found a failing edge case

This commit is contained in:
Nate 2024-09-16 22:42:38 -07:00
parent ef17fa81a7
commit 06859ee9bf
2 changed files with 98 additions and 1 deletions

View file

@ -133,10 +133,14 @@ describe("deterministicApplyLazyEdit(", () => {
await expectDiff("fastapi.py");
});
test.only("calculator exp", async () => {
test("calculator exp", async () => {
await expectDiff("calculator-exp.js");
});
test.only("calculator exp2", async () => {
await expectDiff("calculator-exp2.js");
});
test("calculator comments", async () => {
await expectDiff("calculator-comments.js");
});

View file

@ -0,0 +1,93 @@
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;
}
}
---
class Calculator {
// ... existing code ...
exp(number) {
this.result = Math.pow(this.result, number);
return this;
}
}
---
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;
}
+
+ exp(a) {
+ this.result = Math.pow(this.result, a);
+ return this;
+ }
}