Added more tests

This commit is contained in:
2024-07-07 17:13:22 +02:00
parent 23b4e6442d
commit 9f341a6146
7 changed files with 157 additions and 13 deletions

View File

@ -0,0 +1,3 @@
main() {
unknown()
}

View File

@ -33,6 +33,7 @@ var errs = []struct {
{"MissingOperand.q", errors.MissingOperand},
{"MissingOperand2.q", errors.MissingOperand},
{"VariableAlreadyExists.q", &errors.VariableAlreadyExists{Name: "x"}},
{"UnknownFunction.q", &errors.UnknownFunction{Name: "unknown"}},
{"UnknownIdentifier.q", &errors.UnknownIdentifier{Name: "x"}},
{"UnknownIdentifier2.q", &errors.UnknownIdentifier{Name: "x"}},
{"UnknownIdentifier3.q", &errors.UnknownIdentifier{Name: "f"}},

81
tests/programs/branch.q Normal file
View File

@ -0,0 +1,81 @@
main() {
x := 0
if x != 0 {
exit(1)
}
if x > 0 {
exit(1)
}
if x < 0 {
exit(1)
}
if 0 != x {
exit(1)
}
if 0 > x {
exit(1)
}
if 0 < x {
exit(1)
}
if x >= 1 {
exit(1)
}
if 1 <= x {
exit(1)
}
if x == inc(x) {
exit(1)
}
if x == dec(x) {
exit(1)
}
if inc(0) == x {
exit(1)
}
if dec(0) == x {
exit(1)
}
if inc(x) == dec(x) {
exit(1)
}
if x + 1 != inc(x) {
exit(1)
}
if x + 1 != x + 1 {
exit(1)
}
if x == 0 {
exit(0)
}
exit(1)
}
exit(x) {
syscall(60, x)
}
inc(x) {
return x + 1
}
dec(x) {
return x - 1
}