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 9aef510 commit ada15e3Copy full SHA for ada15e3
packages/npm-packages/ruby-wasm-wasi/test/vm.test.ts
@@ -149,4 +149,25 @@ eval:6:in \`bar'
149
eval:3:in \`foo'
150
eval:11:in \`<main>'`);
151
});
152
+
153
+ test("protect objects having same hash values from GC", async () => {
154
+ const vm = await initRubyVM();
155
+ vm.eval(`
156
+ class X
157
+ def hash
158
+ 42
159
+ end
160
+ def eql?(other)
161
+ true
162
163
164
+ `);
165
166
+ const o1 = vm.eval(`X.new`);
167
+ const o2 = vm.eval(`X.new`);
168
+ const o3 = vm.eval(`X.new`);
169
+ vm.eval(`GC.start`);
170
+ expect(o1.call("hash").toString()).toBe(o2.call("hash").toString());
171
+ expect(o2.call("hash").toString()).toBe(o3.call("hash").toString());
172
+ });
173
0 commit comments