-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_err.sh
executable file
Β·174 lines (141 loc) Β· 2.83 KB
/
test_err.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh
OPT=$*
TARGET=bin/visket
try() {
expected="$1"
input="$2"
echo "$input" > tmp.sl
actual=`$TARGET $OPT -o tmp tmp.sl 2>&1 > /dev/null`
# 'error:' γεγι€γ
actual=${actual:7}
if [ "$actual" == "$expected" ]; then
echo "=> \"$actual\""
else
echo "=> \"$expected\" expected, but got \"$actual\""
exit 1
fi
}
#
try "tmp.sl:3 | type mismatch 'i32' and 'float'" \
"fun main() {
var a = 1
a = 1.0
}"
try "tmp.sl:2 | undefined function 'notFound'" \
"fun main() {
notFound()
}"
try "tmp.sl:2 | not enough arguments in call to 'test'" \
"fun main() {
test()
}
fun test(a: int) {}"
try "tmp.sl:2 | too many arguments in call to 'test'" \
"fun main() {
test(1, 1)
}
fun test(a: int) {}"
try "tmp.sl:2 | type mismatch 'float' and 'i32'" \
"fun main() {
test(1.0)
}
fun test(a: int) {}"
try "tmp.sl:2 | unresolved variable 'a'" \
"fun main() {
a
}"
try "tmp.sl:3 | cannot index 'i32'" \
"fun main() {
var a = 1
a[1]
}"
try "tmp.sl:2 | unexpected operator: float % float" \
"fun main() {
1.0 % 1.0
}"
try "tmp.sl:2 | unexpected operator: i32.1" \
"fun main() {
1 . 1
}"
try "tmp.sl:3 | unexpected operator: i32.A" \
"fun main() {
var a = 1
a.A
}"
try "tmp.sl:4 | unresolved member 'A'" \
"struct Foo { X: int }
fun main() {
var foo = new Foo
foo.A
}"
try "tmp.sl:2 | unknown type 'Hoge'" \
"fun main() {
var a = new Hoge
}"
try "tmp.sl:2 | missing return at end of function" \
"fun test(): int {
}"
try "tmp.sl:2 | already declared function 'test'" \
"fun test() {}
fun test() {}"
try "tmp.sl:2 | type mismatch 'void' and 'i32'" \
"fun test() {
return 1
}"
try "tmp.sl:2 | type mismatch 'i32' and 'float'" \
"fun test(): int {
return 1.0
}"
try "tmp.sl:3 | already declared variable 'a'" \
"fun main() {
var a = 1
var a = 1
}"
try "tmp.sl:2 | type mismatch 'i32' and 'float'" \
"fun main() {
var a: int = 1.0
}"
try "tmp.sl:1 | unknown type 'hoge'" \
"fun test(): hoge {
}"
try "tmp.sl:1 | illegal charactor '@'" \
"@"
try "tmp.sl:2 | type mismatch 'i32' and 'float'" \
"fun main() {
for i in 0..1.0 {}
}"
try "tmp.sl:3 | a ref value must be an assignable variable" \
"fun test(ref i: int){}
fun main() {
test(1)
}"
try "tmp.sl:4 | a ref value must be an assignable variable" \
"fun test(ref i: int){}
fun main() {
val i = 1
test(i)
}"
try "tmp.sl:1 | main func cannot have a return type" \
"fun main(): int {}"
try "tmp.sl:1 | main func cannot have parameters" \
"fun main(i: int) {}"
try "tmp.sl:3 | constant 'i' cannot be reassigned" \
"fun main() {
val i = 10
i = 1
}"
try "tmp.sl:2 | closing ' expected" \
"fun main() {
var c = 'hoge'
}"
try "tmp.sl:2 | invalid escape sequence" \
"fun main() {
var c = '\j'
}"
try "tmp.sl:4 | cannot load the member of incomplete structure: %Foo.A" \
"struct Foo
fun main() {
var foo: Foo
var a = foo.A
}"
echo "all tests passed"