From 36f132112231bf3071d408fffc0b519c84cc206e Mon Sep 17 00:00:00 2001 From: HalidOdat Date: Thu, 6 Aug 2020 10:14:48 +0200 Subject: [PATCH] Added test for symbol object access --- boa/src/builtins/symbol/tests.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/boa/src/builtins/symbol/tests.rs b/boa/src/builtins/symbol/tests.rs index 518632a4ef9..d3f6ee316e0 100644 --- a/boa/src/builtins/symbol/tests.rs +++ b/boa/src/builtins/symbol/tests.rs @@ -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"); +}