Skip to content

Commit c65a321

Browse files
authored
Ensure all core embind tests can run with closure. NFC (#20240)
This change doesn't actually run them all with closure (don't want to add too much time to CI), but I verified that they all at least do run now.
1 parent c6a1b76 commit c65a321

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

src/embind/embind.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ var LibraryEmbind = {
408408
},
409409

410410
#if WASM_BIGINT
411+
_embind_register_bigint__docs: '/** @suppress {globalThis} */',
411412
_embind_register_bigint__deps: [
412413
'$embindRepr', '$readLatin1String', '$registerType', '$integerReadValueFromPointer'],
413414
_embind_register_bigint: (primitiveType, name, size, minRange, maxRange) => {

test/core/embind_lib_with_asyncify.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
Module.onRuntimeInitialized = async () => {
1+
Module['onRuntimeInitialized'] = async () => {
22
try {
3-
let delayedThrowResult = Module.delayed_throw();
3+
let delayedThrowResult = Module["delayed_throw"]();
44
assert(delayedThrowResult instanceof Promise);
55
let err = await delayedThrowResult.then(() => '', err => err.message);
66
assert(err === 'my message', `"${err}" doesn't contain the expected error`);
77

8-
let fooResult = Module.foo();
8+
let fooResult = Module["foo"]();
99
assert(fooResult instanceof Promise);
1010
fooResult = await fooResult;
1111
assert(fooResult === 10);
1212

13-
let barInstancePromise = new Module.Bar();
13+
let barInstancePromise = new Module["Bar"]();
1414
assert(barInstancePromise instanceof Promise);
1515
let barInstance = await barInstancePromise;
16-
assert(barInstance instanceof Module.Bar);
16+
assert(barInstance instanceof Module["Bar"]);
1717
assert(barInstance.x === 20);
1818

1919
let barMethodResult = barInstance.method();
@@ -27,7 +27,7 @@ Module.onRuntimeInitialized = async () => {
2727
assert(barMethodResult instanceof Promise);
2828
assert(await barMethodResult === undefined);
2929

30-
let barStaticMethodResult = Module.Bar.static_method();
30+
let barStaticMethodResult = Module["Bar"].static_method();
3131
assert(barStaticMethodResult instanceof Promise);
3232
assert(await barStaticMethodResult === 50);
3333

test/core/test_embind_5.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ EMSCRIPTEN_BINDINGS(my_module) {
5151
int main(int argc, char **argv) {
5252
EM_ASM(
5353
try {
54-
var foo = new Module.MyFoo();
55-
foo.doit();
56-
var bar = new Module.MyBar();
57-
bar.doit();
54+
var foo = new Module['MyFoo']();
55+
foo['doit']();
56+
var bar = new Module['MyBar']();
57+
bar['doit']();
5858
} catch(e) {
5959
out(e);
6060
} finally {

test/core/test_embind_polymorphic_class_no_rtti.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <stdio.h>
1010

1111
EM_JS(void, calltest, (), {
12-
var foo = new Module.Foo();
12+
var foo = new Module["Foo"]();
1313
console.log("foo.test() returned: " + foo.test());
1414
foo.delete();
1515
});

test/embind/test_custom_marshal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Module.js_func = function(x) {
1+
Module['js_func'] = function(x) {
22
console.log('JS got', x, typeof(x));
33
return 20;
44
}

test/embind/test_finalization.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Module.onRuntimeInitialized = () => {
2-
const foo1 = new Module.Foo("Constructed from JS");
3-
const foo2 = Module.foo();
4-
const foo3 = Module.pFoo();
2+
const foo1 = new Module["Foo"]("Constructed from JS");
3+
const foo2 = Module["foo"]();
4+
const foo3 = Module["pFoo"]();
55
setTimeout(gc, 100);
66
}

test/embind/test_i64_val.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ int main() {
4141
std::array<std::int64_t, 5> int64Array = {-2, -1, 0, 1, 2};
4242

4343
printf("start\n");
44+
EM_ASM({globalThis.a = null});
4445

4546
test("val(int64_t v)");
4647
val::global().set("a", val(int64_t(1234)));

test/test_core.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7637,10 +7637,11 @@ def test_embind(self, args):
76377637
})
76387638
@node_pthreads
76397639
def test_embind_2(self, args):
7640+
self.maybe_closure()
76407641
self.emcc_args += ['-lembind', '--post-js', 'post.js'] + args
76417642
create_file('post.js', '''
76427643
function printLerp() {
7643-
out('lerp ' + Module.lerp(100, 200, 66) + '.');
7644+
out('lerp ' + Module['lerp'](100, 200, 66) + '.');
76447645
}
76457646
''')
76467647
create_file('test_embind_2.cpp', r'''
@@ -7668,7 +7669,7 @@ def test_embind_3(self):
76687669
create_file('post.js', '''
76697670
function ready() {
76707671
try {
7671-
Module.compute(new Uint8Array([1,2,3]));
7672+
Module['compute'](new Uint8Array([1,2,3]));
76727673
} catch(e) {
76737674
out(e);
76747675
}
@@ -7695,7 +7696,7 @@ def test_embind_4(self):
76957696
self.emcc_args += ['-lembind', '--post-js', 'post.js']
76967697
create_file('post.js', '''
76977698
function printFirstElement() {
7698-
out(Module.getBufferView()[0]);
7699+
out(Module['getBufferView']()[0]);
76997700
}
77007701
''')
77017702
create_file('test_embind_4.cpp', r'''
@@ -7779,7 +7780,7 @@ def test_embind_no_rtti(self):
77797780
#include <stdio.h>
77807781
77817782
EM_JS(void, calltest, (), {
7782-
out("dotest returned: " + Module.dotest());
7783+
out("dotest returned: " + Module["dotest"]());
77837784
});
77847785
77857786
int main(int argc, char** argv){
@@ -7811,7 +7812,7 @@ def test_embind_no_rtti_followed_by_rtti(self):
78117812
#include <stdio.h>
78127813
78137814
EM_JS(void, calltest, (), {
7814-
out("dotest returned: " + Module.dotest());
7815+
out("dotest returned: " + Module["dotest"]());
78157816
});
78167817
78177818
int main(int argc, char** argv){

0 commit comments

Comments
 (0)