summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/RegExp/prototype/compile/pattern-regexp-props.js
blob: f723c0017493e9e5e78509056fb476407dd98836 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-regexp.prototype.compile
es6id: B.2.5.1
description: >
    Properties are not referenced when provided pattern is a RegExp instance
info: |
    [...]
    3. If Type(pattern) is Object and pattern has a [[RegExpMatcher]] internal
       slot, then
       a. If flags is not undefined, throw a TypeError exception.
       b. Let P be the value of pattern's [[OriginalSource]] internal slot.
       c. Let F be the value of pattern's [[OriginalFlags]] internal slot.
    4. Else,
       [...]
    5. Return ? RegExpInitialize(O, P, F).
---*/

var thisValue = /abc/gim;
var pattern = /def/mig;
var flagsCount  = 0;
var globalCount = 0;
var ignoreCaseCount = 0;
var multilineCount = 0;
var stickyCount = 0;
var unicodeCount = 0;
var counters = {
  flags: {
    get: function() {
      flagsCount += 1;
    }
  },
  global: {
    get: function() {
      globalCount += 1;
    }
  },
  ignoreCase: {
    get: function() {
      ignoreCaseCount += 1;
    }
  },
  multiline: {
    get: function() {
      multilineCount += 1;
    }
  },
  sticky: {
    get: function() {
      stickyCount += 1;
    }
  },
  unicode: {
    get: function() {
      unicodeCount += 1;
    }
  }
};

Object.defineProperties(thisValue, counters);
Object.defineProperties(pattern, counters);

thisValue.compile(thisValue);
thisValue.compile(pattern);
thisValue.compile(thisValue);

assert.sameValue(flagsCount, 0, '`flags` property not accessed');
assert.sameValue(globalCount, 0, '`global` property not accessed');
assert.sameValue(ignoreCaseCount, 0, '`ignoreCase` property not accessed');
assert.sameValue(multilineCount, 0, '`multiline` property not accessed');
assert.sameValue(stickyCount, 0, '`sticky` property not accessed');
assert.sameValue(unicodeCount, 0, '`unicode` property not accessed');

reportCompare(0, 0);