Added more tests
This commit is contained in:
17
tests/programs/operator-assign-number.q
Normal file
17
tests/programs/operator-assign-number.q
Normal file
@ -0,0 +1,17 @@
|
||||
main() {
|
||||
f(10)
|
||||
}
|
||||
|
||||
f(x int) {
|
||||
y := x
|
||||
x -= 2
|
||||
assert x < y
|
||||
x += 2
|
||||
assert x == y
|
||||
x *= 2
|
||||
assert x > y
|
||||
x /= 2
|
||||
assert x == y
|
||||
x %= 2
|
||||
assert x < 2
|
||||
}
|
18
tests/programs/operator-assign-variable.q
Normal file
18
tests/programs/operator-assign-variable.q
Normal file
@ -0,0 +1,18 @@
|
||||
main() {
|
||||
f(10)
|
||||
}
|
||||
|
||||
f(x int) {
|
||||
y := x
|
||||
num := 2
|
||||
x -= num
|
||||
assert x < y
|
||||
x += num
|
||||
assert x == y
|
||||
x *= num
|
||||
assert x > y
|
||||
x /= num
|
||||
assert x == y
|
||||
x %= num
|
||||
assert x < num
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
main() {
|
||||
number(10)
|
||||
register(10)
|
||||
}
|
||||
|
||||
number(x int) {
|
||||
y := x
|
||||
x -= 1
|
||||
assert x < y
|
||||
x += 1
|
||||
assert x == y
|
||||
x *= 2
|
||||
assert x > y
|
||||
x /= 2
|
||||
assert x == y
|
||||
}
|
||||
|
||||
register(x int) {
|
||||
y := x
|
||||
num := 1
|
||||
x -= num
|
||||
assert x < y
|
||||
x += num
|
||||
assert x == y
|
||||
num = 2
|
||||
x *= num
|
||||
assert x > y
|
||||
x /= num
|
||||
assert x == y
|
||||
}
|
17
tests/programs/operator-number.q
Normal file
17
tests/programs/operator-number.q
Normal file
@ -0,0 +1,17 @@
|
||||
main() {
|
||||
f(10)
|
||||
}
|
||||
|
||||
f(x int) {
|
||||
y := x
|
||||
x = x - 2
|
||||
assert x < y
|
||||
x = x + 2
|
||||
assert x == y
|
||||
x = x * 2
|
||||
assert x > y
|
||||
x = x / 2
|
||||
assert x == y
|
||||
x = x % 2
|
||||
assert x < 2
|
||||
}
|
18
tests/programs/operator-variable.q
Normal file
18
tests/programs/operator-variable.q
Normal file
@ -0,0 +1,18 @@
|
||||
main() {
|
||||
f(10)
|
||||
}
|
||||
|
||||
f(x int) {
|
||||
y := x
|
||||
num := 2
|
||||
x = x - num
|
||||
assert x < y
|
||||
x = x + num
|
||||
assert x == y
|
||||
x = x * num
|
||||
assert x > y
|
||||
x = x / num
|
||||
assert x == y
|
||||
x = x % num
|
||||
assert x < num
|
||||
}
|
@ -28,7 +28,10 @@ var programs = []struct {
|
||||
{"return-multi", 0},
|
||||
{"math", 0},
|
||||
{"precedence", 0},
|
||||
{"operator-assign", 0},
|
||||
{"operator-number", 0},
|
||||
{"operator-variable", 0},
|
||||
{"operator-assign-number", 0},
|
||||
{"operator-assign-variable", 0},
|
||||
{"const", 0},
|
||||
{"escape-rune", 0},
|
||||
{"escape-string", 0},
|
||||
|
Reference in New Issue
Block a user