Added more tests

This commit is contained in:
Eduard Urbach 2024-07-30 15:46:47 +02:00
parent 1e7a1399d3
commit 5abe8acc70
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
4 changed files with 22 additions and 7 deletions

View File

@ -5,12 +5,11 @@ import (
"git.akyoto.dev/cli/q/src/build/errors" "git.akyoto.dev/cli/q/src/build/errors"
"git.akyoto.dev/cli/q/src/build/expression" "git.akyoto.dev/cli/q/src/build/expression"
"git.akyoto.dev/cli/q/src/build/sizeof" "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. // ExpressionToMemory puts the result of an expression into the specified memory address.
func (f *Function) ExpressionToMemory(node *expression.Expression, memory asm.Memory) error { 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) number, err := f.Number(node.Token)
if err != nil { if err != nil {

View File

@ -1,6 +1,6 @@
main() { main() {
x := 1 a := 1
y := x + 1 b := a + 1
x = 2 a = 2
assert y == 2 assert b == 2
} }

View 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
}

View File

@ -20,8 +20,9 @@ var programs = []struct {
}{ }{
{"empty", "", "", 0}, {"empty", "", "", 0},
{"assert", "", "", 1}, {"assert", "", "", 1},
{"reuse", "", "", 0}, {"variables", "", "", 0},
{"reassign", "", "", 0}, {"reassign", "", "", 0},
{"reuse", "", "", 0},
{"return", "", "", 0}, {"return", "", "", 0},
{"binary", "", "", 0}, {"binary", "", "", 0},
{"octal", "", "", 0}, {"octal", "", "", 0},