Skip to content

Commit

Permalink
test: Add more simple test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JothamWong committed Mar 28, 2024
1 parent 86d6d51 commit b892926
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,56 @@ x;
5
);

testProgram(
`
var x = 5;
x + 2;
`,
7
);

testProgram(
`
var x = 5;
x - 2;
`,
3
);

testProgram(
`
var x = 4;
x / 2;
`,
2
);

testProgram(
`
var x = 5;
x * 3;
`,
15
);

// Test blocks and scope
testProgram(`
var x = 5;
{
x = 6;
}
x;
`, 6);

testProgram(`
var x = 5;
var y = 10;
{
var x = 6;
var y = 6;
}
x + y;
`, 15);

// Testing simple identity function
testProgram(
Expand All @@ -54,6 +103,30 @@ foo(5);
5
);

// Testing literals
testProgram(`
5
`, 5);

// Testing conditionals
testProgram(`
var x = 5;
if (x == 5) {
6;
} else {
7;
}
`, 6);

testProgram(`
var x = 6;
if (x == 5) {
6;
} else {
7;
}
`, 7);

// Testing recursive function
testProgram(
`
Expand Down

0 comments on commit b892926

Please sign in to comment.