we in era3 boys; overhauled expression system, and variables are now in maps
This commit is contained in:
parent
bf29e6c3dd
commit
43e450c207
14 changed files with 945 additions and 452 deletions
|
|
@ -5,6 +5,30 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func CompareScope(t *testing.T, expectedScope []map[string]Value, actualScope *Scope) {
|
||||
s := actualScope
|
||||
|
||||
for i := len(expectedScope) - 1; i >= 0; i-- {
|
||||
if s == nil {
|
||||
t.Fatal("scope cut unexpecetantly short")
|
||||
}
|
||||
|
||||
for name, value := range expectedScope[i] {
|
||||
v, ok := s.current[name]
|
||||
if !ok {
|
||||
t.Errorf("variable %s not found in correct scope", name)
|
||||
continue
|
||||
}
|
||||
|
||||
if !v.Equals(value) {
|
||||
t.Errorf("variable %s has value %s but expected %s", name, v.String(), value.String())
|
||||
} else {
|
||||
t.Logf("variable %s has expected value %s", name, v.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CompareStacks[T Value](t *testing.T, expected []T, actual *Stack[T]) {
|
||||
if actual.Current != Pos(len(expected)) {
|
||||
t.Errorf("Unexpected stack size. Expected %d, got %d", len(expected), actual.Current)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue