@no_wasm_backend('uses BINARYEN_TRAP_MODE (the wasm backend only supports non-trapping)')
def test_binaryen_trap_mode(self):
    if (not self.is_wasm()):
        self.skipTest('wasm test')
    TRAP_OUTPUTS = ('trap', 'RuntimeError')
    default = 'allow'
    print('default is', default)
    for mode in ['js', 'clamp', 'allow', '']:
        if ((mode == 'js') and self.is_wasm_backend()):
            continue
        print('mode:', mode)
        self.set_setting('BINARYEN_TRAP_MODE', (mode or default))
        if (not mode):
            mode = default
        print('  idiv')
        self.do_run(open(path_from_root('tests', 'wasm', 'trap-idiv.cpp')).read(), {'js': '|0|', 'clamp': '|0|', 'allow': TRAP_OUTPUTS}[mode], assert_returncode=None)
        print('  f2i')
        self.do_run(open(path_from_root('tests', 'wasm', 'trap-f2i.cpp')).read(), {'js': '|1337|\n|4294967295|', 'clamp': '|-2147483648|\n|4294967295|', 'allow': TRAP_OUTPUTS}[mode], assert_returncode=None)
@no_wasm_backend('uses BINARYEN_TRAP_MODE (the wasm backend only supports non-trapping)')
def test_binaryen_trap_mode(self):
    if (not self.is_wasm()):
        self.skipTest('wasm test')
    TRAP_OUTPUTS = ('trap', 'RuntimeError')
    default = 'allow'
    print('default is', default)
    for mode in ['js', 'clamp', 'allow', ]:
        if ((mode == 'js') and self.is_wasm_backend()):
            continue
        print('mode:', mode)
        self.set_setting('BINARYEN_TRAP_MODE', (mode or default))
        if (not mode):
            mode = default
        print('  idiv')
        self.do_run(open(path_from_root('tests', 'wasm', 'trap-idiv.cpp')).read(), {'js': '|0|', 'clamp': '|0|', 'allow': TRAP_OUTPUTS}[mode], assert_returncode=None)
        print('  f2i')
        self.do_run(open(path_from_root('tests', 'wasm', 'trap-f2i.cpp')).read(), {'js': '|1337|\n|4294967295|', 'clamp': '|-2147483648|\n|4294967295|', 'allow': TRAP_OUTPUTS}[mode], assert_returncode=None)