Skip to content

Commit 99c0843

Browse files
Revert "Add JS::NULL and JS::UNDEFINED constants"
This reverts commit 3294e8a. Still has issue #26 (reply in thread)
1 parent 706ca01 commit 99c0843

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

ext/js/js-core.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ static VALUE _rb_js_eval_js(VALUE _, VALUE code_str) {
8787
return jsvalue_s_new(rb_js_abi_host_eval_js(&abi_str));
8888
}
8989

90-
static VALUE _rb_js_eval_js_cstr(const char *code_str) {
91-
rb_js_abi_host_string_t abi_str;
92-
rb_js_abi_host_string_set(&abi_str, code_str);
93-
return jsvalue_s_new(rb_js_abi_host_eval_js(&abi_str));
94-
}
95-
9690
static VALUE _rb_js_is_js(VALUE _, VALUE obj) {
9791
if (!IS_JSVALUE(obj)) {
9892
return Qfalse;
@@ -376,8 +370,6 @@ void Init_js() {
376370
rb_define_module_function(rb_mJS, "try_convert", _rb_js_try_convert, 1);
377371
rb_define_module_function(rb_mJS, "eval", _rb_js_eval_js, 1);
378372
rb_define_module_function(rb_mJS, "global", _rb_js_global_this, 0);
379-
rb_define_const(rb_mJS, "NULL", _rb_js_eval_js_cstr("return null"));
380-
rb_define_const(rb_mJS, "UNDEFINED", _rb_js_eval_js_cstr("return undefined"));
381373

382374
i_to_js = rb_intern("to_js");
383375
rb_cJS_Object = rb_define_class_under(rb_mJS, "Object", rb_cObject);

packages/npm-packages/ruby-wasm-wasi/test/js_from_rb.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,18 @@ describe("Manipulation of JS from Ruby", () => {
210210

211211
test("Guard null", async () => {
212212
const vm = await initRubyVM();
213-
const results = vm.eval(`
213+
const result = vm.eval(`
214214
require "js"
215215
intrinsics = JS.eval(<<-JS)
216216
return {
217217
returnNull(v) { return null },
218218
returnUndef(v) { return undefined },
219219
}
220220
JS
221+
js_null = JS.eval("return null")
221222
o1 = intrinsics.call(:returnNull)
222-
o2 = intrinsics.call(:returnUndef)
223-
[o1 == JS::NULL, o2 == JS::UNDEFINED]
223+
o1 == js_null
224224
`);
225-
const e1 = results.call("at", vm.eval("0"));
226-
const e2 = results.call("at", vm.eval("1"));
227-
expect(e1.toString()).toEqual("true");
228-
expect(e2.toString()).toEqual("true");
225+
expect(result.toString()).toEqual("true");
229226
});
230227
});

0 commit comments

Comments
 (0)