5 #include "ebisp/scope.h"
6 #include "ebisp/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, "ss", "hello", "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 { fprintf(stderr, "Unexpected value of `x`\n"); });
28 ASSERT_TRUE(equal(CONS(gc, y, STRING(gc, "world")), get_scope_value(&scope, y)),
29 { fprintf(stderr, "Unexpected value of `y`\n"); });
30 ASSERT_TRUE(equal(CONS(gc, z, STRING(gc, "foo")), get_scope_value(&scope, z)),
31 { fprintf(stderr, "Unexpected value of `z`\n"); });
33 pop_scope_frame(gc, &scope);
35 ASSERT_TRUE(equal(NIL(gc), get_scope_value(&scope, x)),
36 { fprintf(stderr, "Unexpected value of `x`\n"); });
37 ASSERT_TRUE(equal(NIL(gc), get_scope_value(&scope, y)),
38 { fprintf(stderr, "Unexpected value of `y`\n"); });
39 ASSERT_TRUE(equal(CONS(gc, z, STRING(gc, "foo")), get_scope_value(&scope, z)),
40 { fprintf(stderr, "Unexpected value of `z`\n"); });
48 TEST_SUITE(scope_suite)
50 TEST_RUN(set_scope_value_test);
55 #endif // SCOPE_SUITE_H_