solve another test

This commit is contained in:
Nate 2024-09-18 07:51:13 -07:00
parent 458224e96a
commit 10b5ac52dd
2 changed files with 6 additions and 16 deletions

View file

@ -137,16 +137,6 @@ function nodesAreExact(a: Parser.SyntaxNode, b: Parser.SyntaxNode): boolean {
return a.text === b.text;
}
function diffLinesForNode(
node: Parser.SyntaxNode,
type: DiffLine["type"],
): DiffLine[] {
return node.text.split("\n").map((line) => ({
line,
type,
}));
}
/**
* Should be like Myers diff, but lazy blocks consume all nodes until the next match
* @param newNode
@ -229,7 +219,7 @@ function diffNodes(
if (isLazy) {
acc.push({
lazyBlockNode: currentLazyBlockNode!,
replacementNodes: [...currentLazyBlockReplacementNodes],
replacementNodes: [...currentLazyBlockReplacementNodes, ...leftChildren],
});
}

View file

@ -47,11 +47,11 @@ class Calculator {
class Subtract extends Calculator {
sub(num1, num2) {
this.result = num1 - num2;
+
+ if (this.result < 0) {
+ throw new Error("Result cannot be negative");
+ }
+
+
+ if (this.result < 0) {
+ throw new Error("Result cannot be negative");
+ }
+
return this.result;
}
}