Debian Codegraph @

js/src/tests/test262/annexB/built-ins/RegExp/legacy-accessors/input/this-not-regexp-constructor.js

raw
1 // |reftest| skip -- legacy-regexp is not supported
2 // Copyright (C) 2020 ExE Boss. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: pending
6 description: RegExp.input throws a TypeError for non-%RegExp% receiver
7 info: |
8 get RegExp.input
9
10 1. Return ? GetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpInput]]).
11
12 set RegExp.input = val
13
14 1. Return ? SetLegacyRegExpStaticProperty(%RegExp%, this value, [[RegExpInput]], val).
15
16 GetLegacyRegExpStaticProperty( C, thisValue, internalSlotName ).
17
18 1. Assert C is an object that has an internal slot named internalSlotName.
19 2. If SameValue(C, thisValue) is false, throw a TypeError exception.
20 3. ...
21
22 SetLegacyRegExpStaticProperty( C, thisValue, internalSlotName, val ).
23
24 1. Assert C is an object that has an internal slot named internalSlotName.
25 2. If SameValue(C, thisValue) is false, throw a TypeError exception.
26 3. ...
27 features: [legacy-regexp]
28 ---*/
29
30 ["input", "$_"].forEach(function (property) {
31 const desc = Object.getOwnPropertyDescriptor(RegExp, property);
32
33 ["get", "set"].forEach(function (accessor) {
34 const messagePrefix = "RegExp." + property + " " + accessor + "ter";
35
36 // Similar to the other test verifying the descriptor, but split as properties can be removed or changed
37 assert.sameValue(typeof desc[accessor], "function", messagePrefix);
38
39 // If SameValue(C, thisValue) is false, throw a TypeError exception.
40 assert.throws(
41 TypeError,
42 function () {
43 desc[accessor]();
44 },
45 messagePrefix + " throws for property descriptor receiver"
46 );
47
48 assert.throws(
49 TypeError,
50 function () {
51 desc[accessor].call(/ /);
52 },
53 messagePrefix + " throws for RegExp instance receiver"
54 );
55
56 assert.throws(
57 TypeError,
58 function () {
59 desc[accessor].call(RegExp.prototype);
60 },
61 messagePrefix + " throws for %RegExp.prototype% receiver"
62 );
63
64 [undefined, null, {}, true, false, 0, 1, "string"].forEach(function (value) {
65 assert.throws(
66 TypeError,
67 function () {
68 desc[accessor].call(value);
69 },
70 messagePrefix + ' throws for primitive "' + value + '" receiver'
71 );
72 });
73 });
74 });
75
76 reportCompare(0, 0);