solve another test
This commit is contained in:
parent
458224e96a
commit
10b5ac52dd
2 changed files with 6 additions and 16 deletions
|
|
@ -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],
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue