feat(tazjin/rlox): Global variable assignment
Needed for example code compatibility. Change-Id: Id83210eaaad7dcfef5aa238dd3a7ec159f6935e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3684 Tested-by: BuildkiteCI Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
parent
6a38600ce8
commit
ad7e591c80
4 changed files with 38 additions and 3 deletions
|
|
@ -110,7 +110,7 @@ fn strings() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn variables() {
|
||||
fn global_variables() {
|
||||
expect_num("var a = 5; a;", 5.0);
|
||||
expect_num("var a = 5; var b = 2; a * b;", 10.0);
|
||||
expect_str(
|
||||
|
|
@ -118,3 +118,16 @@ fn variables() {
|
|||
"hello Zubnog",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn global_assignment() {
|
||||
expect_str(
|
||||
r#"
|
||||
var breakfast = "beignets";
|
||||
var beverage = "cafe au lait";
|
||||
breakfast = "beignets with " + beverage;
|
||||
breakfast;
|
||||
"#,
|
||||
"beignets with cafe au lait"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue