mise à jour des tests
This commit is contained in:
10
tests/testSemanticError/test_decl_scope.vsl
Normal file
10
tests/testSemanticError/test_decl_scope.vsl
Normal file
@@ -0,0 +1,10 @@
|
||||
FUNC INT main() {
|
||||
{
|
||||
INT i
|
||||
i := 3
|
||||
PRINT i
|
||||
}
|
||||
PRINT i
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
11
tests/testSemanticError/test_decl_scope2.vsl
Normal file
11
tests/testSemanticError/test_decl_scope2.vsl
Normal file
@@ -0,0 +1,11 @@
|
||||
FUNC VOID f() {
|
||||
INT i
|
||||
i := 2
|
||||
}
|
||||
|
||||
FUNC INT main() {
|
||||
f()
|
||||
PRINT i
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
7
tests/testSemanticError/test_decl_scope3.vsl
Normal file
7
tests/testSemanticError/test_decl_scope3.vsl
Normal file
@@ -0,0 +1,7 @@
|
||||
PROTO VOID f(i)
|
||||
|
||||
FUNC INT main() {
|
||||
PRINT i
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
10
tests/testSemanticError/test_func_redecl.vsl
Normal file
10
tests/testSemanticError/test_func_redecl.vsl
Normal file
@@ -0,0 +1,10 @@
|
||||
FUNC INT main() {
|
||||
PRINT "a"
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC INT main() {
|
||||
PRINT "a"
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
12
tests/testSemanticError/test_incompat_proto.vsl
Normal file
12
tests/testSemanticError/test_incompat_proto.vsl
Normal file
@@ -0,0 +1,12 @@
|
||||
PROTO VOID fact()
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC VOID fact(i) {
|
||||
INT j
|
||||
j := i
|
||||
}
|
||||
|
||||
10
tests/testSemanticError/test_incompat_proto2.vsl
Normal file
10
tests/testSemanticError/test_incompat_proto2.vsl
Normal file
@@ -0,0 +1,10 @@
|
||||
PROTO VOID fact()
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC INT fact() {
|
||||
RETURN 1
|
||||
}
|
||||
11
tests/testSemanticError/test_incompat_proto3.vsl
Normal file
11
tests/testSemanticError/test_incompat_proto3.vsl
Normal file
@@ -0,0 +1,11 @@
|
||||
PROTO INT fact(t[], i)
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC INT fact(i, j) {
|
||||
RETURN i
|
||||
}
|
||||
|
||||
21
tests/testSemanticError/test_incompat_proto4.vsl
Normal file
21
tests/testSemanticError/test_incompat_proto4.vsl
Normal file
@@ -0,0 +1,21 @@
|
||||
PROTO VOID f(i, j, t[], m, k[])
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
INT t1[3]
|
||||
INT t2[2]
|
||||
i := 0
|
||||
j := 1
|
||||
t1[0] := 4
|
||||
t1[1] := 5
|
||||
t1[2] := 6
|
||||
t2[0] := 9
|
||||
t2[1] := 10
|
||||
f(i, j, t1, i, t2)
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC VOID f(i, j, t, m, k[]) {
|
||||
PRINT i
|
||||
}
|
||||
|
||||
21
tests/testSemanticError/test_incompat_proto5.vsl
Normal file
21
tests/testSemanticError/test_incompat_proto5.vsl
Normal file
@@ -0,0 +1,21 @@
|
||||
PROTO VOID f(i, j, t[], m, k[])
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
INT t1[3]
|
||||
INT t2[2]
|
||||
i := 0
|
||||
j := 1
|
||||
t1[0] := 4
|
||||
t1[1] := 5
|
||||
t1[2] := 6
|
||||
t2[0] := 9
|
||||
t2[1] := 10
|
||||
f(i, j, t1, i, t1)
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC VOID f(i, j, t[], k[], l[]) {
|
||||
PRINT i
|
||||
}
|
||||
|
||||
8
tests/testSemanticError/test_invalid_assign.vsl
Normal file
8
tests/testSemanticError/test_invalid_assign.vsl
Normal file
@@ -0,0 +1,8 @@
|
||||
FUNC INT main() {
|
||||
INT i
|
||||
INT t[2]
|
||||
i := 1
|
||||
t := i
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
9
tests/testSemanticError/test_invalid_assign2.vsl
Normal file
9
tests/testSemanticError/test_invalid_assign2.vsl
Normal file
@@ -0,0 +1,9 @@
|
||||
FUNC INT main() {
|
||||
INT i
|
||||
INT t[2]
|
||||
t[0] := 1
|
||||
t[1] := 2
|
||||
i := t
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
12
tests/testSemanticError/test_invalid_call.vsl
Normal file
12
tests/testSemanticError/test_invalid_call.vsl
Normal file
@@ -0,0 +1,12 @@
|
||||
FUNC VOID f(i) {
|
||||
INT j
|
||||
j := i
|
||||
}
|
||||
|
||||
FUNC INT main() {
|
||||
INT i
|
||||
i := 0
|
||||
i := f(i)
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
22
tests/testSemanticError/test_invalid_call2.vsl
Normal file
22
tests/testSemanticError/test_invalid_call2.vsl
Normal file
@@ -0,0 +1,22 @@
|
||||
PROTO VOID f(i, j, t[], m, k[])
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j, m
|
||||
INT t1[3]
|
||||
INT t2[2]
|
||||
i := 0
|
||||
j := 1
|
||||
t1[0] := 4
|
||||
t1[1] := 5
|
||||
t1[2] := 6
|
||||
t2[0] := 9
|
||||
t2[1] := 10
|
||||
m := 3
|
||||
f(i, j, t1, m, m)
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC VOID f(i, j, t[], m, k[]) {
|
||||
PRINT i
|
||||
}
|
||||
|
||||
21
tests/testSemanticError/test_invalid_call3.vsl
Normal file
21
tests/testSemanticError/test_invalid_call3.vsl
Normal file
@@ -0,0 +1,21 @@
|
||||
PROTO VOID f(i, j, t[], m, k[])
|
||||
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
INT t1[3]
|
||||
INT t2[2]
|
||||
i := 0
|
||||
j := 1
|
||||
t1[0] := 4
|
||||
t1[1] := 5
|
||||
t1[2] := 6
|
||||
t2[0] := 9
|
||||
t2[1] := 10
|
||||
f(i, j, t1, t2, t2)
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
FUNC VOID f(i, j, t[], m, k[]) {
|
||||
PRINT i
|
||||
}
|
||||
|
||||
10
tests/testSemanticError/test_invalid_recursion.vsl
Normal file
10
tests/testSemanticError/test_invalid_recursion.vsl
Normal file
@@ -0,0 +1,10 @@
|
||||
FUNC INT f(a) {
|
||||
IF a THEN RETURN 0
|
||||
ELSE RETURN f(a-1)
|
||||
FI
|
||||
}
|
||||
|
||||
FUNC INT main(){
|
||||
PRINT "La fonction f n est pas declaree avant sa premiere utilisation"
|
||||
RETURN f(5)
|
||||
}
|
||||
12
tests/testSemanticError/test_invalid_return.vsl
Normal file
12
tests/testSemanticError/test_invalid_return.vsl
Normal file
@@ -0,0 +1,12 @@
|
||||
FUNC INT f() {
|
||||
INT t[1]
|
||||
t[0] := 1
|
||||
RETURN t
|
||||
}
|
||||
|
||||
FUNC INT main() {
|
||||
INT i
|
||||
i := f()
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
6
tests/testSemanticError/test_undecl_func.vsl
Normal file
6
tests/testSemanticError/test_undecl_func.vsl
Normal file
@@ -0,0 +1,6 @@
|
||||
FUNC INT main() {
|
||||
INT i, j
|
||||
j := func()
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
6
tests/testSemanticError/test_undecl_var.vsl
Normal file
6
tests/testSemanticError/test_undecl_var.vsl
Normal file
@@ -0,0 +1,6 @@
|
||||
FUNC INT main() {
|
||||
INT i
|
||||
j := i
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
8
tests/testSemanticError/test_var_redecl.vsl
Normal file
8
tests/testSemanticError/test_var_redecl.vsl
Normal file
@@ -0,0 +1,8 @@
|
||||
FUNC INT main() {
|
||||
INT i
|
||||
INT i
|
||||
i := 1
|
||||
PRINT i
|
||||
RETURN 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user