summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-invalid.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-invalid.js')
-rw-r--r--js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-invalid.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-invalid.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-invalid.js
new file mode 100644
index 0000000000..81d509c332
--- /dev/null
+++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-invalid.js
@@ -0,0 +1,58 @@
+// Copyright (C) 2015 Mike Pennisi. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 21.2.5.9
+description: Behavior when invalid value is returned by custom `exec` method
+info: |
+ [...]
+ 9. Let result be RegExpExec(rx, S).
+ 10. ReturnIfAbrupt(result).
+ [...]
+ 14. Return Get(result, "index").
+
+ 21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S )
+
+ [...]
+ 5. If IsCallable(exec) is true, then
+ a. Let result be Call(exec, R, «S»).
+ b. ReturnIfAbrupt(result).
+ c. If Type(result) is neither Object or Null, throw a TypeError
+ exception.
+
+features: [Symbol, Symbol.search]
+---*/
+
+var retVal;
+var fakeRe = {
+ exec: function() {
+ return retVal;
+ }
+};
+
+retVal = undefined;
+assert.throws(TypeError, function() {
+ RegExp.prototype[Symbol.search].call(fakeRe, 'a');
+});
+
+retVal = 86;
+assert.throws(TypeError, function() {
+ RegExp.prototype[Symbol.search].call(fakeRe, 'a');
+});
+
+retVal = 'string';
+assert.throws(TypeError, function() {
+ RegExp.prototype[Symbol.search].call(fakeRe, 'a');
+});
+
+retVal = true;
+assert.throws(TypeError, function() {
+ RegExp.prototype[Symbol.search].call(fakeRe, 'a');
+});
+
+retVal = Symbol();
+assert.throws(TypeError, function() {
+ RegExp.prototype[Symbol.search].call(fakeRe, 'a');
+});
+
+reportCompare(0, 0);