feat(tazjin/rlox): Implement global variable access
This also includes a fix for an issue where the identifiers of variables were pushed onto the stack, which is incorrect. Change-Id: Id89b388268efad295f29978d767aa4b33c4ded14 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2594 Reviewed-by: tazjin <mail@tazj.in> Tested-by: BuildkiteCI
This commit is contained in:
parent
29b2a54705
commit
4162186a19
4 changed files with 48 additions and 6 deletions
|
|
@ -108,3 +108,13 @@ fn strings() {
|
|||
expect_str("\"hello\";", "hello");
|
||||
expect_str("\"hello\" + \" world\";", "hello world");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variables() {
|
||||
expect_num("var a = 5; a;", 5.0);
|
||||
expect_num("var a = 5; var b = 2; a * b;", 10.0);
|
||||
expect_str(
|
||||
"var greeting = \"hello\"; var name = \"Zubnog\"; greeting + \" \" + name;",
|
||||
"hello Zubnog",
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue