Skip to content

Commit

Permalink
added failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Jan 11, 2025
1 parent af081f5 commit 94c9adc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ list[TextEdit] treeDiff(
default list[TextEdit] treeDiff(
t:appl(Production p:prod(_,_,_), list[Tree] _),
r:appl(Production q:!p , list[Tree] _))
= [replace(t@\loc, learnIndentation(t@\loc, "<r>", "<t>"))];
= [replace(t@\loc, learnIndentation(t@\loc, "<r>", "<t>"))] when bprintln(t);

// If list production are the same, then the element lists can still be of different length
// and we switch to listDiff which has different heuristics than normal trees.
Expand All @@ -235,7 +235,7 @@ list[TextEdit] treeDiff(

// When the productions are equal, but the children may be different, we dig deeper for differences
default list[TextEdit] treeDiff(appl(Production p, list[Tree] argsA), appl(p, list[Tree] argsB))
= [*treeDiff(a, b) | <a,b> <- zip2(argsA, argsB)];
= [*treeDiff(a, b) | <a,b> <- zip2(argsA, argsB)] when bprintln("into <p> on both sides");

@synopsis{decide how many separators we have}
int seps(\iter-seps(_,list[Symbol] s)) = size(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ start[Program] swapAB(start[Program] p) = visit(p) {
case (Id) `b` => (Id) `a`
};

start[Program] naturalToString(start[Program] p) = visit(p) {
case (Type) `natural` => (Type) `string`
};

start[Program] addDeclarationToEnd(start[Program] p) = visit(p) {
case (Program) `begin declare <{IdType ","}* decls>; <{Statement ";"}* body> end`
=> (Program) `begin
Expand Down Expand Up @@ -116,3 +120,6 @@ test bool addDeclarationToStartAndSwapABTest()

test bool addDeclarationToStartAndEndAndSwapABTest()
= editsAreSyntacticallyCorrect(#start[Program], simpleExample, addDeclarationToStart o addDeclarationToEnd o swapAB);

test bool naturalToStringTest()
= editsAreSyntacticallyCorrect(#start[Program], simpleExample, naturalToString);

0 comments on commit 94c9adc

Please sign in to comment.