Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit 6d75cbe

Browse files
committed
Adding more tests
1 parent 02630d7 commit 6d75cbe

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

spec/v8/context_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,33 @@
4848
cxt["x"].should == 3
4949
end
5050

51+
it 'duplicates functions' do
52+
cxt = V8::Context.new
53+
54+
cxt.eval('var val = {num: 5, isTruthy: function (arg) { return !!arg }}')
55+
56+
cloned_cxt = cxt.deep_clone
57+
58+
cloned_cxt["val"].isTruthy(1).should be(true)
59+
end
60+
61+
it "keeps closure's contexts" do
62+
js = <<-js
63+
function wrapper(x) { return function() { return x; } };
64+
var f = wrapper(42);
65+
js
66+
67+
cxt = V8::Context.new
68+
69+
cxt.eval(js)
70+
71+
cloned_cxt = cxt.deep_clone
72+
73+
cloned_cxt.eval('x = f();')
74+
75+
cloned_cxt["x"].should == 42
76+
end
77+
5178
it 'works on empty contexts' do
5279
cxt = V8::Context.new
5380

0 commit comments

Comments
 (0)