We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02630d7 commit 6d5210eCopy full SHA for 6d5210e
1 file changed
spec/v8/context_spec.rb
@@ -48,6 +48,33 @@
48
cxt["x"].should == 3
49
end
50
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 closures' contexts" do
62
+ js = <<-js
63
+ function wrapper(x) { return function() { return x; } };
64
+ var f = wrapper(42);
65
+ js
66
67
68
69
+ cxt.eval(js)
70
71
72
73
+ cloned_cxt.eval('x = f();')
74
75
+ cloned_cxt["x"].should == 42
76
77
78
it 'works on empty contexts' do
79
cxt = V8::Context.new
80
0 commit comments