diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-03-10 23:22:10 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-03-10 23:22:10 +0000 |
commit | 8638f32c4624d8d7b225eaf43333ba926c5acaf0 (patch) | |
tree | 39b610dfe9ad898304aea3547f816197ab69df60 | |
parent | 733e278a3c20988cfe1ae386fe057945a805bbb3 (diff) | |
download | Compiler-8638f32c4624d8d7b225eaf43333ba926c5acaf0.tar.gz Compiler-8638f32c4624d8d7b225eaf43333ba926c5acaf0.zip |
Fixing tests
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | c_parser/test/in/08.c | 6 | ||||
-rw-r--r-- | c_parser/test/in/09.c | 8 | ||||
-rw-r--r-- | c_parser/test/ref/01.stdout.xml | 9 | ||||
-rw-r--r-- | c_parser/test/ref/02.stdout.xml | 6 | ||||
-rw-r--r-- | c_parser/test/ref/03.stdout.xml | 7 | ||||
-rw-r--r-- | c_parser/test/ref/04.stdout.xml | 12 | ||||
-rw-r--r-- | c_parser/test/ref/05.stdout.xml | 10 | ||||
-rw-r--r-- | c_parser/test/ref/06.stdout.xml | 14 | ||||
-rw-r--r-- | c_parser/test/ref/07.stdout.xml | 11 | ||||
-rw-r--r-- | c_parser/test/ref/08.stdout.xml | 16 | ||||
-rw-r--r-- | c_parser/test/ref/09.stdout.xml | 20 | ||||
-rw-r--r-- | c_parser/test/ref/10.stdout.xml | 19 | ||||
-rw-r--r-- | c_parser/test/ref/11.stdout.xml | 11 | ||||
-rw-r--r-- | c_parser/test/ref/12.stdout.xml | 10 | ||||
-rw-r--r-- | c_parser/test/ref/13.stdout.xml | 13 | ||||
-rw-r--r-- | c_parser/test/ref/14.stdout.xml | 13 | ||||
-rw-r--r-- | c_parser/test/ref/15.stdout.xml | 32 | ||||
-rwxr-xr-x | test_parser.sh | 2 |
19 files changed, 212 insertions, 8 deletions
@@ -7,7 +7,6 @@ build/ bin/ -ref/ out/ # ignore all files with these extensions diff --git a/c_parser/test/in/08.c b/c_parser/test/in/08.c index c57a6ab..dfac1e5 100644 --- a/c_parser/test/in/08.c +++ b/c_parser/test/in/08.c @@ -1,10 +1,10 @@ int func(int a, int b) { int c = 0; if(a == b) { - int d; + int d; } else if(a == d) { - int e; - return d; + int e; + return d; } return c; } diff --git a/c_parser/test/in/09.c b/c_parser/test/in/09.c index ae86bb1..950ae7c 100644 --- a/c_parser/test/in/09.c +++ b/c_parser/test/in/09.c @@ -6,10 +6,10 @@ int g; int zz(int a, int b, int c) { if(a==b){ - int a; - return a; + int a; + return a; }else{ - int fsdfsdfs; - return c; + int fsdfsdfs; + return c; } } diff --git a/c_parser/test/ref/01.stdout.xml b/c_parser/test/ref/01.stdout.xml new file mode 100644 index 0000000..e0545e4 --- /dev/null +++ b/c_parser/test/ref/01.stdout.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<Program> + <Variable id="a" /> + <Variable id="b" /> + <Variable id="c" /> + <Variable id="d" /> + <Variable id="e" /> + <Variable id="f" /> +</Program> diff --git a/c_parser/test/ref/02.stdout.xml b/c_parser/test/ref/02.stdout.xml new file mode 100644 index 0000000..1f73bca --- /dev/null +++ b/c_parser/test/ref/02.stdout.xml @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<Program> + <Function id="f"> + <Scope></Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/03.stdout.xml b/c_parser/test/ref/03.stdout.xml new file mode 100644 index 0000000..6ab6ab3 --- /dev/null +++ b/c_parser/test/ref/03.stdout.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<Program> + <Function id="foo"> + <Parameter id="bar" /> + <Scope></Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/04.stdout.xml b/c_parser/test/ref/04.stdout.xml new file mode 100644 index 0000000..caae53b --- /dev/null +++ b/c_parser/test/ref/04.stdout.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<Program> + <Function id="foo"> + <Parameter id="bar1" /> + <Parameter id="bar2" /> + <Scope> + <Variable id="x" /> + <Variable id="y" /> + <Variable id="z" /> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/05.stdout.xml b/c_parser/test/ref/05.stdout.xml new file mode 100644 index 0000000..944d950 --- /dev/null +++ b/c_parser/test/ref/05.stdout.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<Program> + <Function id="foo"> + <Parameter id="x" /> + <Parameter id="y" /> + <Scope> + <Scope></Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/06.stdout.xml b/c_parser/test/ref/06.stdout.xml new file mode 100644 index 0000000..6422001 --- /dev/null +++ b/c_parser/test/ref/06.stdout.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<Program> + <Function id="f"> + <Parameter id="a" /> + <Parameter id="b" /> + <Parameter id="c" /> + <Scope> + <Variable id="d" /> + <Scope> + <Variable id="e" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/07.stdout.xml b/c_parser/test/ref/07.stdout.xml new file mode 100644 index 0000000..11c3b77 --- /dev/null +++ b/c_parser/test/ref/07.stdout.xml @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<Program> + <Function id="foo"> + <Parameter id="a" /> + <Scope> + <Scope> + <Variable id="z" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/08.stdout.xml b/c_parser/test/ref/08.stdout.xml new file mode 100644 index 0000000..6cf0f8e --- /dev/null +++ b/c_parser/test/ref/08.stdout.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<Program> + <Function id="func"> + <Parameter id="a" /> + <Parameter id="b" /> + <Scope> + <Variable id="c" /> + <Scope> + <Variable id="d" /> + </Scope> + <Scope> + <Variable id="e" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/09.stdout.xml b/c_parser/test/ref/09.stdout.xml new file mode 100644 index 0000000..6c137df --- /dev/null +++ b/c_parser/test/ref/09.stdout.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<Program> + <Function id="x"> + <Scope></Scope> + </Function> + <Variable id="g" /> + <Function id="zz"> + <Parameter id="a" /> + <Parameter id="b" /> + <Parameter id="c" /> + <Scope> + <Scope> + <Variable id="a" /> + </Scope> + <Scope> + <Variable id="fsdfsdfs" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/10.stdout.xml b/c_parser/test/ref/10.stdout.xml new file mode 100644 index 0000000..89a6292 --- /dev/null +++ b/c_parser/test/ref/10.stdout.xml @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<Program> + <Function id="f"> + <Scope></Scope> + </Function> + <Variable id="g" /> + <Function id="x"> + <Parameter id="y" /> + <Scope> + <Variable id="z" /> + <Scope> + <Variable id="r" /> + </Scope> + <Scope> + <Variable id="f" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/11.stdout.xml b/c_parser/test/ref/11.stdout.xml new file mode 100644 index 0000000..b9779d7 --- /dev/null +++ b/c_parser/test/ref/11.stdout.xml @@ -0,0 +1,11 @@ +<?xml version="1.0"?> +<Program> + <Function id="f"> + <Scope> + <Variable id="x" /> + <Scope> + <Variable id="y" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/12.stdout.xml b/c_parser/test/ref/12.stdout.xml new file mode 100644 index 0000000..9f49265 --- /dev/null +++ b/c_parser/test/ref/12.stdout.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<Program> + <Function id="f"> + <Parameter id="b" /> + <Parameter id="c" /> + <Scope> + <Variable id="a" /> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/13.stdout.xml b/c_parser/test/ref/13.stdout.xml new file mode 100644 index 0000000..a604ecd --- /dev/null +++ b/c_parser/test/ref/13.stdout.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<Program> + <Function id="func"> + <Parameter id="x" /> + <Parameter id="y" /> + <Scope> + <Variable id="i" /> + <Scope> + <Variable id="z" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/14.stdout.xml b/c_parser/test/ref/14.stdout.xml new file mode 100644 index 0000000..866d44e --- /dev/null +++ b/c_parser/test/ref/14.stdout.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<Program> + <Function id="function_1"> + <Parameter id="a" /> + <Parameter id="b" /> + <Scope> + <Variable id="x" /> + <Scope> + <Variable id="c" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/c_parser/test/ref/15.stdout.xml b/c_parser/test/ref/15.stdout.xml new file mode 100644 index 0000000..b06dde0 --- /dev/null +++ b/c_parser/test/ref/15.stdout.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<Program> + <Function id="add"> + <Parameter id="a" /> + <Parameter id="b" /> + <Scope> + <Variable id="c" /> + </Scope> + </Function> + <Function id="sub"> + <Parameter id="a" /> + <Parameter id="b" /> + <Scope> + <Variable id="c" /> + </Scope> + </Function> + <Function id="mult_by_5"> + <Parameter id="a" /> + <Scope> + <Variable id="b" /> + </Scope> + </Function> + <Function id="add_5"> + <Parameter id="a" /> + <Scope> + <Variable id="i" /> + <Scope> + <Variable id="b" /> + </Scope> + </Scope> + </Function> +</Program> diff --git a/test_parser.sh b/test_parser.sh index 3e56054..1bf6a44 100755 --- a/test_parser.sh +++ b/test_parser.sh @@ -20,6 +20,8 @@ echo " Testing parser" PASSED=0 CHECKED=0 +mkdir -p c_parser/test/out + for i in c_parser/test/in/*.c; do echo "===========================" echo "" |