From 4b3282c5a1845b98852b9f9aa7ccedbb16bead7e Mon Sep 17 00:00:00 2001 From: Pierre Wilke <pierre.wilke@centralesupelec.fr> Date: Tue, 17 Mar 2020 10:54:52 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20des=20tests=20funcall.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/funcall/2apb.e | 4 +- tests/funcall/2apb.e.expect_14_12_3_8_12 | 1 + tests/funcall/2apb.e.expect_1_2_3 | 1 + tests/funcall/2apb.e.expect_lexer | 29 ++++ tests/funcall/5args.e | 6 +- tests/funcall/5args.e.expect_14_12_3_8_12 | 1 + tests/funcall/5args.e.expect_1_2_3 | 1 + tests/funcall/5args.e.expect_lexer | 50 ++++++ tests/funcall/argswap.e | 9 +- tests/funcall/argswap.e.expect_14_12_3_8_12 | 1 + tests/funcall/argswap.e.expect_1_2_3 | 1 + tests/funcall/argswap.e.expect_lexer | 68 +++++++++ tests/funcall/even_more_args.e | 44 +++--- .../even_more_args.e.expect_14_12_3_8_12 | 1 + tests/funcall/even_more_args.e.expect_1_2_3 | 1 + tests/funcall/even_more_args.e.expect_lexer | 143 ++++++++++++++++++ tests/funcall/f+g.e | 6 +- tests/funcall/f+g.e.expect_14_12_3_8_12 | 1 + tests/funcall/f+g.e.expect_1_2_3 | 1 + tests/funcall/f+g.e.expect_lexer | 39 +++++ tests/funcall/f_3.e | 4 +- tests/funcall/f_3.e.expect_14_12_3_8_12 | 1 + tests/funcall/f_3.e.expect_1_2_3 | 1 + tests/funcall/f_3.e.expect_lexer | 19 +++ tests/funcall/fib.e.expect_14_12_3_8_12 | 1 + tests/funcall/fib.e.expect_1_2_3 | 1 + tests/funcall/fib.e.expect_lexer | 60 ++++++++ tests/funcall/gcdrec.e | 6 +- tests/funcall/gcdrec.e.expect_14_12_3_8_12 | 1 + tests/funcall/gcdrec.e.expect_1_2_3 | 1 + tests/funcall/gcdrec.e.expect_lexer | 49 ++++++ tests/funcall/hanoi.e | 7 +- tests/funcall/hanoi.e.expect_14_12_3_8_12 | 1 + tests/funcall/hanoi.e.expect_1_2_3 | 1 + tests/funcall/hanoi.e.expect_lexer | 46 ++++++ tests/funcall/lots_of_args.e | 24 +-- .../lots_of_args.e.expect_14_12_3_8_12 | 1 + tests/funcall/lots_of_args.e.expect_1_2_3 | 1 + tests/funcall/lots_of_args.e.expect_lexer | 75 +++++++++ tests/funcall/print_and_fun.e | 6 +- .../print_and_fun.e.expect_14_12_3_8_12 | 1 + tests/funcall/print_and_fun.e.expect_1_2_3 | 1 + tests/funcall/print_and_fun.e.expect_lexer | 53 +++++++ 43 files changed, 708 insertions(+), 61 deletions(-) create mode 100644 tests/funcall/2apb.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/2apb.e.expect_1_2_3 create mode 100644 tests/funcall/2apb.e.expect_lexer create mode 100644 tests/funcall/5args.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/5args.e.expect_1_2_3 create mode 100644 tests/funcall/5args.e.expect_lexer create mode 100644 tests/funcall/argswap.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/argswap.e.expect_1_2_3 create mode 100644 tests/funcall/argswap.e.expect_lexer create mode 100644 tests/funcall/even_more_args.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/even_more_args.e.expect_1_2_3 create mode 100644 tests/funcall/even_more_args.e.expect_lexer create mode 100644 tests/funcall/f+g.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/f+g.e.expect_1_2_3 create mode 100644 tests/funcall/f+g.e.expect_lexer create mode 100644 tests/funcall/f_3.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/f_3.e.expect_1_2_3 create mode 100644 tests/funcall/f_3.e.expect_lexer create mode 100644 tests/funcall/fib.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/fib.e.expect_1_2_3 create mode 100644 tests/funcall/fib.e.expect_lexer create mode 100644 tests/funcall/gcdrec.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/gcdrec.e.expect_1_2_3 create mode 100644 tests/funcall/gcdrec.e.expect_lexer create mode 100644 tests/funcall/hanoi.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/hanoi.e.expect_1_2_3 create mode 100644 tests/funcall/hanoi.e.expect_lexer create mode 100644 tests/funcall/lots_of_args.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/lots_of_args.e.expect_1_2_3 create mode 100644 tests/funcall/lots_of_args.e.expect_lexer create mode 100644 tests/funcall/print_and_fun.e.expect_14_12_3_8_12 create mode 100644 tests/funcall/print_and_fun.e.expect_1_2_3 create mode 100644 tests/funcall/print_and_fun.e.expect_lexer diff --git a/tests/funcall/2apb.e b/tests/funcall/2apb.e index cad9626..4ff99d0 100644 --- a/tests/funcall/2apb.e +++ b/tests/funcall/2apb.e @@ -1,6 +1,6 @@ -int main(int argc,char* argv[]){ +main(){ return f(8,3); } -int f(int a,int b){ +f(a, b){ return a + 2 * b; } diff --git a/tests/funcall/2apb.e.expect_14_12_3_8_12 b/tests/funcall/2apb.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..e2ce800 --- /dev/null +++ b/tests/funcall/2apb.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/funcall/2apb.e.expect_1_2_3 b/tests/funcall/2apb.e.expect_1_2_3 new file mode 100644 index 0000000..e2ce800 --- /dev/null +++ b/tests/funcall/2apb.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 14} \ No newline at end of file diff --git a/tests/funcall/2apb.e.expect_lexer b/tests/funcall/2apb.e.expect_lexer new file mode 100644 index 0000000..8197b9b --- /dev/null +++ b/tests/funcall/2apb.e.expect_lexer @@ -0,0 +1,29 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(3) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(b) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/5args.e b/tests/funcall/5args.e index 818871c..59f7469 100644 --- a/tests/funcall/5args.e +++ b/tests/funcall/5args.e @@ -1,8 +1,6 @@ -int main(int argc,char* argv[]){ - int x = atoi(argv[1]); - int y = atoi(argv[2]); +main(x, y){ return f(x,x,y,y,x*2); } -int f(int x,int y,int z,int t,int u){ +f(x, y, z, t, u){ return x + y + z + t + u; } diff --git a/tests/funcall/5args.e.expect_14_12_3_8_12 b/tests/funcall/5args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..e9a8021 --- /dev/null +++ b/tests/funcall/5args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 80} \ No newline at end of file diff --git a/tests/funcall/5args.e.expect_1_2_3 b/tests/funcall/5args.e.expect_1_2_3 new file mode 100644 index 0000000..61b83a8 --- /dev/null +++ b/tests/funcall/5args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 8} \ No newline at end of file diff --git a/tests/funcall/5args.e.expect_lexer b/tests/funcall/5args.e.expect_lexer new file mode 100644 index 0000000..aeb9624 --- /dev/null +++ b/tests/funcall/5args.e.expect_lexer @@ -0,0 +1,50 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(x) +SYM_ASTERISK +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_COMMA +SYM_IDENTIFIER(z) +SYM_COMMA +SYM_IDENTIFIER(t) +SYM_COMMA +SYM_IDENTIFIER(u) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_IDENTIFIER(y) +SYM_PLUS +SYM_IDENTIFIER(z) +SYM_PLUS +SYM_IDENTIFIER(t) +SYM_PLUS +SYM_IDENTIFIER(u) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/argswap.e b/tests/funcall/argswap.e index f910ae5..615371c 100644 --- a/tests/funcall/argswap.e +++ b/tests/funcall/argswap.e @@ -1,14 +1,13 @@ -int g(int a, int b){ +g(a,b){ print(a); print(b); return (b - a); } -int f(int a, int b){ +f(a,b){ print(a); print(b); return g(b, a); } -int main(int argc, char* argv[]){ - return f(atoi(argv[1]), - atoi(argv[2])); +main(x, y){ + return f(x, y); } diff --git a/tests/funcall/argswap.e.expect_14_12_3_8_12 b/tests/funcall/argswap.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..38f595a --- /dev/null +++ b/tests/funcall/argswap.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "14\n12\n12\n14\n", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/funcall/argswap.e.expect_1_2_3 b/tests/funcall/argswap.e.expect_1_2_3 new file mode 100644 index 0000000..e03517f --- /dev/null +++ b/tests/funcall/argswap.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "1\n2\n2\n1\n", "error": null, "retval": -1} \ No newline at end of file diff --git a/tests/funcall/argswap.e.expect_lexer b/tests/funcall/argswap.e.expect_lexer new file mode 100644 index 0000000..2c8a87d --- /dev/null +++ b/tests/funcall/argswap.e.expect_lexer @@ -0,0 +1,68 @@ +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_MINUS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_COMMA +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/even_more_args.e b/tests/funcall/even_more_args.e index 9e04d35..281e743 100644 --- a/tests/funcall/even_more_args.e +++ b/tests/funcall/even_more_args.e @@ -1,27 +1,27 @@ -int f(int a, - int b, - int c, - int d, - int e, - int f, - int g, - int h, - int i, - int j, - int k, - int l, - int m, - int n, - int o, - int p, - int q, - int r, - int s, - int t - ){ +f(a, + b, + c, + d, + e, + f, + g, + h, + i, + j, + k, + l, + m, + n, + o, + p, + q, + r, + s, + t + ){ return (k * (a + b * c + d * e * f + g * h * i * j) + (l + m * n) * o + p * q) * (r + s * t); } -int main(int argc, char* argv[]){ +main(){ return f(1,2,3,4,5,6,7,8,9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); } diff --git a/tests/funcall/even_more_args.e.expect_14_12_3_8_12 b/tests/funcall/even_more_args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..1705ac5 --- /dev/null +++ b/tests/funcall/even_more_args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23887562} \ No newline at end of file diff --git a/tests/funcall/even_more_args.e.expect_1_2_3 b/tests/funcall/even_more_args.e.expect_1_2_3 new file mode 100644 index 0000000..1705ac5 --- /dev/null +++ b/tests/funcall/even_more_args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 23887562} \ No newline at end of file diff --git a/tests/funcall/even_more_args.e.expect_lexer b/tests/funcall/even_more_args.e.expect_lexer new file mode 100644 index 0000000..f29ddb9 --- /dev/null +++ b/tests/funcall/even_more_args.e.expect_lexer @@ -0,0 +1,143 @@ +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(c) +SYM_COMMA +SYM_IDENTIFIER(d) +SYM_COMMA +SYM_IDENTIFIER(e) +SYM_COMMA +SYM_IDENTIFIER(f) +SYM_COMMA +SYM_IDENTIFIER(g) +SYM_COMMA +SYM_IDENTIFIER(h) +SYM_COMMA +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_COMMA +SYM_IDENTIFIER(k) +SYM_COMMA +SYM_IDENTIFIER(l) +SYM_COMMA +SYM_IDENTIFIER(m) +SYM_COMMA +SYM_IDENTIFIER(n) +SYM_COMMA +SYM_IDENTIFIER(o) +SYM_COMMA +SYM_IDENTIFIER(p) +SYM_COMMA +SYM_IDENTIFIER(q) +SYM_COMMA +SYM_IDENTIFIER(r) +SYM_COMMA +SYM_IDENTIFIER(s) +SYM_COMMA +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_LPARENTHESIS +SYM_IDENTIFIER(k) +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_ASTERISK +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_IDENTIFIER(d) +SYM_ASTERISK +SYM_IDENTIFIER(e) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_ASTERISK +SYM_IDENTIFIER(h) +SYM_ASTERISK +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_PLUS +SYM_LPARENTHESIS +SYM_IDENTIFIER(l) +SYM_PLUS +SYM_IDENTIFIER(m) +SYM_ASTERISK +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_IDENTIFIER(o) +SYM_PLUS +SYM_IDENTIFIER(p) +SYM_ASTERISK +SYM_IDENTIFIER(q) +SYM_RPARENTHESIS +SYM_ASTERISK +SYM_LPARENTHESIS +SYM_IDENTIFIER(r) +SYM_PLUS +SYM_IDENTIFIER(s) +SYM_ASTERISK +SYM_IDENTIFIER(t) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(2) +SYM_COMMA +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_COMMA +SYM_INTEGER(6) +SYM_COMMA +SYM_INTEGER(7) +SYM_COMMA +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(9) +SYM_COMMA +SYM_INTEGER(10) +SYM_COMMA +SYM_INTEGER(11) +SYM_COMMA +SYM_INTEGER(12) +SYM_COMMA +SYM_INTEGER(13) +SYM_COMMA +SYM_INTEGER(14) +SYM_COMMA +SYM_INTEGER(15) +SYM_COMMA +SYM_INTEGER(16) +SYM_COMMA +SYM_INTEGER(17) +SYM_COMMA +SYM_INTEGER(18) +SYM_COMMA +SYM_INTEGER(19) +SYM_COMMA +SYM_INTEGER(20) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/f+g.e b/tests/funcall/f+g.e index c50653a..c88d2f1 100644 --- a/tests/funcall/f+g.e +++ b/tests/funcall/f+g.e @@ -1,10 +1,10 @@ -int f(int x){ +f(x){ return x + 2; } -int g(int y){ +g(y){ return y * 3; } -int main(int argc,char* argv[]){ +main(){ return f(8) + g(5); } diff --git a/tests/funcall/f+g.e.expect_14_12_3_8_12 b/tests/funcall/f+g.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..c24e9b8 --- /dev/null +++ b/tests/funcall/f+g.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 25} \ No newline at end of file diff --git a/tests/funcall/f+g.e.expect_1_2_3 b/tests/funcall/f+g.e.expect_1_2_3 new file mode 100644 index 0000000..c24e9b8 --- /dev/null +++ b/tests/funcall/f+g.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 25} \ No newline at end of file diff --git a/tests/funcall/f+g.e.expect_lexer b/tests/funcall/f+g.e.expect_lexer new file mode 100644 index 0000000..0ebab59 --- /dev/null +++ b/tests/funcall/f+g.e.expect_lexer @@ -0,0 +1,39 @@ +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_PLUS +SYM_INTEGER(2) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(y) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(y) +SYM_ASTERISK +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_RPARENTHESIS +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INTEGER(5) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/f_3.e b/tests/funcall/f_3.e index da963c0..249610c 100644 --- a/tests/funcall/f_3.e +++ b/tests/funcall/f_3.e @@ -1,6 +1,6 @@ -int main(int argc,char* argv[]){ +main(){ return f(); } -int f(){ +f(){ return 3; } diff --git a/tests/funcall/f_3.e.expect_14_12_3_8_12 b/tests/funcall/f_3.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..ff173ec --- /dev/null +++ b/tests/funcall/f_3.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/funcall/f_3.e.expect_1_2_3 b/tests/funcall/f_3.e.expect_1_2_3 new file mode 100644 index 0000000..ff173ec --- /dev/null +++ b/tests/funcall/f_3.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 3} \ No newline at end of file diff --git a/tests/funcall/f_3.e.expect_lexer b/tests/funcall/f_3.e.expect_lexer new file mode 100644 index 0000000..79b5dd3 --- /dev/null +++ b/tests/funcall/f_3.e.expect_lexer @@ -0,0 +1,19 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(3) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/fib.e.expect_14_12_3_8_12 b/tests/funcall/fib.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..1fef237 --- /dev/null +++ b/tests/funcall/fib.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 377} \ No newline at end of file diff --git a/tests/funcall/fib.e.expect_1_2_3 b/tests/funcall/fib.e.expect_1_2_3 new file mode 100644 index 0000000..91ce1a2 --- /dev/null +++ b/tests/funcall/fib.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/funcall/fib.e.expect_lexer b/tests/funcall/fib.e.expect_lexer new file mode 100644 index 0000000..0782208 --- /dev/null +++ b/tests/funcall/fib.e.expect_lexer @@ -0,0 +1,60 @@ +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(14) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_MINUS +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_LEQ +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_INTEGER(1) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_PLUS +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(2) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(fib) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/gcdrec.e b/tests/funcall/gcdrec.e index 4bc69ff..0352c55 100644 --- a/tests/funcall/gcdrec.e +++ b/tests/funcall/gcdrec.e @@ -1,12 +1,10 @@ -int gcd(int a,int b){ +gcd(a,b){ if(b == 0){ return a; } else { return gcd(b, a % b); } } -int main(int argc,char* argv[]){ - int a = atoi(argv[1]); - int b = atoi(argv[2]); +main(a, b){ return gcd(a,b); } diff --git a/tests/funcall/gcdrec.e.expect_14_12_3_8_12 b/tests/funcall/gcdrec.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..df1c5a5 --- /dev/null +++ b/tests/funcall/gcdrec.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 2} \ No newline at end of file diff --git a/tests/funcall/gcdrec.e.expect_1_2_3 b/tests/funcall/gcdrec.e.expect_1_2_3 new file mode 100644 index 0000000..91ce1a2 --- /dev/null +++ b/tests/funcall/gcdrec.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/funcall/gcdrec.e.expect_lexer b/tests/funcall/gcdrec.e.expect_lexer new file mode 100644 index 0000000..e02c133 --- /dev/null +++ b/tests/funcall/gcdrec.e.expect_lexer @@ -0,0 +1,49 @@ +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_EQUALITY +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_SEMICOLON +SYM_RBRACE +SYM_ELSE +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(a) +SYM_MOD +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(gcd) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/hanoi.e b/tests/funcall/hanoi.e index ee9d726..5b485da 100644 --- a/tests/funcall/hanoi.e +++ b/tests/funcall/hanoi.e @@ -1,12 +1,11 @@ -int main(int argc,char* argv[]){ - int ndisque = atoi(argv[1]); +main(ndisque){ return hanoi(ndisque); } -int hanoi(int n) +hanoi(n) { if(n > 0) { - int x = hanoi(n-1); + x = hanoi(n-1); return 1 + 2 * x; } return 0; diff --git a/tests/funcall/hanoi.e.expect_14_12_3_8_12 b/tests/funcall/hanoi.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..7cf52b9 --- /dev/null +++ b/tests/funcall/hanoi.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 16383} \ No newline at end of file diff --git a/tests/funcall/hanoi.e.expect_1_2_3 b/tests/funcall/hanoi.e.expect_1_2_3 new file mode 100644 index 0000000..91ce1a2 --- /dev/null +++ b/tests/funcall/hanoi.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 1} \ No newline at end of file diff --git a/tests/funcall/hanoi.e.expect_lexer b/tests/funcall/hanoi.e.expect_lexer new file mode 100644 index 0000000..6ba0a1e --- /dev/null +++ b/tests/funcall/hanoi.e.expect_lexer @@ -0,0 +1,46 @@ +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_IDENTIFIER(ndisque) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(ndisque) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IF +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_GT +SYM_INTEGER(0) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(x) +SYM_ASSIGN +SYM_IDENTIFIER(hanoi) +SYM_LPARENTHESIS +SYM_IDENTIFIER(n) +SYM_MINUS +SYM_INTEGER(1) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(1) +SYM_PLUS +SYM_INTEGER(2) +SYM_ASTERISK +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/lots_of_args.e b/tests/funcall/lots_of_args.e index 3dc2575..a8017e1 100644 --- a/tests/funcall/lots_of_args.e +++ b/tests/funcall/lots_of_args.e @@ -1,17 +1,17 @@ -int f(int a, - int b, - int c, - int d, - int e, - int f, - int g, - int h, - int i, - int j - ){ +f(a, + b, + c, + d, + e, + f, + g, + h, + i, + j + ){ return a + b * c + d * e * f + g * h * i * j; } -int main(int argc, char* argv[]){ +main(){ return f(1,2,3,4,5,6,7,8,9,10); } diff --git a/tests/funcall/lots_of_args.e.expect_14_12_3_8_12 b/tests/funcall/lots_of_args.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..16d63e1 --- /dev/null +++ b/tests/funcall/lots_of_args.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5167} \ No newline at end of file diff --git a/tests/funcall/lots_of_args.e.expect_1_2_3 b/tests/funcall/lots_of_args.e.expect_1_2_3 new file mode 100644 index 0000000..16d63e1 --- /dev/null +++ b/tests/funcall/lots_of_args.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "", "error": null, "retval": 5167} \ No newline at end of file diff --git a/tests/funcall/lots_of_args.e.expect_lexer b/tests/funcall/lots_of_args.e.expect_lexer new file mode 100644 index 0000000..3c28c41 --- /dev/null +++ b/tests/funcall/lots_of_args.e.expect_lexer @@ -0,0 +1,75 @@ +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_COMMA +SYM_IDENTIFIER(c) +SYM_COMMA +SYM_IDENTIFIER(d) +SYM_COMMA +SYM_IDENTIFIER(e) +SYM_COMMA +SYM_IDENTIFIER(f) +SYM_COMMA +SYM_IDENTIFIER(g) +SYM_COMMA +SYM_IDENTIFIER(h) +SYM_COMMA +SYM_IDENTIFIER(i) +SYM_COMMA +SYM_IDENTIFIER(j) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(a) +SYM_PLUS +SYM_IDENTIFIER(b) +SYM_ASTERISK +SYM_IDENTIFIER(c) +SYM_PLUS +SYM_IDENTIFIER(d) +SYM_ASTERISK +SYM_IDENTIFIER(e) +SYM_ASTERISK +SYM_IDENTIFIER(f) +SYM_PLUS +SYM_IDENTIFIER(g) +SYM_ASTERISK +SYM_IDENTIFIER(h) +SYM_ASTERISK +SYM_IDENTIFIER(i) +SYM_ASTERISK +SYM_IDENTIFIER(j) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(1) +SYM_COMMA +SYM_INTEGER(2) +SYM_COMMA +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_COMMA +SYM_INTEGER(5) +SYM_COMMA +SYM_INTEGER(6) +SYM_COMMA +SYM_INTEGER(7) +SYM_COMMA +SYM_INTEGER(8) +SYM_COMMA +SYM_INTEGER(9) +SYM_COMMA +SYM_INTEGER(10) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF diff --git a/tests/funcall/print_and_fun.e b/tests/funcall/print_and_fun.e index 6f6901a..0c24e56 100644 --- a/tests/funcall/print_and_fun.e +++ b/tests/funcall/print_and_fun.e @@ -1,16 +1,16 @@ -int g(int x){ +g(x){ return x; } -int f(int a, int b){ +f(a, b){ b = g(8); print(a); print(b); return 0; } -int main(int argc, char* argv[]){ +main(){ f(3,4); return 0; } diff --git a/tests/funcall/print_and_fun.e.expect_14_12_3_8_12 b/tests/funcall/print_and_fun.e.expect_14_12_3_8_12 new file mode 100644 index 0000000..7d935d7 --- /dev/null +++ b/tests/funcall/print_and_fun.e.expect_14_12_3_8_12 @@ -0,0 +1 @@ +{"output": "3\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/funcall/print_and_fun.e.expect_1_2_3 b/tests/funcall/print_and_fun.e.expect_1_2_3 new file mode 100644 index 0000000..7d935d7 --- /dev/null +++ b/tests/funcall/print_and_fun.e.expect_1_2_3 @@ -0,0 +1 @@ +{"output": "3\n8\n", "error": null, "retval": 0} \ No newline at end of file diff --git a/tests/funcall/print_and_fun.e.expect_lexer b/tests/funcall/print_and_fun.e.expect_lexer new file mode 100644 index 0000000..834218f --- /dev/null +++ b/tests/funcall/print_and_fun.e.expect_lexer @@ -0,0 +1,53 @@ +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_IDENTIFIER(x) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_RETURN +SYM_IDENTIFIER(x) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_COMMA +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(b) +SYM_ASSIGN +SYM_IDENTIFIER(g) +SYM_LPARENTHESIS +SYM_INTEGER(8) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(a) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_IDENTIFIER(print) +SYM_LPARENTHESIS +SYM_IDENTIFIER(b) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_IDENTIFIER(main) +SYM_LPARENTHESIS +SYM_RPARENTHESIS +SYM_LBRACE +SYM_IDENTIFIER(f) +SYM_LPARENTHESIS +SYM_INTEGER(3) +SYM_COMMA +SYM_INTEGER(4) +SYM_RPARENTHESIS +SYM_SEMICOLON +SYM_RETURN +SYM_INTEGER(0) +SYM_SEMICOLON +SYM_RBRACE +SYM_EOF -- GitLab