Skip to content

Commit

Permalink
Added test for symbol object access
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Aug 6, 2020
1 parent 9ac7a76 commit 36f1321
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions boa/src/builtins/symbol/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,20 @@ fn print_symbol_expect_description() {
let sym = forward_val(&mut engine, "sym.toString()").unwrap();
assert_eq!(sym.to_string(), "\"Symbol(Hello)\"");
}

#[test]
fn symbol_access() {
let realm = Realm::create();
let mut engine = Interpreter::new(realm);
let init = r#"
var x = {};
var sym1 = Symbol("Hello");
var sym2 = Symbol("Hello");
x[sym1] = 10;
x[sym2] = 20;
"#;
forward_val(&mut engine, init).unwrap();
assert_eq!(forward(&mut engine, "x[sym1]"), "10");
assert_eq!(forward(&mut engine, "x[sym2]"), "20");
assert_eq!(forward(&mut engine, "x['Symbol(Hello)']"), "undefined");
}

0 comments on commit 36f1321

Please sign in to comment.