From deea8f1f44403b6d7d7bb4236ff5acb8d38bca01 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Mon, 4 Nov 2024 17:46:12 +0700 Subject: [PATCH] fix: tests --- .../test/NEGATIVE_CASES_STARCODER.tsx | 51 -------- .../test/NEGATIVE_CASES_STARCODER.txt | 123 ++++++++++++++++++ 2 files changed, 123 insertions(+), 51 deletions(-) delete mode 100644 core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.tsx create mode 100644 core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.txt diff --git a/core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.tsx b/core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.tsx deleted file mode 100644 index 269d25f0f..000000000 --- a/core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.tsx +++ /dev/null @@ -1,51 +0,0 @@ -##### Prompt ##### -class Calculator { - constructor() { - this.result = 0; - } - - add(number) { - this.result += number; - return this; - } - - subtract(number) { - this.result -= number; - return this; - } - - multiply(number) { - this.result *= number; - return this; - } - - divide(number) { - if (number === 0) { - throw new Error("Cannot divide by zero"); - } - - - - this.result /= number; - return this; - } - - getResult() { - return this.result; - } - - reset() { - this.result = 0; - return this; - } -} -========================================================================== -========================================================================== -Completion: - - this.result /= number; - return this; - } -} - -module.exports = Calculator; \ No newline at end of file diff --git a/core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.txt b/core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.txt new file mode 100644 index 000000000..9a286d1de --- /dev/null +++ b/core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.txt @@ -0,0 +1,123 @@ +##### Prompt ##### +class Calculator { + constructor() { + this.result = 0; + } + + add(number) { + this.result += number; + return this; + } + + subtract(number) { + this.result -= number; + return this; + } + + multiply(number) { + this.result *= number; + return this; + } + + divide(number) { + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + + + + this.result /= number; + return this; + } + + getResult() { + return this.result; + } + + reset() { + this.result = 0; + return this; + } +} +========================================================================== +========================================================================== +Completion: + + this.result /= number; + return this; + } +} + +module.exports = Calculator; + +------------------------------------------------------------------------ + +##### Prompt ##### +class Calculator { + constructor() { + this.result = 0; + } + + add(number) { + this.result += number; + return this; + } + + subtract(number) { + this.result -= number; + return this; + } + + multiply(number) { + this.result *= number; + return this; + } + + divide(number) { + if (number === 0) { + throw new Error("Cannot divide by zero"); + } + this.result /= number; + return this; + } + + + + + + + getResult() { + return this.result; + } + + reset() { + this.result = 0; + return this; + } +} +========================================================================== +========================================================================== +Completion: + + getResult() { + return this.result; + } + + reset() { + this.result = 0; + return this; + } +} + +// Example usage: +const calculator = new Calculator(); +calculator.add(5).subtract(3).multiply(2).divide(4); +console.log(calculator.getResult()); // Output: 2 + +calculator.reset().add(10).divide(2); +console.log(calculator.getResult()); // Output: 5 + +calculator.reset().add(8).multiply(0); +console.log(calculator.getResult()); // Output: 0 + +calculator.reset().add(6).divide(0); // Throws an error: Cannot divide by zero \ No newline at end of file