<commit_before>import * as td from "../../../";

const f = td.function();
td.when(f(10)).thenReturn(10);
td.when(f(1)).thenThrow(new Error("ok"));
td.when(f(td.matchers.isA(String))).thenDo(function(s: string) { return s; });
td.when(f(td.matchers.not(true))).thenResolve("value");
td.when(f(td.matchers.not(false))).thenReject(new Error("rejected"));

class Dog {
  bark() {}
}

const dog = td.object(Dog);
td.when(dog.bark()).thenReturn("bark!");

const bird = td.object({ fly: function(){} });
td.when(bird.fly()).thenReturn("fly!");

td.replace({}, "prop");
td.replace({}, "prop", 42);
td.replace("../../..");
td.replace("../../../", 42);

td.verify(f());
td.verify(f(), { times: 1 });
td.verify(f(), { ignoreExtraArgs: false });
td.verify(f(), { ignoreExtraArgs: true, times: 2 });

const explanation = td.explain(f);
console.log(
  explanation.description,
  explanation.calls.length,
  explanation.callCount
);
<commit_msg>fixes call at least ¯\_(ツ)_/¯ <commit_after>import * as td from "../../../";

const f = td.function();
td.when(f(10)).thenReturn(10);
td.when(f(1)).thenThrow(new Error("ok"));
td.when(f(td.matchers.isA(String))).thenDo(function(s: string) { return s; });
td.when(f(td.matchers.not(true))).thenResolve("value");
td.when(f(td.matchers.not(false))).thenReject(new Error("rejected"));

class Dog {
  bark() {}
}

const dog = td.constructor(Dog);
td.when(dog.bark()).thenReturn("bark!");

const bird = td.object({ fly: function(){} });
td.when(bird.fly()).thenReturn("fly!");

td.replace({}, "prop");
td.replace({}, "prop", 42);
td.replace("../../..");
td.replace("../../../", 42);

td.verify(f());
td.verify(f(), { times: 1 });
td.verify(f(), { ignoreExtraArgs: false });
td.verify(f(), { ignoreExtraArgs: true, times: 2 });

const explanation = td.explain(f);
console.log(
  explanation.description,
  explanation.calls.length,
  explanation.callCount
);

{'fraction_non_alphanumeric': 0.2635494155154091, 'fraction_numerical': 0.011689691817215728, 'mean_word_length': 4.884375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6172632', 'n_tokens_mistral': 703, 'n_tokens_neox': 693, 'n_words': 119}