summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_6/String/search.js
blob: 86d0aacc60c1fd3ba8fb4ea59fda71543af36c9e (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
var BUGNUMBER = 887016;
var summary = "Call RegExp.prototype[@@search] from String.prototype.search.";

print(BUGNUMBER + ": " + summary);

var called = 0;
var myRegExp = {
  [Symbol.search](S) {
    assertEq(S, "abcAbcABC");
    called++;
    return 42;
  }
};
assertEq("abcAbcABC".search(myRegExp), 42);
assertEq(called, 1);

called = 0;
RegExp.prototype[Symbol.search] = function(S) {
  assertEq(S, "abcAbcABC");
  called++;
  return 43;
};
assertEq("abcAbcABC".search("abc"), 43);
assertEq(called, 1);

if (typeof reportCompare === "function")
    reportCompare(true, true);