Variables (#8)

This commit was merged in pull request #8.
This commit is contained in:
2026-05-02 20:12:15 -05:00
parent f9733f3b20
commit 9bc6ad1c92
10 changed files with 100 additions and 27 deletions

View File

@@ -268,6 +268,23 @@ TEST(VM, StringString)
)").to_integer(-1), 0);
}
TEST(VM, LocalVariables)
{
VM vm = run(R"(
.func 0
pushv 2 ; local a, b
pushi 3 ; a = 3
set 0
pushi 4 ; b = 4
set 1
dupv 0 ; return a
ret
)");
ASSERT_EQ(vm.stack_sz(), 1);
ASSERT_EQ(vm.to_integer(-1), 3);
}
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);