Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added coverage for js_property?()

  • Loading branch information...
commit d5db110c2a83751c1862c00ec9b3747cf9536ef6 1 parent 27a046f
@flavorjones flavorjones authored
Showing with 41 additions and 0 deletions.
  1. +41 −0 test/johnson/spidermonkey/js_land_proxy_test.rb
View
41 test/johnson/spidermonkey/js_land_proxy_test.rb
@@ -231,6 +231,47 @@ def test_raises_object_to_ruby
def test_raises_exception_to_ruby
assert_raise(Johnson::Error) { @runtime.evaluate("undefinedValue();") }
end
+
+ def test_js_property_false_should_not_invoke
+ klass = Class.new do
+ def bar ; 10 ; end
+ def js_property?(name) ; false ; end
+ end
+ @runtime['foo'] = foo = klass.new
+ assert_equal foo.method(:bar), @runtime.evaluate("foo.bar")
+ end
+
+ def test_js_property_nil_should_not_invoke
+ klass = Class.new do
+ def bar ; 10 ; end
+ def js_property?(name) ; nil ; end
+ end
+ foo = klass.new
+ assert_js_equal(foo.method(:bar), "foo.bar", :foo => foo)
+ end
+
+ def test_js_property_true_should_invoke_0_arity
+ klass = Class.new do
+ def bar ; 10 ; end
+ def js_property?(name) ; true ; end
+ end
+ assert_js_equal(10, "foo.bar", :foo => klass.new)
+ end
+
+ def test_js_property_on_n_arity_should_raise_exception
+ klass = Class.new do
+ def bar(n) ; 10 + n ; end
+ def js_property?(name) ; true ; end
+ end
+ @runtime['foo'] = klass.new
+ begin
+ @runtime.evaluate("foo.bar")
+ rescue Exception => e
+ assert_match(/ArgumentError/, e.message)
+ else
+ flunk "did not raise an exception"
+ end
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.