Skip to content

Commit

Permalink
CURRENT TESTS PASSED
Browse files Browse the repository at this point in the history
for i in 1 to 5 : {print i}
  • Loading branch information
pannous committed Dec 11, 2024
1 parent cc572a9 commit 66df15d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion source/Angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,11 @@ Node &groupForIn(Node &n, Function &context) {
addLocal(context, variable.name, int32, false);
Node &begin = n[3];
Node &end = n[5];
Node &body = (n.length > 6) ? n[6] : end.values();
Node &body = end.values();// for i in 1 to 5 : {print i}
if (n.length == 6) body = n[6];
if (n.length > 6) body = n.from(6);
if (n.length > 6 and n[6].name == ":") body = n.from(7);

body.setType(expression); // if …
Node *foro = new Node("for");
Node &ef = *foro;
Expand Down
7 changes: 6 additions & 1 deletion source/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ void testAssert() {
}

void testForLoops() {
assert_emit("for i in 1 to 5 {print i};i", 6);
assert_emit("for i in 1 to 5 : {print i};i", 6);
assert_emit("for i in 1 to 5 {print i}", 5);
assert_emit("for i in 1 to 5 {print i};i", 6); // after loop :(
assert_emit("for i in 1 to 5 : print i", 5);
assert_emit("for i in 1 to 5\n print i\ni", 5);
assert_emit("for i in 1 to 5\n print i\ni", 5);
// assert_emit("sum=0\nfor i in (1..3) {sum+=i}\nsum", 6);
// assert_emit("sum=0;for i in (1..3) {sum+=i};sum", 6);
// assert_emit("sum=0;for i=1..3;sum+=i;sum", 6);
Expand Down

0 comments on commit 66df15d

Please sign in to comment.