summaryrefslogtreecommitdiff
path: root/ecomp-c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2020-01-30 19:56:33 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2020-01-30 19:56:33 +0100
commita4595f5a03ddd0b8d6b08b98f58fb0785b961ff3 (patch)
treef86c598d3a7e147bf2e551ee7308260686177f53 /ecomp-c
parent99ef28b45012765a0bfe078db0568ba48f87969f (diff)
downloadcompilertests-a4595f5a03ddd0b8d6b08b98f58fb0785b961ff3.tar.gz
compilertests-a4595f5a03ddd0b8d6b08b98f58fb0785b961ff3.tar.bz2
more testing
Diffstat (limited to 'ecomp-c')
-rw-r--r--ecomp-c/test1.e10
-rw-r--r--ecomp-c/tests/duplicate_variable.e4
-rw-r--r--ecomp-c/tests/empty_module.e4
-rwxr-xr-xecomp-c/tests/run_tests.sh1
-rw-r--r--ecomp-c/tests/unknown_type.e2
-rw-r--r--ecomp-c/tests/unknown_type.eerr2
-rw-r--r--ecomp-c/tests/variable_name_as_type.e10
-rw-r--r--ecomp-c/tests/variable_name_as_type.eerr2
-rw-r--r--ecomp-c/tests/variable_name_as_type.eout1
9 files changed, 24 insertions, 12 deletions
diff --git a/ecomp-c/test1.e b/ecomp-c/test1.e
index 315627a..41bb9d1 100644
--- a/ecomp-c/test1.e
+++ b/ecomp-c/test1.e
@@ -5,16 +5,16 @@ module test1;
const
// integer constant
-// N : integer = 20;
+ N : integer = 20;
var
// this is an integer
-// a : integer;
+ a : integer;
// this is also an integer
-// b : integer;
-// c : integer; // c too
-
+ b : integer;
+ c : integer; // c too
+
begin
a := 1;
b := 7;
diff --git a/ecomp-c/tests/duplicate_variable.e b/ecomp-c/tests/duplicate_variable.e
index 49a4554..ef8536a 100644
--- a/ecomp-c/tests/duplicate_variable.e
+++ b/ecomp-c/tests/duplicate_variable.e
@@ -1,9 +1,7 @@
module duplicate_variable;
var
- a : integer = 7;
-
-var
+ a : integer;
a : integer; // must croak about redefining a const as a variable
begin
diff --git a/ecomp-c/tests/empty_module.e b/ecomp-c/tests/empty_module.e
index 42261e3..914ccb3 100644
--- a/ecomp-c/tests/empty_module.e
+++ b/ecomp-c/tests/empty_module.e
@@ -1,8 +1,8 @@
/*
- * empty module
+ * empty module, testing also comments
*/
-module empty_module;
+module empty_module; // this is also possible
begin
end
diff --git a/ecomp-c/tests/run_tests.sh b/ecomp-c/tests/run_tests.sh
index 03e828c..2607241 100755
--- a/ecomp-c/tests/run_tests.sh
+++ b/ecomp-c/tests/run_tests.sh
@@ -3,6 +3,7 @@
TESTS="
empty_module
unknown_variable
+variable_name_as_type
unknown_type
const_assignment_error
"
diff --git a/ecomp-c/tests/unknown_type.e b/ecomp-c/tests/unknown_type.e
index 16b23a3..240d03e 100644
--- a/ecomp-c/tests/unknown_type.e
+++ b/ecomp-c/tests/unknown_type.e
@@ -1,7 +1,7 @@
module unknown_type;
var
- a : flabla; // must warn here about a unknown type
+ a : bigint23; // must warn here about a unknown type
begin
a := 1;
diff --git a/ecomp-c/tests/unknown_type.eerr b/ecomp-c/tests/unknown_type.eerr
index 8a1de4c..3998ce1 100644
--- a/ecomp-c/tests/unknown_type.eerr
+++ b/ecomp-c/tests/unknown_type.eerr
@@ -1,2 +1,2 @@
-Error line 4, pos 13: Unknown type 'flabla'
+Error line 4, pos 15: Unknown type 'bigint23'
diff --git a/ecomp-c/tests/variable_name_as_type.e b/ecomp-c/tests/variable_name_as_type.e
new file mode 100644
index 0000000..ef59201
--- /dev/null
+++ b/ecomp-c/tests/variable_name_as_type.e
@@ -0,0 +1,10 @@
+module variable_name_as_type;
+
+var
+ a : integer;
+ // type as variable, must fail
+ b : a;
+
+begin
+ a := 1;
+end
diff --git a/ecomp-c/tests/variable_name_as_type.eerr b/ecomp-c/tests/variable_name_as_type.eerr
new file mode 100644
index 0000000..aab4eff
--- /dev/null
+++ b/ecomp-c/tests/variable_name_as_type.eerr
@@ -0,0 +1,2 @@
+Error line 6, pos 8: 'a' is defined, but is not a type as expected
+
diff --git a/ecomp-c/tests/variable_name_as_type.eout b/ecomp-c/tests/variable_name_as_type.eout
new file mode 100644
index 0000000..91f6ecc
--- /dev/null
+++ b/ecomp-c/tests/variable_name_as_type.eout
@@ -0,0 +1 @@
+DECL a -> integer