v1
1/14/2023 by sufian -00
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
function TrackedFunctionAssign(fn) {
  let callCount = 0;

  const wrapped = (...args) => {
    callCount += 1;
    return fn(...args);
  };

  return Object.assign(wrapped, {
    member1: () => callCount,
    member2: () => callCount,
    member3: () => callCount,
    member4: () => callCount,
    member5: () => callCount,
    member6: () => callCount,
    member7: () => callCount,
    member8: () => callCount,
    member9: () => callCount,
    member10: () => callCount,
  });
}

class TrackedFunctionClass extends Function {
  constructor(fn) {
    const self = (...args) => {
      self.callCount += 1;
      return fn(...args);
    };

    self.callCount = 0;

    Object.setPrototypeOf(self, TrackedFunctionClass.prototype);

    return self;
  }

  member1() { return this.callCount; }
  member2() { return this.callCount; }
  member3() { return this.callCount; }
  member4() { return this.callCount; }
  member5() { return this.callCount; }
  member6() { return this.callCount; }
  member7() { return this.callCount; }
  member8() { return this.callCount; }
  member9() { return this.callCount; }
  member10() { return this.callCount; }
}

delete caserun single casemove downdrag and drop case


ready



const add = TrackedFunctionAssign((a, b) => a + b);
delete caserun single casemove updrag and drop case


ready



const add = new TrackedFunctionClass((a, b) => a + b);
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN