@@ -4948,6 +4948,35 @@ def test_jslib_aliases(self, args):
49484948'''
49494949 self.do_runf('main.c', expected, cflags=['--js-library', 'foo.js'] + args)
49504950
4951+ @parameterized({
4952+ '': ([],),
4953+ 'closure': (['--closure=1'],),
4954+ })
4955+ def test_jslib_export_alias(self, args):
4956+ create_file('lib.js', '''
4957+ addToLibrary({
4958+ $foo: 'main',
4959+ $bar: '__indirect_function_table',
4960+ $baz: 'memory',
4961+ });
4962+ ''')
4963+ create_file('extern_pre.js', r'''
4964+ Module = {
4965+ onRuntimeInitialized: () => {
4966+ const assert = require('assert');
4967+ console.log("onRuntimeInitialized");
4968+ console.log('foo:', typeof Module.foo)
4969+ console.log('bar:', typeof Module.bar)
4970+ console.log('baz:', typeof Module.baz)
4971+ assert(Module.foo instanceof Function);
4972+ assert(Module.bar instanceof WebAssembly.Table);
4973+ assert(Module.baz instanceof WebAssembly.Memory);
4974+ console.log('done');
4975+ }
4976+ };
4977+ ''')
4978+ self.do_runf('hello_world.c', 'done\n', cflags=['--js-library=lib.js', '--extern-pre-js=extern_pre.js', '-sEXPORTED_RUNTIME_METHODS=foo,bar,baz'] + args)
4979+
49514980 def test_postjs_errors(self):
49524981 create_file('post.js', '#preprocess\n#error This is an error')
49534982 err = self.expect_fail([EMCC, test_file('hello_world.c'), '--post-js', 'post.js'])
0 commit comments