diff options
-rwxr-xr-x | test/gen-spec-js.py | 9 | ||||
-rw-r--r-- | test/gen-spec-js/assert_exhaustion.txt | 13 | ||||
-rw-r--r-- | test/gen-spec-prefix.js | 7 |
3 files changed, 24 insertions, 5 deletions
diff --git a/test/gen-spec-js.py b/test/gen-spec-js.py index a715acc3..c8502f31 100755 --- a/test/gen-spec-js.py +++ b/test/gen-spec-js.py @@ -183,9 +183,7 @@ def IsValidJSCommand(command): expected = command['expected'] return (IsValidJSAction(action) and all(IsValidJSConstant(x) for x in expected)) - elif type_ == 'assert_return_nan': - return IsValidJSAction(action) - elif type_ == 'assert_trap': + elif type_ in ('assert_return_nan', 'assert_trap', 'assert_exhaustion'): return IsValidJSAction(action) @@ -200,7 +198,7 @@ def CollectInvalidModuleCommands(commands): if module_name: module_map[module_name] = pair elif command['type'] in ('assert_return', 'assert_return_nan', - 'assert_trap'): + 'assert_trap', 'assert_exhaustion'): if IsValidJSCommand(command): continue @@ -270,7 +268,7 @@ class ModuleExtender(object): # Change the command to assert_return, it won't return NaN anymore. command['type'] = 'assert_return' - elif command_type == 'assert_trap': + elif command_type in ('assert_trap', 'assert_exhaustion'): self.lines.append('(func (export "%s")' % new_field) self._Action(command['action']) self.lines.extend(['br 0', ')']) @@ -363,6 +361,7 @@ class JSWriter(object): 'assert_return': self._WriteAssertReturnCommand, 'assert_return_nan': self._WriteAssertActionCommand, 'assert_trap': self._WriteAssertActionCommand, + 'assert_exhaustion': self._WriteAssertActionCommand, } func = command_funcs.get(command['type']) diff --git a/test/gen-spec-js/assert_exhaustion.txt b/test/gen-spec-js/assert_exhaustion.txt new file mode 100644 index 00000000..51ba3918 --- /dev/null +++ b/test/gen-spec-js/assert_exhaustion.txt @@ -0,0 +1,13 @@ +;;; TOOL: run-gen-spec-js +;;; FLAGS: --prefix=%(test_dir)s/gen-spec-empty-prefix.js +(module + (func (export "foo") + call 0)) + +(assert_exhaustion (invoke "foo") "so exhausted") +(;; STDOUT ;;; +// A deliberately empty file for testing. + +$$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x03\x02\x01\x00\x07\x07\x01\x03\x66\x6f\x6f\x00\x00\x0a\x06\x01\x04\x00\x10\x00\x0b"); +assert_exhaustion(() => $$.exports["foo"]()); +;;; STDOUT ;;) diff --git a/test/gen-spec-prefix.js b/test/gen-spec-prefix.js index 7806c477..36692dc0 100644 --- a/test/gen-spec-prefix.js +++ b/test/gen-spec-prefix.js @@ -90,4 +90,11 @@ function assert_return_nan(action) { }; } +function assert_exhaustion(action) { + try { action() } catch (e) { + if (e instanceof RangeError) return; + } + throw new Error("RangeError expected"); +} + let f32 = Math.fround; |