summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/RegExp/replace-compile-elembase.js
blob: 591d27cfe9b420b3b1bbf4e645162dd4b495346e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function() {
    var rx = /a/g;
    var b = {
        get a() {
            rx.compile("b");
            return "A";
        }
    };

    // Replacer function which is applicable for the elem-base optimization in
    // RegExp.prototype.@@replace.
    function replacer(a) {
        return b[a];
    }

    var result = rx[Symbol.replace]("aaa", replacer);

    assertEq(result, "AAA");
})();

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