Added more tests
This commit is contained in:
parent
1e7a1399d3
commit
5abe8acc70
@ -5,12 +5,11 @@ import (
|
||||
"git.akyoto.dev/cli/q/src/build/errors"
|
||||
"git.akyoto.dev/cli/q/src/build/expression"
|
||||
"git.akyoto.dev/cli/q/src/build/sizeof"
|
||||
"git.akyoto.dev/cli/q/src/build/token"
|
||||
)
|
||||
|
||||
// ExpressionToMemory puts the result of an expression into the specified memory address.
|
||||
func (f *Function) ExpressionToMemory(node *expression.Expression, memory asm.Memory) error {
|
||||
if node.IsLeaf() && (node.Token.Kind == token.Number || node.Token.Kind == token.Rune) {
|
||||
if node.IsLeaf() && node.Token.IsNumeric() {
|
||||
number, err := f.Number(node.Token)
|
||||
|
||||
if err != nil {
|
||||
|
@ -1,6 +1,6 @@
|
||||
main() {
|
||||
x := 1
|
||||
y := x + 1
|
||||
x = 2
|
||||
assert y == 2
|
||||
a := 1
|
||||
b := a + 1
|
||||
a = 2
|
||||
assert b == 2
|
||||
}
|
15
tests/programs/variables.q
Normal file
15
tests/programs/variables.q
Normal file
@ -0,0 +1,15 @@
|
||||
main() {
|
||||
a := 1
|
||||
b := 2
|
||||
c := 3
|
||||
d := 4
|
||||
e := 5
|
||||
f := 6
|
||||
g := 7
|
||||
h := 8
|
||||
|
||||
assert a != b
|
||||
assert c != d
|
||||
assert e != f
|
||||
assert g != h
|
||||
}
|
@ -20,8 +20,9 @@ var programs = []struct {
|
||||
}{
|
||||
{"empty", "", "", 0},
|
||||
{"assert", "", "", 1},
|
||||
{"reuse", "", "", 0},
|
||||
{"variables", "", "", 0},
|
||||
{"reassign", "", "", 0},
|
||||
{"reuse", "", "", 0},
|
||||
{"return", "", "", 0},
|
||||
{"binary", "", "", 0},
|
||||
{"octal", "", "", 0},
|
||||
|
Loading…
Reference in New Issue
Block a user