Skip to content

Commit 119f11e

Browse files
committed
improve test
1 parent b0bd228 commit 119f11e

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

tests/core/getValue_setValue.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#include<emscripten.h>
22

33
int main() {
4+
#ifdef DIRECT
5+
EM_ASM({
6+
setValue(8, 1234, 'i32');
7+
Module['print']('|' + getValue(8, 'i32') + '|');
8+
});
9+
#else
410
EM_ASM({
511
Module['setValue'](8, 1234, 'i32');
612
Module['print']('|' + Module['getValue'](8, 'i32') + '|');
713
});
14+
#endif
815
}
916

tests/test_core.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -5938,15 +5938,21 @@ def process(filename):
59385938

59395939
def test_getValue_setValue(self):
59405940
# these used to be exported, but no longer are by default
5941-
def test(output_prefix=''):
5941+
def test(output_prefix='', args=[]):
5942+
old = self.emcc_args[:]
5943+
self.emcc_args += args
59425944
self.do_run(open(path_from_root('tests', 'core', 'getValue_setValue.cpp')).read(),
59435945
open(path_from_root('tests', 'core', 'getValue_setValue' + output_prefix + '.txt')).read())
5946+
self.emcc_args = old
5947+
# see that direct usage (not on module) works. we don't export, but the use
5948+
# keeps it alive through JSDCE
5949+
test(args=['-DDIRECT'])
59445950
# see that with assertions, we get a nice error message
59455951
Settings.EXTRA_EXPORTED_RUNTIME_METHODS = []
59465952
Settings.ASSERTIONS = 1
59475953
test('_assert')
59485954
Settings.ASSERTIONS = 0
5949-
# see that when we export them, things work
5955+
# see that when we export them, things work on the module
59505956
Settings.EXTRA_EXPORTED_RUNTIME_METHODS = ['getValue', 'setValue']
59515957
test()
59525958

0 commit comments

Comments
 (0)