Backed out 3 changesets (bug 1892041) for causing failures on async-module-does-not...
[gecko.git] / js / src / tests / test262 / built-ins / RegExp / prototype / Symbol.replace / exec-invocation.js
blob54f4b7b59edf4cf51d615d644b70a5d439493a47
1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: Invocation of `exec` method
6 es6id: 21.2.5.8
7 info: |
8     [...]
9     13. Repeat, while done is false
10         a. Let result be RegExpExec(rx, S).
11         [...]
13     21.2.5.2.1 Runtime Semantics: RegExpExec ( R, S )
15     [...]
16     3. Let exec be Get(R, "exec").
17     4. ReturnIfAbrupt(exec).
18     5. If IsCallable(exec) is true, then
19        a. Let result be Call(exec, R, «S»).
20 features: [Symbol.replace]
21 ---*/
23 var r = /./;
24 var callCount = 0;
25 var arg = {
26   toString: function() {
27     return 'string form';
28   }
30 var thisValue, args;
32 r.exec = function() {
33   thisValue = this;
34   args = arguments;
35   callCount += 1;
36   return null;
39 r[Symbol.replace](arg, '');
41 assert.sameValue(callCount, 1);
42 assert.sameValue(thisValue, r);
43 assert.sameValue(args.length, 1);
44 assert.sameValue(args[0], 'string form');
46 reportCompare(0, 0);