summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/cstm-exec-return-index.js
blob: 01410d1bdba8c4afb5cf4c657c35c908db04e5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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: Index value returned by a custom `exec` method
info: |
    [...]
    9. Let result be RegExpExec(rx, S).
    [...]
    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.
       d. Return result.

features: [Symbol.search]
---*/

var fakeRe = {
  exec: function() {
    return { index: 86 };
  }
};

assert.sameValue(RegExp.prototype[Symbol.search].call(fakeRe, 'abc'), 86);

reportCompare(0, 0);