Skip to content

Commit

Permalink
Add default initialization tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JothamWong committed Apr 13, 2024
1 parent d31d41f commit 2425e07
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1690,3 +1690,24 @@ print(y[5]); // shud be 10
print(len(x)); // should be 5
y[0]; // should be 0
`, 0, '10\n5\n', defaultNumWords);

// Testing default initialization
testProgram(`
var x []bool = make([]bool, 5, 5); // create a slice of len 5 and capacity 5
for i := 0; i < len(x); i++ {
print(x[i]);
}
0;
`, 0, 'false\nfalse\nfalse\nfalse\nfalse\n', defaultNumWords);


testProgram(`
var x []string = make([]string, 5, 5); // create a slice of len 5 and capacity 5
x = append(x, "Jotham");
for i := 0; i < len(x); i++ {
print(x[i]);
}
0;
`, 0, '""\n""\n""\n""\n""\n"Jotham"\n', defaultNumWords);

0 comments on commit 2425e07

Please sign in to comment.