diff options
Diffstat (limited to 'tiger-compiler/tests/bind')
| -rw-r--r-- | tiger-compiler/tests/bind/break-outside-loop.tig | 2 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/compare_to_break.tig | 2 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/invalid-function-redefinition-1.tig | 11 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/invalid-type-redefinition.tig | 10 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/scoped_main.tig | 6 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/set_to_break.tig | 2 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/simple_sequence_int.tig | 6 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/simple_sequence_void.tig | 1 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/test17.tig | 12 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/test18.tig | 15 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/test19.tig | 13 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/tome.tig | 7 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/undeclared-variable.tig | 5 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/unknown-field-type.tig | 5 | ||||
| -rw-r--r-- | tiger-compiler/tests/bind/unknown-record.tig | 6 |
15 files changed, 103 insertions, 0 deletions
diff --git a/tiger-compiler/tests/bind/break-outside-loop.tig b/tiger-compiler/tests/bind/break-outside-loop.tig new file mode 100644 index 0000000..0fb24a5 --- /dev/null +++ b/tiger-compiler/tests/bind/break-outside-loop.tig @@ -0,0 +1,2 @@ +/* error: break out of a loop. */ +if 1 then break diff --git a/tiger-compiler/tests/bind/compare_to_break.tig b/tiger-compiler/tests/bind/compare_to_break.tig new file mode 100644 index 0000000..e917f6f --- /dev/null +++ b/tiger-compiler/tests/bind/compare_to_break.tig @@ -0,0 +1,2 @@ +/* Break cannot be used in comparaisons, especially at the left side */ +() = break diff --git a/tiger-compiler/tests/bind/invalid-function-redefinition-1.tig b/tiger-compiler/tests/bind/invalid-function-redefinition-1.tig new file mode 100644 index 0000000..aa50eaf --- /dev/null +++ b/tiger-compiler/tests/bind/invalid-function-redefinition-1.tig @@ -0,0 +1,11 @@ +/* public. */ + +/* This is invalid, since there are two functions with the same name + in the same (consecutive) batch of mutually recursive functions. + See also test48 */ +let + function g(a : int) : int = a + function g(a : int) : int = a +in + 0 +end diff --git a/tiger-compiler/tests/bind/invalid-type-redefinition.tig b/tiger-compiler/tests/bind/invalid-type-redefinition.tig new file mode 100644 index 0000000..cfe9496 --- /dev/null +++ b/tiger-compiler/tests/bind/invalid-type-redefinition.tig @@ -0,0 +1,10 @@ +/* public. */ +/* This is invalid, since there are two types with the same name + in the same (consecutive) batch of mutually recursive types. + See also shadowing-types-separate */ +let + type a = int + type a = string +in + 0 +end diff --git a/tiger-compiler/tests/bind/scoped_main.tig b/tiger-compiler/tests/bind/scoped_main.tig new file mode 100644 index 0000000..f97af75 --- /dev/null +++ b/tiger-compiler/tests/bind/scoped_main.tig @@ -0,0 +1,6 @@ +function seq():int = +let + function _main(a : a) : a = 8 +in + _main +end
\ No newline at end of file diff --git a/tiger-compiler/tests/bind/set_to_break.tig b/tiger-compiler/tests/bind/set_to_break.tig new file mode 100644 index 0000000..cf981ee --- /dev/null +++ b/tiger-compiler/tests/bind/set_to_break.tig @@ -0,0 +1,2 @@ +/* Break cannot be used in assignments */ +var void := break diff --git a/tiger-compiler/tests/bind/simple_sequence_int.tig b/tiger-compiler/tests/bind/simple_sequence_int.tig new file mode 100644 index 0000000..34e7757 --- /dev/null +++ b/tiger-compiler/tests/bind/simple_sequence_int.tig @@ -0,0 +1,6 @@ + + function seq(): int = ( + 1; + 2; + 3 + )
\ No newline at end of file diff --git a/tiger-compiler/tests/bind/simple_sequence_void.tig b/tiger-compiler/tests/bind/simple_sequence_void.tig new file mode 100644 index 0000000..1e76b0a --- /dev/null +++ b/tiger-compiler/tests/bind/simple_sequence_void.tig @@ -0,0 +1 @@ +function seq() = ()
\ No newline at end of file diff --git a/tiger-compiler/tests/bind/test17.tig b/tiger-compiler/tests/bind/test17.tig new file mode 100644 index 0000000..42c29ce --- /dev/null +++ b/tiger-compiler/tests/bind/test17.tig @@ -0,0 +1,12 @@ +/* error : definition of recursive types is interrupted */ +let + /* define a tree */ + type tree = {key : int, children : treelist} + + var d : int :=0 + + type treelist = {hd : tree, tl : treelist} + +in + d +end diff --git a/tiger-compiler/tests/bind/test18.tig b/tiger-compiler/tests/bind/test18.tig new file mode 100644 index 0000000..7592df5 --- /dev/null +++ b/tiger-compiler/tests/bind/test18.tig @@ -0,0 +1,15 @@ +/* error : definition of recursive functions is interrupted */ +let + +function do_nothing1(a : int, b : string) : int= + (do_nothing2 (a+1);0) + +var d :=0 + +function do_nothing2(d : int) : string = + (do_nothing1 (d, "str");" ") + +in + do_nothing1(0, "str2") +end + diff --git a/tiger-compiler/tests/bind/test19.tig b/tiger-compiler/tests/bind/test19.tig new file mode 100644 index 0000000..662ed35 --- /dev/null +++ b/tiger-compiler/tests/bind/test19.tig @@ -0,0 +1,13 @@ +/* error : second function uses variables local to the first one, undeclared variable */ +let + +function do_nothing1(a : int, b : string) : int= + (do_nothing2 (a+1);0) + +function do_nothing2(d : int) : string = + (do_nothing1 (a, "str");" ") + +in + do_nothing1(0, "str2") +end + diff --git a/tiger-compiler/tests/bind/tome.tig b/tiger-compiler/tests/bind/tome.tig new file mode 100644 index 0000000..e9fa3d6 --- /dev/null +++ b/tiger-compiler/tests/bind/tome.tig @@ -0,0 +1,7 @@ +let + type me = {} + type me = {} + function twice(a: int, a: int) : int = a + a +in + me {} = me {} +end
\ No newline at end of file diff --git a/tiger-compiler/tests/bind/undeclared-variable.tig b/tiger-compiler/tests/bind/undeclared-variable.tig new file mode 100644 index 0000000..9dfa905 --- /dev/null +++ b/tiger-compiler/tests/bind/undeclared-variable.tig @@ -0,0 +1,5 @@ +/* public. */ + +/* error : undeclared variable i */ + +while 10 > 5 do (i+1; ()) diff --git a/tiger-compiler/tests/bind/unknown-field-type.tig b/tiger-compiler/tests/bind/unknown-field-type.tig new file mode 100644 index 0000000..cf21308 --- /dev/null +++ b/tiger-compiler/tests/bind/unknown-field-type.tig @@ -0,0 +1,5 @@ +let + type rec = { a : unknown } +in + rec { a = 42 } +end
\ No newline at end of file diff --git a/tiger-compiler/tests/bind/unknown-record.tig b/tiger-compiler/tests/bind/unknown-record.tig new file mode 100644 index 0000000..87e85b5 --- /dev/null +++ b/tiger-compiler/tests/bind/unknown-record.tig @@ -0,0 +1,6 @@ +/* error : unknown type */ +let + var a := rectype { foo = 0 } +in + 0 +end |
