test table assignment!
This commit is contained in:
parent
5f6da6ec60
commit
c6ad5c92ce
27
src/run.rs
27
src/run.rs
|
|
@ -227,6 +227,33 @@ mod tests {
|
||||||
assert_eq!(scope.get("bar"), None);
|
assert_eq!(scope.get("bar"), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_table_assign() {
|
||||||
|
let mut scope = Scope::default();
|
||||||
|
let foo = types::Table::default();
|
||||||
|
let bar = types::Table::default();
|
||||||
|
scope.variables.insert("foo".into(), foo.clone().into());
|
||||||
|
scope.variables.insert("bar".into(), bar.clone().into());
|
||||||
|
assert_eq!(foo.get("foo".into()), None);
|
||||||
|
assert_eq!(foo.get("bar".into()), None);
|
||||||
|
assert_eq!(bar.get("foo".into()), None);
|
||||||
|
assert_eq!(bar.get("bar".into()), None);
|
||||||
|
ast::Statement::Assign {
|
||||||
|
target: ast::Location::Field {
|
||||||
|
table: Box::new(ast::Location::Variable { name: "foo".into() }),
|
||||||
|
index: Box::new(ast::Expression::Constant(ast::Constant::String(
|
||||||
|
"bar".into(),
|
||||||
|
))),
|
||||||
|
},
|
||||||
|
source: Box::new(ast::Expression::Constant(ast::Constant::Number(42))),
|
||||||
|
}
|
||||||
|
.exec(&mut scope);
|
||||||
|
assert_eq!(foo.get("foo".into()), None);
|
||||||
|
assert_eq!(foo.get("bar".into()), Some(42.into()));
|
||||||
|
assert_eq!(bar.get("foo".into()), None);
|
||||||
|
assert_eq!(bar.get("bar".into()), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_call_statement() {
|
fn test_call_statement() {
|
||||||
let mut scope = Scope::default();
|
let mut scope = Scope::default();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user