From 01406ad25ff49d5c5f722f34187d2063cefea5ed Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 6 Jun 2018 14:14:55 +0200 Subject: require main func and rename tests --- res/ko_sample.tpc | 24 ------------------------ res/ok_sample.tpc | 22 ---------------------- res/test-table-symboles.tpc | 14 -------------- res/test_add.tpc | 11 ----------- res/test_add_ok.tpc | 11 +++++++++++ res/test_array.tpc | 10 ---------- res/test_array_ok.tpc | 10 ++++++++++ res/test_global.tpc | 18 ------------------ res/test_global_ok.tpc | 18 ++++++++++++++++++ res/test_if.tpc | 22 ---------------------- res/test_if_ok.tpc | 22 ++++++++++++++++++++++ res/test_mul.tpc | 13 ------------- res/test_mul_ok.tpc | 13 +++++++++++++ res/test_nomain_ko.tpc | 6 ++++++ res/test_parameters.tpc | 18 ------------------ res/test_parameters_ok.tpc | 18 ++++++++++++++++++ res/test_read.tpc | 13 ------------- res/test_read_ok.tpc | 13 +++++++++++++ res/test_return.tpc | 14 -------------- res/test_return_ok.tpc | 14 ++++++++++++++ res/test_sample_ko.tpc | 24 ++++++++++++++++++++++++ res/test_sample_ok.tpc | 22 ++++++++++++++++++++++ res/test_table_symbols_ok.tpc | 14 ++++++++++++++ res/test_while.tpc | 13 ------------- res/test_while_ok.tpc | 13 +++++++++++++ 25 files changed, 198 insertions(+), 192 deletions(-) delete mode 100644 res/ko_sample.tpc delete mode 100644 res/ok_sample.tpc delete mode 100644 res/test-table-symboles.tpc delete mode 100644 res/test_add.tpc create mode 100644 res/test_add_ok.tpc delete mode 100644 res/test_array.tpc create mode 100644 res/test_array_ok.tpc delete mode 100644 res/test_global.tpc create mode 100644 res/test_global_ok.tpc delete mode 100644 res/test_if.tpc create mode 100644 res/test_if_ok.tpc delete mode 100644 res/test_mul.tpc create mode 100644 res/test_mul_ok.tpc create mode 100644 res/test_nomain_ko.tpc delete mode 100644 res/test_parameters.tpc create mode 100644 res/test_parameters_ok.tpc delete mode 100644 res/test_read.tpc create mode 100644 res/test_read_ok.tpc delete mode 100644 res/test_return.tpc create mode 100644 res/test_return_ok.tpc create mode 100644 res/test_sample_ko.tpc create mode 100644 res/test_sample_ok.tpc create mode 100644 res/test_table_symbols_ok.tpc delete mode 100644 res/test_while.tpc create mode 100644 res/test_while_ok.tpc (limited to 'res') diff --git a/res/ko_sample.tpc b/res/ko_sample.tpc deleted file mode 100644 index 9dc344f..0000000 --- a/res/ko_sample.tpc +++ /dev/null @@ -1,24 +0,0 @@ -/** - * UPEM / Compilation / Projet TPC - * Exemple de fichier source TPC invalide - * Pacien TRAN-GIRARD, Adam NAILI - */ - -const special = 'b'; - -caractere funky_func(entier arg) { - return !arg; -} - -void main(void) { - void ret; - ret = 1 + funky_func(0) * 2; - - while (ret) { - readc(ret); - print(ret); - - if (ret == special) print('!'); - } -} - diff --git a/res/ok_sample.tpc b/res/ok_sample.tpc deleted file mode 100644 index c8d3d9d..0000000 --- a/res/ok_sample.tpc +++ /dev/null @@ -1,22 +0,0 @@ -/** - * UPEM / Compilation / Projet TPC - * Exemple de fichier source TPC valide - * Pacien TRAN-GIRARD, Adam NAILI - */ - -const special = 'b'; - -entier funky_func(entier arg) { - return !arg; -} - -void main(void) { - entier ret; - ret = 1 + funky_func(0) * 2; - - while (1) { - reade(ret); - print(ret); - } -} - diff --git a/res/test-table-symboles.tpc b/res/test-table-symboles.tpc deleted file mode 100644 index b2cc31e..0000000 --- a/res/test-table-symboles.tpc +++ /dev/null @@ -1,14 +0,0 @@ -/* test-table-symboles.tpc */ - -/* Test file for simplified translator of a declaration of variables in C */ -entier r1,b,s,c,r2 ; -caractere letter, digit, punct; - -entier main(void) { - - r1=12; - r2=24; - b=r1+r2; - punct='.'; - return b; -} diff --git a/res/test_add.tpc b/res/test_add.tpc deleted file mode 100644 index 848130c..0000000 --- a/res/test_add.tpc +++ /dev/null @@ -1,11 +0,0 @@ -entier a; - -entier main(void) { - entier a,b,res; - a = 2; - b = 3; - res = a + b; - print(res); - res = a - b; - print(res); -} diff --git a/res/test_add_ok.tpc b/res/test_add_ok.tpc new file mode 100644 index 0000000..848130c --- /dev/null +++ b/res/test_add_ok.tpc @@ -0,0 +1,11 @@ +entier a; + +entier main(void) { + entier a,b,res; + a = 2; + b = 3; + res = a + b; + print(res); + res = a - b; + print(res); +} diff --git a/res/test_array.tpc b/res/test_array.tpc deleted file mode 100644 index a968c22..0000000 --- a/res/test_array.tpc +++ /dev/null @@ -1,10 +0,0 @@ -entier tab[5]; - -entier main(void) { - tab[1]=3; - tab[2]=22; - print(tab[2]+tab[1]); - print(tab[1]); - print(tab[2]); - return 0; -} diff --git a/res/test_array_ok.tpc b/res/test_array_ok.tpc new file mode 100644 index 0000000..a968c22 --- /dev/null +++ b/res/test_array_ok.tpc @@ -0,0 +1,10 @@ +entier tab[5]; + +entier main(void) { + tab[1]=3; + tab[2]=22; + print(tab[2]+tab[1]); + print(tab[1]); + print(tab[2]); + return 0; +} diff --git a/res/test_global.tpc b/res/test_global.tpc deleted file mode 100644 index d8b7d45..0000000 --- a/res/test_global.tpc +++ /dev/null @@ -1,18 +0,0 @@ -entier r1,b,s,c,r2 ; -caractere letter, digit, punct; -entier i; - - -void calcul(void) { - r1=12; - r2=13; - i = 3; - - b = r1 + r2 + i; - print(b); -} - - -entier main(void) { - calcul(); -} diff --git a/res/test_global_ok.tpc b/res/test_global_ok.tpc new file mode 100644 index 0000000..d8b7d45 --- /dev/null +++ b/res/test_global_ok.tpc @@ -0,0 +1,18 @@ +entier r1,b,s,c,r2 ; +caractere letter, digit, punct; +entier i; + + +void calcul(void) { + r1=12; + r2=13; + i = 3; + + b = r1 + r2 + i; + print(b); +} + + +entier main(void) { + calcul(); +} diff --git a/res/test_if.tpc b/res/test_if.tpc deleted file mode 100644 index 054811b..0000000 --- a/res/test_if.tpc +++ /dev/null @@ -1,22 +0,0 @@ -/* test-table-symboles.tpc */ - -/* Test file for simplified translator of a declaration of variables in C */ - -entier main(void) { - entier bool1, bool2; - bool1 = 0; - bool2 = 0; - if(bool1 == bool2){ - if(bool1 != bool2){ - print('n'); - } - else{ - if(bool1 <= bool2){ - print('o'); - return 0; - } - print('n'); - } - } - return 0; -} diff --git a/res/test_if_ok.tpc b/res/test_if_ok.tpc new file mode 100644 index 0000000..054811b --- /dev/null +++ b/res/test_if_ok.tpc @@ -0,0 +1,22 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ + +entier main(void) { + entier bool1, bool2; + bool1 = 0; + bool2 = 0; + if(bool1 == bool2){ + if(bool1 != bool2){ + print('n'); + } + else{ + if(bool1 <= bool2){ + print('o'); + return 0; + } + print('n'); + } + } + return 0; +} diff --git a/res/test_mul.tpc b/res/test_mul.tpc deleted file mode 100644 index 62a8080..0000000 --- a/res/test_mul.tpc +++ /dev/null @@ -1,13 +0,0 @@ -entier a; - -entier main(void) { - entier a,b,res; - a = 2; - b = 3; - res = a * b; - print(res); - res = a / b; - print(res); - res = a % b; - print(res); -} diff --git a/res/test_mul_ok.tpc b/res/test_mul_ok.tpc new file mode 100644 index 0000000..62a8080 --- /dev/null +++ b/res/test_mul_ok.tpc @@ -0,0 +1,13 @@ +entier a; + +entier main(void) { + entier a,b,res; + a = 2; + b = 3; + res = a * b; + print(res); + res = a / b; + print(res); + res = a % b; + print(res); +} diff --git a/res/test_nomain_ko.tpc b/res/test_nomain_ko.tpc new file mode 100644 index 0000000..570c5ca --- /dev/null +++ b/res/test_nomain_ko.tpc @@ -0,0 +1,6 @@ +const c = 0; + +/* not a main */ +void f(void) { + print(c); +} diff --git a/res/test_parameters.tpc b/res/test_parameters.tpc deleted file mode 100644 index 479fb60..0000000 --- a/res/test_parameters.tpc +++ /dev/null @@ -1,18 +0,0 @@ -/* test-table-symboles.tpc */ - -/* Test file for simplified translator of a declaration of variables in C */ - -void test2(caractere x,caractere y,caractere z){ - print(x); - print(y); - print(z); -} - -void test(void){ - test2('a','b','c'); -} - -entier main(void) { - test(); - return 0; -} diff --git a/res/test_parameters_ok.tpc b/res/test_parameters_ok.tpc new file mode 100644 index 0000000..479fb60 --- /dev/null +++ b/res/test_parameters_ok.tpc @@ -0,0 +1,18 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ + +void test2(caractere x,caractere y,caractere z){ + print(x); + print(y); + print(z); +} + +void test(void){ + test2('a','b','c'); +} + +entier main(void) { + test(); + return 0; +} diff --git a/res/test_read.tpc b/res/test_read.tpc deleted file mode 100644 index 6ad3632..0000000 --- a/res/test_read.tpc +++ /dev/null @@ -1,13 +0,0 @@ -/* test-table-symboles.tpc */ - -/* Test file for simplified translator of a declaration of variables in C */ -entier r1,b,s,c,r2 ; -caractere letter, digit, punct; - - -entier main(void) { - caractere r1; - readc(r1); - print(r1); - return 0; -} diff --git a/res/test_read_ok.tpc b/res/test_read_ok.tpc new file mode 100644 index 0000000..6ad3632 --- /dev/null +++ b/res/test_read_ok.tpc @@ -0,0 +1,13 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ +entier r1,b,s,c,r2 ; +caractere letter, digit, punct; + + +entier main(void) { + caractere r1; + readc(r1); + print(r1); + return 0; +} diff --git a/res/test_return.tpc b/res/test_return.tpc deleted file mode 100644 index f450203..0000000 --- a/res/test_return.tpc +++ /dev/null @@ -1,14 +0,0 @@ -/* test-table-symboles.tpc */ - -/* Test file for simplified translator of a declaration of variables in C */ -entier r1,b,s,c,r2 ; -caractere letter, digit, punct; - -caractere test(void){ -} - -entier main(void) { - letter = test(); - print(letter); - return 0; -} diff --git a/res/test_return_ok.tpc b/res/test_return_ok.tpc new file mode 100644 index 0000000..f450203 --- /dev/null +++ b/res/test_return_ok.tpc @@ -0,0 +1,14 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ +entier r1,b,s,c,r2 ; +caractere letter, digit, punct; + +caractere test(void){ +} + +entier main(void) { + letter = test(); + print(letter); + return 0; +} diff --git a/res/test_sample_ko.tpc b/res/test_sample_ko.tpc new file mode 100644 index 0000000..9dc344f --- /dev/null +++ b/res/test_sample_ko.tpc @@ -0,0 +1,24 @@ +/** + * UPEM / Compilation / Projet TPC + * Exemple de fichier source TPC invalide + * Pacien TRAN-GIRARD, Adam NAILI + */ + +const special = 'b'; + +caractere funky_func(entier arg) { + return !arg; +} + +void main(void) { + void ret; + ret = 1 + funky_func(0) * 2; + + while (ret) { + readc(ret); + print(ret); + + if (ret == special) print('!'); + } +} + diff --git a/res/test_sample_ok.tpc b/res/test_sample_ok.tpc new file mode 100644 index 0000000..c8d3d9d --- /dev/null +++ b/res/test_sample_ok.tpc @@ -0,0 +1,22 @@ +/** + * UPEM / Compilation / Projet TPC + * Exemple de fichier source TPC valide + * Pacien TRAN-GIRARD, Adam NAILI + */ + +const special = 'b'; + +entier funky_func(entier arg) { + return !arg; +} + +void main(void) { + entier ret; + ret = 1 + funky_func(0) * 2; + + while (1) { + reade(ret); + print(ret); + } +} + diff --git a/res/test_table_symbols_ok.tpc b/res/test_table_symbols_ok.tpc new file mode 100644 index 0000000..b2cc31e --- /dev/null +++ b/res/test_table_symbols_ok.tpc @@ -0,0 +1,14 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ +entier r1,b,s,c,r2 ; +caractere letter, digit, punct; + +entier main(void) { + + r1=12; + r2=24; + b=r1+r2; + punct='.'; + return b; +} diff --git a/res/test_while.tpc b/res/test_while.tpc deleted file mode 100644 index 25d04c6..0000000 --- a/res/test_while.tpc +++ /dev/null @@ -1,13 +0,0 @@ -/* test-table-symboles.tpc */ - -/* Test file for simplified translator of a declaration of variables in C */ - -entier main(void) { - entier i; - i = 0; - while(i<=5){ - print(i); - i = i + 1; - } - return 0; -} diff --git a/res/test_while_ok.tpc b/res/test_while_ok.tpc new file mode 100644 index 0000000..25d04c6 --- /dev/null +++ b/res/test_while_ok.tpc @@ -0,0 +1,13 @@ +/* test-table-symboles.tpc */ + +/* Test file for simplified translator of a declaration of variables in C */ + +entier main(void) { + entier i; + i = 0; + while(i<=5){ + print(i); + i = i + 1; + } + return 0; +} -- cgit v1.2.3