5 #include "script/scope.h"
6 #include "script/expr.h"
8 TEST(set_scope_value_test)
12 struct Expr z = SYMBOL(gc, "z");
13 struct Expr x = SYMBOL(gc, "x");
14 struct Expr y = SYMBOL(gc, "y");
16 struct Scope scope = {
17 .expr = CONS(gc, NIL(gc), NIL(gc))
20 push_scope_frame(gc, &scope,
22 list(gc, 2, STRING(gc, "hello"), STRING(gc, "world")));
24 set_scope_value(gc, &scope, z, STRING(gc, "foo"));
26 ASSERT_TRUE(equal(CONS(gc, x, STRING(gc, "hello")), get_scope_value(&scope, x)),
27 "Unexpected value of `x`");
28 ASSERT_TRUE(equal(CONS(gc, y, STRING(gc, "world")), get_scope_value(&scope, y)),
29 "Unexpected value of `y`");
30 ASSERT_TRUE(equal(CONS(gc, z, STRING(gc, "foo")), get_scope_value(&scope, z)),
31 "Unexpected value of `z`");
33 pop_scope_frame(gc, &scope);
35 ASSERT_TRUE(equal(NIL(gc), get_scope_value(&scope, x)),
36 "Unexpected value of `x`");
37 ASSERT_TRUE(equal(NIL(gc), get_scope_value(&scope, y)),
38 "Unexpected value of `y`");
39 ASSERT_TRUE(equal(CONS(gc, z, STRING(gc, "foo")), get_scope_value(&scope, z)),
40 "Unexpected value of `z`");
48 TEST_SUITE(scope_suite)
50 TEST_RUN(set_scope_value_test);
55 #endif // SCOPE_SUITE_H_