This commit is contained in:
parent
0db420aae4
commit
7245af0438
5 changed files with 35 additions and 30 deletions
|
|
@ -2,18 +2,19 @@ package core
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func CompareScope(t *testing.T, expectedScope []map[string]Value, actualScope *Scope) {
|
||||
s := actualScope
|
||||
|
||||
for i := len(expectedScope) - 1; i >= 0; i-- {
|
||||
for _, e := range slices.Backward(expectedScope) {
|
||||
if s == nil {
|
||||
t.Fatal("scope cut unexpecetantly short")
|
||||
}
|
||||
|
||||
for name, value := range expectedScope[i] {
|
||||
for name, value := range e {
|
||||
v, ok := s.current[name]
|
||||
if !ok {
|
||||
t.Errorf("variable %s not found in correct scope", name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue