|
1 | | -const obj = { |
2 | | - get name() { return 'bar'; }, |
3 | | - get [expr]() { return 'bar'; }, |
4 | | - async get name() { return 'bar'; }, |
5 | | - set name(val) { }, |
6 | | - set [expr](val) { }, |
7 | | - async set [expr](val) { }, |
8 | | -}; |
9 | | - |
10 | | -// not keywords |
11 | | -get(); |
12 | | -set(foo); |
13 | | - |
14 | | ----------------------------------------------------- |
15 | | - |
16 | | -[ |
17 | | - ["keyword", "const"], |
18 | | - " obj ", |
19 | | - ["operator", "="], |
20 | | - ["punctuation", "{"], |
21 | | - |
22 | | - ["keyword", "get"], |
23 | | - ["function", "name"], |
24 | | - ["punctuation", "("], |
25 | | - ["punctuation", ")"], |
26 | | - ["punctuation", "{"], |
27 | | - ["keyword", "return"], |
28 | | - ["string", "'bar'"], |
29 | | - ["punctuation", ";"], |
30 | | - ["punctuation", "}"], |
31 | | - ["punctuation", ","], |
32 | | - |
33 | | - ["keyword", "get"], |
34 | | - ["punctuation", "["], |
35 | | - "expr", |
36 | | - ["punctuation", "]"], |
37 | | - ["punctuation", "("], |
38 | | - ["punctuation", ")"], |
39 | | - ["punctuation", "{"], |
40 | | - ["keyword", "return"], |
41 | | - ["string", "'bar'"], |
42 | | - ["punctuation", ";"], |
43 | | - ["punctuation", "}"], |
44 | | - ["punctuation", ","], |
45 | | - |
46 | | - ["keyword", "async"], |
47 | | - ["keyword", "get"], |
48 | | - ["function", "name"], |
49 | | - ["punctuation", "("], |
50 | | - ["punctuation", ")"], |
51 | | - ["punctuation", "{"], |
52 | | - ["keyword", "return"], |
53 | | - ["string", "'bar'"], |
54 | | - ["punctuation", ";"], |
55 | | - ["punctuation", "}"], |
56 | | - ["punctuation", ","], |
57 | | - |
58 | | - ["keyword", "set"], |
59 | | - ["function", "name"], |
60 | | - ["punctuation", "("], |
61 | | - ["parameter", [ |
62 | | - "val" |
63 | | - ]], |
64 | | - ["punctuation", ")"], |
65 | | - ["punctuation", "{"], |
66 | | - ["punctuation", "}"], |
67 | | - ["punctuation", ","], |
68 | | - |
69 | | - ["keyword", "set"], |
70 | | - ["punctuation", "["], |
71 | | - "expr", |
72 | | - ["punctuation", "]"], |
73 | | - ["punctuation", "("], |
74 | | - ["parameter", [ |
75 | | - "val" |
76 | | - ]], |
77 | | - ["punctuation", ")"], |
78 | | - ["punctuation", "{"], |
79 | | - ["punctuation", "}"], |
80 | | - ["punctuation", ","], |
81 | | - |
82 | | - ["keyword", "async"], |
83 | | - ["keyword", "set"], |
84 | | - ["punctuation", "["], |
85 | | - "expr", |
86 | | - ["punctuation", "]"], |
87 | | - ["punctuation", "("], |
88 | | - ["parameter", [ |
89 | | - "val" |
90 | | - ]], |
91 | | - ["punctuation", ")"], |
92 | | - ["punctuation", "{"], |
93 | | - ["punctuation", "}"], |
94 | | - ["punctuation", ","], |
95 | | - |
96 | | - ["punctuation", "}"], |
97 | | - ["punctuation", ";"], |
98 | | - |
99 | | - ["comment", "// not keywords"], |
100 | | - |
101 | | - ["function", "get"], |
102 | | - ["punctuation", "("], |
103 | | - ["punctuation", ")"], |
104 | | - ["punctuation", ";"], |
105 | | - |
106 | | - ["function", "set"], |
107 | | - ["punctuation", "("], |
108 | | - "foo", |
109 | | - ["punctuation", ")"], |
110 | | - ["punctuation", ";"] |
111 | | -] |
112 | | - |
113 | | ----------------------------------------------------- |
114 | | - |
115 | | -Checks for getters and setters. |
| 1 | +const obj = { |
| 2 | + get name() { return 'bar'; }, |
| 3 | + get [expr]() { return 'bar'; }, |
| 4 | + async get name() { return 'bar'; }, |
| 5 | + set name(val) { }, |
| 6 | + set [expr](val) { }, |
| 7 | + async set [expr](val) { }, |
| 8 | + get #x() { return #xValue; }, |
| 9 | +}; |
| 10 | + |
| 11 | +// not keywords |
| 12 | +get(); |
| 13 | +set(foo); |
| 14 | + |
| 15 | +---------------------------------------------------- |
| 16 | + |
| 17 | +[ |
| 18 | + ["keyword", "const"], |
| 19 | + " obj ", |
| 20 | + ["operator", "="], |
| 21 | + ["punctuation", "{"], |
| 22 | + |
| 23 | + ["keyword", "get"], |
| 24 | + ["function", "name"], |
| 25 | + ["punctuation", "("], |
| 26 | + ["punctuation", ")"], |
| 27 | + ["punctuation", "{"], |
| 28 | + ["keyword", "return"], |
| 29 | + ["string", "'bar'"], |
| 30 | + ["punctuation", ";"], |
| 31 | + ["punctuation", "}"], |
| 32 | + ["punctuation", ","], |
| 33 | + |
| 34 | + ["keyword", "get"], |
| 35 | + ["punctuation", "["], |
| 36 | + "expr", |
| 37 | + ["punctuation", "]"], |
| 38 | + ["punctuation", "("], |
| 39 | + ["punctuation", ")"], |
| 40 | + ["punctuation", "{"], |
| 41 | + ["keyword", "return"], |
| 42 | + ["string", "'bar'"], |
| 43 | + ["punctuation", ";"], |
| 44 | + ["punctuation", "}"], |
| 45 | + ["punctuation", ","], |
| 46 | + |
| 47 | + ["keyword", "async"], |
| 48 | + ["keyword", "get"], |
| 49 | + ["function", "name"], |
| 50 | + ["punctuation", "("], |
| 51 | + ["punctuation", ")"], |
| 52 | + ["punctuation", "{"], |
| 53 | + ["keyword", "return"], |
| 54 | + ["string", "'bar'"], |
| 55 | + ["punctuation", ";"], |
| 56 | + ["punctuation", "}"], |
| 57 | + ["punctuation", ","], |
| 58 | + |
| 59 | + ["keyword", "set"], |
| 60 | + ["function", "name"], |
| 61 | + ["punctuation", "("], |
| 62 | + ["parameter", ["val"]], |
| 63 | + ["punctuation", ")"], |
| 64 | + ["punctuation", "{"], |
| 65 | + ["punctuation", "}"], |
| 66 | + ["punctuation", ","], |
| 67 | + |
| 68 | + ["keyword", "set"], |
| 69 | + ["punctuation", "["], |
| 70 | + "expr", |
| 71 | + ["punctuation", "]"], |
| 72 | + ["punctuation", "("], |
| 73 | + ["parameter", ["val"]], |
| 74 | + ["punctuation", ")"], |
| 75 | + ["punctuation", "{"], |
| 76 | + ["punctuation", "}"], |
| 77 | + ["punctuation", ","], |
| 78 | + |
| 79 | + ["keyword", "async"], |
| 80 | + ["keyword", "set"], |
| 81 | + ["punctuation", "["], |
| 82 | + "expr", |
| 83 | + ["punctuation", "]"], |
| 84 | + ["punctuation", "("], |
| 85 | + ["parameter", ["val"]], |
| 86 | + ["punctuation", ")"], |
| 87 | + ["punctuation", "{"], |
| 88 | + ["punctuation", "}"], |
| 89 | + ["punctuation", ","], |
| 90 | + |
| 91 | + ["keyword", "get"], |
| 92 | + ["function", "#x"], |
| 93 | + ["punctuation", "("], |
| 94 | + ["punctuation", ")"], |
| 95 | + ["punctuation", "{"], |
| 96 | + ["keyword", "return"], |
| 97 | + " #xValue", |
| 98 | + ["punctuation", ";"], |
| 99 | + ["punctuation", "}"], |
| 100 | + ["punctuation", ","], |
| 101 | + |
| 102 | + ["punctuation", "}"], |
| 103 | + ["punctuation", ";"], |
| 104 | + |
| 105 | + ["comment", "// not keywords"], |
| 106 | + |
| 107 | + ["function", "get"], |
| 108 | + ["punctuation", "("], |
| 109 | + ["punctuation", ")"], |
| 110 | + ["punctuation", ";"], |
| 111 | + |
| 112 | + ["function", "set"], |
| 113 | + ["punctuation", "("], |
| 114 | + "foo", |
| 115 | + ["punctuation", ")"], |
| 116 | + ["punctuation", ";"] |
| 117 | +] |
| 118 | + |
| 119 | +---------------------------------------------------- |
| 120 | + |
| 121 | +Checks for getters and setters. |
0 commit comments