fix: tests
This commit is contained in:
parent
400be9b47f
commit
deea8f1f44
2 changed files with 123 additions and 51 deletions
|
|
@ -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");
|
||||
}
|
||||
|
||||
<FIM>
|
||||
|
||||
this.result /= number;
|
||||
return this;
|
||||
}
|
||||
|
||||
getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.result = 0;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
==========================================================================
|
||||
==========================================================================
|
||||
Completion:
|
||||
|
||||
this.result /= number;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Calculator;
|
||||
123
core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.txt
Normal file
123
core/autocomplete/filtering/test/NEGATIVE_CASES_STARCODER.txt
Normal file
|
|
@ -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");
|
||||
}
|
||||
|
||||
<FIM>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
<FIM>
|
||||
|
||||
|
||||
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
|
||||
Loading…
Add table
Reference in a new issue