Skip to content

Commit e4e4bec

Browse files
committed
JS: Add failing parser tests.
1 parent e931898 commit e4e4bec

2 files changed

Lines changed: 159 additions & 138 deletions

File tree

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
({x = 1}) => x;
1+
({x = 1}) => x;
2+
3+
const example = ({ set = {}, unset = [] }, replacements) => {
4+
return { set, unset };
5+
};
6+
({ get = {}, set = [] }) => ({ get, set });
7+
async ({ get = 1, set = 2 } = {}) => ({ get, set });
8+
9+
let get, set;
10+
({ get = 1, set = 2 } = {});
11+
function defaults({ get = 1, set = 2 }) {
12+
return { get, set };
13+
}
14+
15+
({
16+
get value() { return get; },
17+
set value(v) { set = v; },
18+
get,
19+
set
20+
});
21+
({ get() {}, set(value) {} });

‎javascript/extractor/tests/es2015/output/trap/property_pattern_with_default.js.trap‎

Lines changed: 138 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -9,146 +9,147 @@ hasLocation(#10000,#10002)
99
#20000=@"global_scope"
1010
scopes(#20000,0)
1111
#20001=@"script;{#10000},1,1"
12-
#20002=*
13-
lines(#20002,#20001,"({x = 1}) => x;","")
14-
#20003=@"loc,{#10000},1,1,1,15"
15-
locations_default(#20003,#10000,1,1,1,15)
16-
hasLocation(#20002,#20003)
17-
numlines(#20001,1,1,0)
18-
#20004=*
19-
tokeninfo(#20004,8,#20001,0,"(")
20-
#20005=@"loc,{#10000},1,1,1,1"
21-
locations_default(#20005,#10000,1,1,1,1)
22-
hasLocation(#20004,#20005)
23-
#20006=*
24-
tokeninfo(#20006,8,#20001,1,"{")
25-
#20007=@"loc,{#10000},1,2,1,2"
26-
locations_default(#20007,#10000,1,2,1,2)
27-
hasLocation(#20006,#20007)
28-
#20008=*
29-
tokeninfo(#20008,6,#20001,2,"x")
30-
#20009=@"loc,{#10000},1,3,1,3"
31-
locations_default(#20009,#10000,1,3,1,3)
32-
hasLocation(#20008,#20009)
33-
#20010=*
34-
tokeninfo(#20010,8,#20001,3,"=")
35-
#20011=@"loc,{#10000},1,5,1,5"
36-
locations_default(#20011,#10000,1,5,1,5)
37-
hasLocation(#20010,#20011)
38-
#20012=*
39-
tokeninfo(#20012,3,#20001,4,"1")
40-
#20013=@"loc,{#10000},1,7,1,7"
41-
locations_default(#20013,#10000,1,7,1,7)
42-
hasLocation(#20012,#20013)
43-
#20014=*
44-
tokeninfo(#20014,8,#20001,5,"}")
45-
#20015=@"loc,{#10000},1,8,1,8"
46-
locations_default(#20015,#10000,1,8,1,8)
47-
hasLocation(#20014,#20015)
48-
#20016=*
49-
tokeninfo(#20016,8,#20001,6,")")
50-
#20017=@"loc,{#10000},1,9,1,9"
51-
locations_default(#20017,#10000,1,9,1,9)
52-
hasLocation(#20016,#20017)
53-
#20018=*
54-
tokeninfo(#20018,8,#20001,7,"=>")
55-
#20019=@"loc,{#10000},1,11,1,12"
56-
locations_default(#20019,#10000,1,11,1,12)
57-
hasLocation(#20018,#20019)
58-
#20020=*
59-
tokeninfo(#20020,6,#20001,8,"x")
60-
#20021=@"loc,{#10000},1,14,1,14"
61-
locations_default(#20021,#10000,1,14,1,14)
62-
hasLocation(#20020,#20021)
63-
#20022=*
64-
tokeninfo(#20022,8,#20001,9,";")
65-
#20023=@"loc,{#10000},1,15,1,15"
66-
locations_default(#20023,#10000,1,15,1,15)
67-
hasLocation(#20022,#20023)
68-
#20024=*
69-
tokeninfo(#20024,0,#20001,10,"")
70-
#20025=@"loc,{#10000},1,16,1,15"
71-
locations_default(#20025,#10000,1,16,1,15)
72-
hasLocation(#20024,#20025)
7312
toplevels(#20001,0)
74-
hasLocation(#20001,#20003)
75-
#20026=@"var;{this};{#20000}"
76-
variables(#20026,"this",#20000)
13+
#20002=@"loc,{#10000},1,1,1,1"
14+
locations_default(#20002,#10000,1,1,1,1)
15+
hasLocation(#20001,#20002)
16+
#20003=*
17+
js_parse_errors(#20003,#20001,"Error: Unexpected token","const example = ({ set = {}, unset = [] }, replacements) => {
18+
")
19+
#20004=@"loc,{#10000},3,24,3,24"
20+
locations_default(#20004,#10000,3,24,3,24)
21+
hasLocation(#20003,#20004)
22+
#20005=*
23+
lines(#20005,#20001,"({x = 1}) => x;","
24+
")
25+
#20006=@"loc,{#10000},1,1,1,15"
26+
locations_default(#20006,#10000,1,1,1,15)
27+
hasLocation(#20005,#20006)
28+
#20007=*
29+
lines(#20007,#20001,"","
30+
")
31+
#20008=@"loc,{#10000},2,1,2,0"
32+
locations_default(#20008,#10000,2,1,2,0)
33+
hasLocation(#20007,#20008)
34+
#20009=*
35+
lines(#20009,#20001,"const example = ({ set = {}, unset = [] }, replacements) => {","
36+
")
37+
#20010=@"loc,{#10000},3,1,3,61"
38+
locations_default(#20010,#10000,3,1,3,61)
39+
hasLocation(#20009,#20010)
40+
#20011=*
41+
lines(#20011,#20001," return { set, unset };","
42+
")
43+
#20012=@"loc,{#10000},4,1,4,24"
44+
locations_default(#20012,#10000,4,1,4,24)
45+
hasLocation(#20011,#20012)
46+
indentation(#10000,4," ",2)
47+
#20013=*
48+
lines(#20013,#20001,"};","
49+
")
50+
#20014=@"loc,{#10000},5,1,5,2"
51+
locations_default(#20014,#10000,5,1,5,2)
52+
hasLocation(#20013,#20014)
53+
#20015=*
54+
lines(#20015,#20001,"({ get = {}, set = [] }) => ({ get, set });","
55+
")
56+
#20016=@"loc,{#10000},6,1,6,43"
57+
locations_default(#20016,#10000,6,1,6,43)
58+
hasLocation(#20015,#20016)
59+
#20017=*
60+
lines(#20017,#20001,"async ({ get = 1, set = 2 } = {}) => ({ get, set });","
61+
")
62+
#20018=@"loc,{#10000},7,1,7,52"
63+
locations_default(#20018,#10000,7,1,7,52)
64+
hasLocation(#20017,#20018)
65+
#20019=*
66+
lines(#20019,#20001,"","
67+
")
68+
#20020=@"loc,{#10000},8,1,8,0"
69+
locations_default(#20020,#10000,8,1,8,0)
70+
hasLocation(#20019,#20020)
71+
#20021=*
72+
lines(#20021,#20001,"let get, set;","
73+
")
74+
#20022=@"loc,{#10000},9,1,9,13"
75+
locations_default(#20022,#10000,9,1,9,13)
76+
hasLocation(#20021,#20022)
77+
#20023=*
78+
lines(#20023,#20001,"({ get = 1, set = 2 } = {});","
79+
")
80+
#20024=@"loc,{#10000},10,1,10,28"
81+
locations_default(#20024,#10000,10,1,10,28)
82+
hasLocation(#20023,#20024)
83+
#20025=*
84+
lines(#20025,#20001,"function defaults({ get = 1, set = 2 }) {","
85+
")
86+
#20026=@"loc,{#10000},11,1,11,41"
87+
locations_default(#20026,#10000,11,1,11,41)
88+
hasLocation(#20025,#20026)
7789
#20027=*
78-
stmts(#20027,2,#20001,0,"({x = 1}) => x;")
79-
hasLocation(#20027,#20003)
80-
stmt_containers(#20027,#20001)
81-
#20028=*
82-
exprs(#20028,65,#20027,0,"({x = 1}) => x")
83-
#20029=@"loc,{#10000},1,1,1,14"
84-
locations_default(#20029,#10000,1,1,1,14)
85-
hasLocation(#20028,#20029)
86-
enclosing_stmt(#20028,#20027)
87-
expr_containers(#20028,#20001)
88-
#20030=*
89-
scopes(#20030,1)
90-
scopenodes(#20028,#20030)
91-
scopenesting(#20030,#20000)
92-
#20031=@"var;{x};{#20030}"
93-
variables(#20031,"x",#20030)
94-
#20032=*
95-
exprs(#20032,68,#20028,0,"{x = 1}")
96-
#20033=@"loc,{#10000},1,2,1,8"
97-
locations_default(#20033,#10000,1,2,1,8)
98-
hasLocation(#20032,#20033)
99-
expr_containers(#20032,#20028)
100-
#20034=*
101-
properties(#20034,#20032,0,0,"x = 1")
102-
#20035=@"loc,{#10000},1,3,1,7"
103-
locations_default(#20035,#10000,1,3,1,7)
104-
hasLocation(#20034,#20035)
105-
#20036=*
106-
exprs(#20036,0,#20034,0,"x")
107-
hasLocation(#20036,#20009)
108-
expr_containers(#20036,#20028)
109-
literals("x","x",#20036)
90+
lines(#20027,#20001," return { get, set };","
91+
")
92+
#20028=@"loc,{#10000},12,1,12,22"
93+
locations_default(#20028,#10000,12,1,12,22)
94+
hasLocation(#20027,#20028)
95+
indentation(#10000,12," ",2)
96+
#20029=*
97+
lines(#20029,#20001,"}","
98+
")
99+
#20030=@"loc,{#10000},13,1,13,1"
100+
locations_default(#20030,#10000,13,1,13,1)
101+
hasLocation(#20029,#20030)
102+
#20031=*
103+
lines(#20031,#20001,"","
104+
")
105+
#20032=@"loc,{#10000},14,1,14,0"
106+
locations_default(#20032,#10000,14,1,14,0)
107+
hasLocation(#20031,#20032)
108+
#20033=*
109+
lines(#20033,#20001,"({","
110+
")
111+
#20034=@"loc,{#10000},15,1,15,2"
112+
locations_default(#20034,#10000,15,1,15,2)
113+
hasLocation(#20033,#20034)
114+
#20035=*
115+
lines(#20035,#20001," get value() { return get; },","
116+
")
117+
#20036=@"loc,{#10000},16,1,16,30"
118+
locations_default(#20036,#10000,16,1,16,30)
119+
hasLocation(#20035,#20036)
120+
indentation(#10000,16," ",2)
110121
#20037=*
111-
exprs(#20037,78,#20034,1,"x")
112-
hasLocation(#20037,#20009)
113-
expr_containers(#20037,#20028)
114-
literals("x","x",#20037)
115-
decl(#20037,#20031)
116-
#20038=*
117-
exprs(#20038,3,#20034,2,"1")
118-
hasLocation(#20038,#20013)
119-
expr_containers(#20038,#20028)
120-
literals("1","1",#20038)
122+
lines(#20037,#20001," set value(v) { set = v; },","
123+
")
124+
#20038=@"loc,{#10000},17,1,17,28"
125+
locations_default(#20038,#10000,17,1,17,28)
126+
hasLocation(#20037,#20038)
127+
indentation(#10000,17," ",2)
121128
#20039=*
122-
exprs(#20039,79,#20028,-2,"x")
123-
hasLocation(#20039,#20021)
124-
expr_containers(#20039,#20028)
125-
literals("x","x",#20039)
126-
bind(#20039,#20031)
127-
#20040=*
128-
entry_cfg_node(#20040,#20001)
129-
#20041=@"loc,{#10000},1,1,1,0"
130-
locations_default(#20041,#10000,1,1,1,0)
131-
hasLocation(#20040,#20041)
132-
#20042=*
133-
exit_cfg_node(#20042,#20001)
134-
hasLocation(#20042,#20025)
135-
successor(#20027,#20028)
136-
successor(#20028,#20042)
129+
lines(#20039,#20001," get,","
130+
")
131+
#20040=@"loc,{#10000},18,1,18,6"
132+
locations_default(#20040,#10000,18,1,18,6)
133+
hasLocation(#20039,#20040)
134+
indentation(#10000,18," ",2)
135+
#20041=*
136+
lines(#20041,#20001," set","
137+
")
138+
#20042=@"loc,{#10000},19,1,19,5"
139+
locations_default(#20042,#10000,19,1,19,5)
140+
hasLocation(#20041,#20042)
141+
indentation(#10000,19," ",2)
137142
#20043=*
138-
entry_cfg_node(#20043,#20028)
139-
hasLocation(#20043,#20041)
140-
#20044=*
141-
exit_cfg_node(#20044,#20028)
142-
#20045=@"loc,{#10000},1,15,1,14"
143-
locations_default(#20045,#10000,1,15,1,14)
144-
hasLocation(#20044,#20045)
145-
successor(#20039,#20044)
146-
successor(#20032,#20036)
147-
successor(#20038,#20034)
148-
successor(#20037,#20038)
149-
successor(#20036,#20037)
150-
successor(#20034,#20039)
151-
successor(#20043,#20032)
152-
successor(#20040,#20027)
153-
numlines(#10000,1,1,0)
143+
lines(#20043,#20001,"});","
144+
")
145+
#20044=@"loc,{#10000},20,1,20,3"
146+
locations_default(#20044,#10000,20,1,20,3)
147+
hasLocation(#20043,#20044)
148+
#20045=*
149+
lines(#20045,#20001,"({ get() {}, set(value) {} });","")
150+
#20046=@"loc,{#10000},21,1,21,30"
151+
locations_default(#20046,#10000,21,1,21,30)
152+
hasLocation(#20045,#20046)
153+
numlines(#20001,21,0,0)
154+
numlines(#10000,21,0,0)
154155
filetype(#10000,"javascript")

0 commit comments

Comments
 (0)