From 87356531ffaf350398b9c03c9eca6a28f98ea6cf Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 14 Dec 2022 00:31:05 +0100 Subject: [PATCH] add some tests --- tests/23_fn-name-mips-instr.test | 2 ++ tests/28_rec.test | 11 +++++++++++ tests/29_if-int.test | 6 ++++++ tests/30_else-empty.test | 7 +++++++ tests/31_return.test | 8 ++++++++ tests/32_while-int.test | 6 ++++++ 6 files changed, 40 insertions(+) create mode 100644 tests/28_rec.test create mode 100644 tests/29_if-int.test create mode 100644 tests/30_else-empty.test create mode 100644 tests/31_return.test create mode 100644 tests/32_while-int.test diff --git a/tests/23_fn-name-mips-instr.test b/tests/23_fn-name-mips-instr.test index 190ef18..7397add 100644 --- a/tests/23_fn-name-mips-instr.test +++ b/tests/23_fn-name-mips-instr.test @@ -1,4 +1,6 @@ int add (int a, int b) { + # Alors que "add" est le nom d'une instruction + # MIPS, ça ne pose aucun problème return a + b; } diff --git a/tests/28_rec.test b/tests/28_rec.test new file mode 100644 index 0000000..6782b09 --- /dev/null +++ b/tests/28_rec.test @@ -0,0 +1,11 @@ +void recursive (int n) { + if (n > 0) { + puti(n); + puts("\n"); + recursive (n - 1); + } +} + +void main () { + recursive(5); +} diff --git a/tests/29_if-int.test b/tests/29_if-int.test new file mode 100644 index 0000000..a1ef6a3 --- /dev/null +++ b/tests/29_if-int.test @@ -0,0 +1,6 @@ +void main () { + if (1) { # Error on line 2 col 8: Expected bool but given int. + # Requiert le type bool, pas de convertion implicite + return; + } +} diff --git a/tests/30_else-empty.test b/tests/30_else-empty.test new file mode 100644 index 0000000..24a4f74 --- /dev/null +++ b/tests/30_else-empty.test @@ -0,0 +1,7 @@ +void main () { + if (false) { + puts("ANTOINE DANIEL\n"); + } else { + + } +} diff --git a/tests/31_return.test b/tests/31_return.test new file mode 100644 index 0000000..8f1dcd1 --- /dev/null +++ b/tests/31_return.test @@ -0,0 +1,8 @@ +void main () { + puti(1312); + puts("\n"); + return; + + # Ce message ne s'affichera pas + puts(":)\n"); +} diff --git a/tests/32_while-int.test b/tests/32_while-int.test new file mode 100644 index 0000000..acde393 --- /dev/null +++ b/tests/32_while-int.test @@ -0,0 +1,6 @@ +void main () { + while (1) { # Error on line 2 col 11: Expected bool but given int. + # Requiert le type bool, pas de convertion implicite + return; + } +}