0
@@ -58,7 +58,7 @@ module Johnson
0
- @
context = Johnson::Context.new(Johnson::SpiderMonkey::Context)
0
+ @
runtime = Johnson::Runtime.new(Johnson::SpiderMonkey::Runtime)
0
def test_find_constants
0
@@ -66,14 +66,14 @@ module Johnson
0
def test_proxies_get_reused
0
- @
context["foo"] = @context["bar"] = Foo.new
0
+ @
runtime["foo"] = @runtime["bar"] = Foo.new
0
assert_js_equal(true, "foo === bar")
0
def test_attributes_get_added_to_ruby
0
- foo = @
context["foo"] = Foo.new
0
+ foo = @
runtime["foo"] = Foo.new
0
assert !foo.respond_to?(:johnson)
0
- @
context.evaluate("foo.johnson = 'explode';")
0
+ @
runtime.evaluate("foo.johnson = 'explode';")
0
assert foo.respond_to?(:johnson)
0
assert_equal('explode', foo.johnson)
0
assert_js_equal('explode', 'foo.johnson')
0
@@ -81,9 +81,9 @@ module Johnson
0
def test_assign_function_as_attribute
0
- foo = @
context["foo"] = Foo.new
0
+ foo = @
runtime["foo"] = Foo.new
0
assert !foo.respond_to?(:johnson)
0
- f = @
context.evaluate("foo.johnson = function() { return 'explode'; }")
0
+ f = @
runtime.evaluate("foo.johnson = function() { return 'explode'; }")
0
assert foo.respond_to?(:johnson)
0
assert_equal('explode', foo.johnson)
0
assert_js_equal('explode', 'foo.johnson()')
0
@@ -92,115 +92,115 @@ module Johnson
0
def test_assign_function_as_attribute_with_this
0
- foo = @context["foo"] = Foo.new
0
- @context.evaluate("foo.ex_squared = function(x) { return this.x2(x); }")
0
+ foo = @runtime["foo"] = Foo.new
0
+ @runtime.evaluate("foo.ex_squared = function(x) { return this.x2(x); }")
0
assert_equal(4, foo.ex_squared(2))
0
- @
context.evaluate("foo.ex_squared = 20;")
0
+ @
runtime.evaluate("foo.ex_squared = 20;")
0
assert_equal(20, foo.ex_squared)
0
def test_use_ruby_global_object
0
- func = @
context.evaluate("function(x) { return this.x2(x); }")
0
+ func = @
runtime.evaluate("function(x) { return this.x2(x); }")
0
assert_equal(4, func.call_using(foo, 2))
0
def test_proxies_roundtrip
0
- @context["foo"] = foo = Foo.new
0
- assert_same(foo, @context.evaluate("foo"))
0
+ @runtime["foo"] = foo = Foo.new
0
+ assert_same(foo, @runtime.evaluate("foo"))
0
def test_proxies_classes
0
- assert_same(Foo, @context.evaluate("Foo"))
0
+ assert_same(Foo, @runtime.evaluate("Foo"))
0
def test_proxies_modules
0
- @context["AModule"] = AModule
0
- assert_same(AModule, @context.evaluate("AModule"))
0
+ @runtime["AModule"] = AModule
0
+ assert_same(AModule, @runtime.evaluate("AModule"))
0
def test_proxies_hashes
0
- @context["beatles"] = { "george" => "guitar" }
0
- assert_equal("guitar", @context.evaluate("beatles['george']"))
0
+ @runtime["beatles"] = { "george" => "guitar" }
0
+ assert_equal("guitar", @runtime.evaluate("beatles['george']"))
0
def test_getter_calls_0_arity_method
0
- @
context["foo"] = Foo.new
0
+ @
runtime["foo"] = Foo.new
0
assert_js_equal(10, "foo.bar")
0
def test_getter_calls_indexer
0
- @
context["foo"] = indexable = Indexable.new
0
+ @
runtime["foo"] = indexable = Indexable.new
0
assert_js_equal(10, "foo.bar")
0
def test_getter_returns_nil_for_unknown_properties
0
- @
context["foo"] = Foo.new
0
+ @
runtime["foo"] = Foo.new
0
assert_js_equal(nil, "foo.quux")
0
def test_setter_calls_key=
0
- @
context["foo"] = foo = Foo.new
0
+ @
runtime["foo"] = foo = Foo.new
0
assert_js_equal(42, "foo.bar = 42")
0
assert_equal(42, foo.bar)
0
def test_setter_calls_indexer
0
- @
context["foo"] = indexable = Indexable.new
0
+ @
runtime["foo"] = indexable = Indexable.new
0
assert_js_equal(42, "foo.monkey = 42")
0
assert_equal(42, indexable["monkey"])
0
def test_calls_attr_reader
0
- @
context["foo"] = Foo.new
0
+ @
runtime["foo"] = Foo.new
0
assert_js_equal(10, "foo.bar")
0
def test_calls_1_arity_method
0
- @
context["foo"] = Foo.new
0
+ @
runtime["foo"] = Foo.new
0
assert_js_equal(10, "foo.x2(5)")
0
def test_calls_n_arity_method
0
- @
context["foo"] = Foo.new
0
+ @
runtime["foo"] = Foo.new
0
assert_js_equal(10, "foo.add(4, 2, 2, 1, 1)")
0
def test_calls_class_method
0
assert_js_equal(Foo.bar, "Foo.bar()")
0
def test_accesses_consts
0
- assert_same(Foo::Inner, @context.evaluate("Foo.Inner"))
0
+ assert_same(Foo::Inner, @runtime.evaluate("Foo.Inner"))
0
def test_can_create_new_instances_in_js
0
- @context["AClass"] = AClass
0
- foo = @context.evaluate("AClass.new()")
0
+ @runtime["AClass"] = AClass
0
+ foo = @runtime.evaluate("AClass.new()")
0
assert_kind_of(AClass, foo)
0
def test_class_proxies_provide_a_ctor
0
- @context["AClass"] = AClass
0
- foo = @context.evaluate("new AClass()")
0
+ @runtime["AClass"] = AClass
0
+ foo = @runtime.evaluate("new AClass()")
0
assert_kind_of(AClass, foo)
0
- bar = @
context.evaluate("new AClass(1, 2, 3)")
0
+ bar = @
runtime.evaluate("new AClass(1, 2, 3)")
0
assert_equal([1, 2, 3], bar.args)
0
- @
context["foo"] = Foo.new
0
+ @
runtime["foo"] = Foo.new
0
assert_js_equal(4, "foo.xform(2, function(x) { return x * 2 })")
0
def test_dwims_blocks_for_0_arity_methods
0
- @
context[:arr] = [1, 2, 3]
0
+ @
runtime[:arr] = [1, 2, 3]
0
assert_js_equal([2, 4, 6], "arr.collect(function(x) { return x * 2 })")
0
@@ -221,15 +221,15 @@ module Johnson
0
def test_raises_string_to_ruby
0
- assert_raise(Johnson::Error) { @
context.evaluate("throw 'my string';") }
0
+ assert_raise(Johnson::Error) { @
runtime.evaluate("throw 'my string';") }
0
def test_raises_object_to_ruby
0
- assert_raise(Johnson::Error) { @
context.evaluate("throw { bad: true };") }
0
+ assert_raise(Johnson::Error) { @
runtime.evaluate("throw { bad: true };") }
0
def test_raises_exception_to_ruby
0
- assert_raise(Johnson::Error) { @
context.evaluate("undefinedValue();") }
0
+ assert_raise(Johnson::Error) { @
runtime.evaluate("undefinedValue();") }