public void Will_parses_a_simple_attribute_assignment() { var o = new DummyClass(0); var method = _compiler.Parse <DummyClass, DummyClass, object>("Key = 42"); method(o, null).Should().Be(42); o.Key.Should().Be(42); }
public void Will_parse_on_plain_object_scope() { var o = new DummyClass(42); var method = _compiler.Parse <DummyClass, DummyClass, object>("Key"); method(o, null).Should().Be(42); }
public void Uses_locals_instead_of_scope_when_there_is_matching_key() { //Assert var method = _compiler.Parse <int>("aKey"); var scope = new JavascriptObject { { "aKey", 43 } }; var locals = new JavascriptObject { { "aKey", 42 } }; method(scope, locals).Should().Be(42); }
public void Parses_a_function_call() { //Assert var value = new Func <int>(() => 42); var scope = new JavascriptObject { { "aFunction", value } }; var method = _compiler.Parse <int>("aFunction()"); method(scope, null).Should().Be(42); }
public void Parses_a_simple_computed_property_access() { //Assert var obj = new JavascriptObject { { "key", new JavascriptObject { { "key2", 42 } } } }; var method = _compiler.Parse <int>("key['key2']"); method(obj, null).Should().Be(42); }
public void Looks_up_an_property_from_the_scope() { //Assert var method = _compiler.Parse <int>("aKey"); //Assert var obj = new JavascriptObject(); dynamic dyn = obj; dyn.aKey = 42; method(obj, null).Should().Be(42); }
public void Parse_Can_Parse_Integer(string input, int output) { var method = _compiler.Parse <int>(input); //Assert method(null, null).Should().Be(output); }