diff --git a/test/test_execjs.rb b/test/test_execjs.rb index fa4ef02..957b7b2 100644 --- a/test/test_execjs.rb +++ b/test/test_execjs.rb @@ -160,13 +160,20 @@ class TestExecJS < Test end end - def test_compile + def test_compile_anonymous_function context = ExecJS.compile("foo = function() { return \"bar\"; }") assert_equal "bar", context.exec("return foo()") assert_equal "bar", context.eval("foo()") assert_equal "bar", context.call("foo") end + def test_compile_named_function + context = ExecJS.compile("function foo() { return \"bar\"; }") + assert_equal "bar", context.exec("return foo()") + assert_equal "bar", context.eval("foo()") + assert_equal "bar", context.call("foo") + end + def test_this_is_global_scope assert_equal true, ExecJS.eval("this === (function() {return this})()") assert_equal true, ExecJS.exec("return this === (function() {return this})()")