Simplified compilation of function calls
This commit is contained in:
3
tests/errors/MissingBlockStart2.q
Normal file
3
tests/errors/MissingBlockStart2.q
Normal file
@ -0,0 +1,3 @@
|
||||
main() {
|
||||
loop
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
main() {
|
||||
x := 1 + f(x)
|
||||
}
|
3
tests/errors/UnknownIdentifier5.q
Normal file
3
tests/errors/UnknownIdentifier5.q
Normal file
@ -0,0 +1,3 @@
|
||||
main() {
|
||||
x := 1 + unknown(x)
|
||||
}
|
@ -39,6 +39,7 @@ var errs = []struct {
|
||||
{"MissingBlockEnd.q", errors.MissingBlockEnd},
|
||||
{"MissingBlockEnd2.q", errors.MissingBlockEnd},
|
||||
{"MissingBlockStart.q", errors.MissingBlockStart},
|
||||
{"MissingBlockStart2.q", errors.MissingBlockStart},
|
||||
{"MissingExpression.q", errors.MissingExpression},
|
||||
{"MissingGroupEnd.q", errors.MissingGroupEnd},
|
||||
{"MissingGroupStart.q", errors.MissingGroupStart},
|
||||
@ -52,11 +53,11 @@ var errs = []struct {
|
||||
{"ReturnCountMismatch.q", &errors.ReturnCountMismatch{Count: 1, ExpectedCount: 0}},
|
||||
{"TypeMismatch.q", &errors.TypeMismatch{Expected: "*any", Encountered: "int", ParameterName: "p"}},
|
||||
{"TypeMismatch2.q", &errors.TypeMismatch{Expected: "[]any", Encountered: "int", ParameterName: "array"}},
|
||||
{"UnknownFunction.q", &errors.UnknownFunction{Name: "unknown"}},
|
||||
{"UnknownFunction2.q", &errors.UnknownFunction{Name: "f"}},
|
||||
{"UnknownIdentifier.q", &errors.UnknownIdentifier{Name: "x"}},
|
||||
{"UnknownIdentifier2.q", &errors.UnknownIdentifier{Name: "x"}},
|
||||
{"UnknownIdentifier3.q", &errors.UnknownIdentifier{Name: "x"}},
|
||||
{"UnknownIdentifier4.q", &errors.UnknownIdentifier{Name: "unknown"}},
|
||||
{"UnknownIdentifier5.q", &errors.UnknownIdentifier{Name: "unknown"}},
|
||||
{"UnknownPackage.q", &errors.UnknownPackage{Name: "sys"}},
|
||||
{"UnknownType.q", &errors.UnknownType{Name: "unknown"}},
|
||||
{"UnknownType2.q", &errors.UnknownType{Name: "unknown"}},
|
||||
|
11
tests/programs/function-pointer-field.q
Normal file
11
tests/programs/function-pointer-field.q
Normal file
@ -0,0 +1,11 @@
|
||||
import core
|
||||
|
||||
struct Struct {
|
||||
func *any
|
||||
}
|
||||
|
||||
main() {
|
||||
s := new(Struct)
|
||||
s.func = core.exit
|
||||
s.func()
|
||||
}
|
21
tests/programs/loop-in-loop.q
Normal file
21
tests/programs/loop-in-loop.q
Normal file
@ -0,0 +1,21 @@
|
||||
import sys
|
||||
|
||||
main() {
|
||||
x := 0
|
||||
|
||||
loop {
|
||||
for 0..10 {
|
||||
x += 1
|
||||
}
|
||||
|
||||
assert x == 10
|
||||
|
||||
loop {
|
||||
x -= 1
|
||||
|
||||
if x == 0 {
|
||||
sys.exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -58,8 +58,9 @@ var programs = []struct {
|
||||
{"branch-save", 0},
|
||||
{"jump-near", 0},
|
||||
{"switch", 0},
|
||||
{"loop-infinite", 0},
|
||||
{"loop", 0},
|
||||
{"loop-lifetime", 0},
|
||||
{"loop-in-loop", 0},
|
||||
{"for", 0},
|
||||
{"memory-free", 0},
|
||||
{"out-of-memory", 0},
|
||||
@ -69,6 +70,7 @@ var programs = []struct {
|
||||
{"len", 0},
|
||||
{"cast", 0},
|
||||
{"function-pointer", 0},
|
||||
{"function-pointer-field", 0},
|
||||
}
|
||||
|
||||
func TestPrograms(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user