From d3c6f8265dde0a1b82110d643f5fa5538f0f1a16 Mon Sep 17 00:00:00 2001
From: Pierre Wilke <pierre.wilke@centralesupelec.fr>
Date: Wed, 25 Mar 2020 13:39:52 +0100
Subject: [PATCH] tests pointeurs

---
 tests/ptr/ptr.e                      |  8 +++++
 tests/ptr/ptr.e.expect_14_12_3_8_12  |  1 +
 tests/ptr/ptr.e.expect_1_2_3         |  1 +
 tests/ptr/ptr.e.expect_lexer         | 52 ++++++++++++++++++++++++++++
 tests/ptr/ptr2.e                     |  7 ++++
 tests/ptr/ptr2.e.expect_14_12_3_8_12 |  1 +
 tests/ptr/ptr2.e.expect_1_2_3        |  1 +
 tests/ptr/ptr2.e.expect_lexer        | 36 +++++++++++++++++++
 8 files changed, 107 insertions(+)
 create mode 100644 tests/ptr/ptr.e
 create mode 100644 tests/ptr/ptr.e.expect_14_12_3_8_12
 create mode 100644 tests/ptr/ptr.e.expect_1_2_3
 create mode 100644 tests/ptr/ptr.e.expect_lexer
 create mode 100644 tests/ptr/ptr2.e
 create mode 100644 tests/ptr/ptr2.e.expect_14_12_3_8_12
 create mode 100644 tests/ptr/ptr2.e.expect_1_2_3
 create mode 100644 tests/ptr/ptr2.e.expect_lexer

diff --git a/tests/ptr/ptr.e b/tests/ptr/ptr.e
new file mode 100644
index 0000000..d998f28
--- /dev/null
+++ b/tests/ptr/ptr.e
@@ -0,0 +1,8 @@
+void f(int* z, int x, int y){
+  *z = x + y;
+}
+int main(int x, int y){
+  int z = 3;
+  f(&z, x, y);
+  return z;
+}
diff --git a/tests/ptr/ptr.e.expect_14_12_3_8_12 b/tests/ptr/ptr.e.expect_14_12_3_8_12
new file mode 100644
index 0000000..91317f7
--- /dev/null
+++ b/tests/ptr/ptr.e.expect_14_12_3_8_12
@@ -0,0 +1 @@
+{"output": "", "error": null, "retval": 26}
\ No newline at end of file
diff --git a/tests/ptr/ptr.e.expect_1_2_3 b/tests/ptr/ptr.e.expect_1_2_3
new file mode 100644
index 0000000..ff173ec
--- /dev/null
+++ b/tests/ptr/ptr.e.expect_1_2_3
@@ -0,0 +1 @@
+{"output": "", "error": null, "retval": 3}
\ No newline at end of file
diff --git a/tests/ptr/ptr.e.expect_lexer b/tests/ptr/ptr.e.expect_lexer
new file mode 100644
index 0000000..dc2a41e
--- /dev/null
+++ b/tests/ptr/ptr.e.expect_lexer
@@ -0,0 +1,52 @@
+SYM_VOID
+SYM_IDENTIFIER(f)
+SYM_LPARENTHESIS
+SYM_INT
+SYM_ASTERISK
+SYM_IDENTIFIER(z)
+SYM_COMMA
+SYM_INT
+SYM_IDENTIFIER(x)
+SYM_COMMA
+SYM_INT
+SYM_IDENTIFIER(y)
+SYM_RPARENTHESIS
+SYM_LBRACE
+SYM_ASTERISK
+SYM_IDENTIFIER(z)
+SYM_ASSIGN
+SYM_IDENTIFIER(x)
+SYM_PLUS
+SYM_IDENTIFIER(y)
+SYM_SEMICOLON
+SYM_RBRACE
+SYM_INT
+SYM_IDENTIFIER(main)
+SYM_LPARENTHESIS
+SYM_INT
+SYM_IDENTIFIER(x)
+SYM_COMMA
+SYM_INT
+SYM_IDENTIFIER(y)
+SYM_RPARENTHESIS
+SYM_LBRACE
+SYM_INT
+SYM_IDENTIFIER(z)
+SYM_ASSIGN
+SYM_INTEGER(3)
+SYM_SEMICOLON
+SYM_IDENTIFIER(f)
+SYM_LPARENTHESIS
+SYM_AMPERSAND
+SYM_IDENTIFIER(z)
+SYM_COMMA
+SYM_IDENTIFIER(x)
+SYM_COMMA
+SYM_IDENTIFIER(y)
+SYM_RPARENTHESIS
+SYM_SEMICOLON
+SYM_RETURN
+SYM_IDENTIFIER(z)
+SYM_SEMICOLON
+SYM_RBRACE
+SYM_EOF
diff --git a/tests/ptr/ptr2.e b/tests/ptr/ptr2.e
new file mode 100644
index 0000000..dd2921e
--- /dev/null
+++ b/tests/ptr/ptr2.e
@@ -0,0 +1,7 @@
+int main(){
+  int x = 0;
+  int *y = &x;
+  int** z = &y;
+  **z = 3;
+  return x;
+}
diff --git a/tests/ptr/ptr2.e.expect_14_12_3_8_12 b/tests/ptr/ptr2.e.expect_14_12_3_8_12
new file mode 100644
index 0000000..ff173ec
--- /dev/null
+++ b/tests/ptr/ptr2.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/ptr/ptr2.e.expect_1_2_3 b/tests/ptr/ptr2.e.expect_1_2_3
new file mode 100644
index 0000000..ff173ec
--- /dev/null
+++ b/tests/ptr/ptr2.e.expect_1_2_3
@@ -0,0 +1 @@
+{"output": "", "error": null, "retval": 3}
\ No newline at end of file
diff --git a/tests/ptr/ptr2.e.expect_lexer b/tests/ptr/ptr2.e.expect_lexer
new file mode 100644
index 0000000..a68606b
--- /dev/null
+++ b/tests/ptr/ptr2.e.expect_lexer
@@ -0,0 +1,36 @@
+SYM_INT
+SYM_IDENTIFIER(main)
+SYM_LPARENTHESIS
+SYM_RPARENTHESIS
+SYM_LBRACE
+SYM_INT
+SYM_IDENTIFIER(x)
+SYM_ASSIGN
+SYM_INTEGER(0)
+SYM_SEMICOLON
+SYM_INT
+SYM_ASTERISK
+SYM_IDENTIFIER(y)
+SYM_ASSIGN
+SYM_AMPERSAND
+SYM_IDENTIFIER(x)
+SYM_SEMICOLON
+SYM_INT
+SYM_ASTERISK
+SYM_ASTERISK
+SYM_IDENTIFIER(z)
+SYM_ASSIGN
+SYM_AMPERSAND
+SYM_IDENTIFIER(y)
+SYM_SEMICOLON
+SYM_ASTERISK
+SYM_ASTERISK
+SYM_IDENTIFIER(z)
+SYM_ASSIGN
+SYM_INTEGER(3)
+SYM_SEMICOLON
+SYM_RETURN
+SYM_IDENTIFIER(x)
+SYM_SEMICOLON
+SYM_RBRACE
+SYM_EOF
-- 
GitLab