Skip to content

Commit 7d7cf16

Browse files
committed
Add tests
1 parent c93a48e commit 7d7cf16

File tree

3 files changed

+123
-3
lines changed

3 files changed

+123
-3
lines changed

jscomp/syntax/src/res_core.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,6 @@ let isJsxPropWellFormed p =
10371037
| Rbrace -> false
10381038
| _ ->
10391039
goToClosing Rbrace state;
1040-
(*print_string (Token.toString state.Parser.token);
1041-
print_newline ();*)
10421040
isPossibleAfterRbrace state.Parser.token)
10431041
(* arrived at k1=v1 *)
10441042
| token when isPossibleAfterEqual token -> (

jscomp/syntax/tests/parsing/recovery/expression/expected/jsx.res.txt

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,118 @@
44

55
1 │ let x = <div @ @@@ />
66
2 │
7+
3 │ let x = <Component prop1= prop2="value2" prop3=<C /> {...props} props=mo
8+
│ dule(Foo) />
79

810
I'm not sure what to parse here when looking at "@".
911

12+
13+
Syntax error!
14+
tests/parsing/recovery/expression/jsx.res:3:25
15+
16+
1 │ let x = <div @ @@@ />
17+
2 │
18+
3 │ let x = <Component prop1= prop2="value2" prop3=<C /> {...props} props=mo
19+
│ dule(Foo) />
20+
4 │
21+
5 │ let x = <Component ?prop0 prop1=[1,2,3] prop2= prop3={value3} prop4=?val
22+
│ ue4 />
23+
24+
I'm not sure what to parse here when looking at "=".
25+
26+
27+
Syntax error!
28+
tests/parsing/recovery/expression/jsx.res:5:46
29+
30+
3 │ let x = <Component prop1= prop2="value2" prop3=<C /> {...props} props=mo
31+
│ dule(Foo) />
32+
4 │
33+
5 │ let x = <Component ?prop0 prop1=[1,2,3] prop2= prop3={value3} prop4=?val
34+
│ ue4 />
35+
6 │
36+
7 │ let x = <Component prop1=value1 prop2="value2" prop3=<C /> {...props} pr
37+
│ ops4= />
38+
39+
I'm not sure what to parse here when looking at "=".
40+
41+
42+
Syntax error!
43+
tests/parsing/recovery/expression/jsx.res:7:77
44+
45+
5 │ let x = <Component ?prop0 prop1=[1,2,3] prop2= prop3={value3} prop4=?val
46+
│ ue4 />
47+
6 │
48+
7 │ let x = <Component prop1=value1 prop2="value2" prop3=<C /> {...props} pr
49+
│ ops4= />
50+
8 │
51+
9 │ let x = <Component className=Styles.something prop2={v => {f(v + 1)}} pr
52+
│ op1= prop3=1 />
53+
54+
I'm not sure what to parse here when looking at "=".
55+
56+
57+
Syntax error!
58+
tests/parsing/recovery/expression/jsx.res:9:76
59+
60+
7 │ let x = <Component prop1=value1 prop2="value2" prop3=<C /> {...props} p
61+
│ rops4= />
62+
8 │
63+
9 │ let x = <Component className=Styles.something prop2={v => {f(v + 1)}} p
64+
│ rop1= prop3=1 />
65+
10 │
66+
11 │ let x =
67+
68+
I'm not sure what to parse here when looking at "=".
69+
70+
71+
Syntax error!
72+
tests/parsing/recovery/expression/jsx.res:12:10
73+
74+
10 │
75+
11 │ let x =
76+
12 │ <a prop= href={j`https://$txExplererUrl/tx/$txHash`} target="_blank"
77+
│ rel="noopener noreferrer">
78+
13 │ {("View the transaction on " ++ txExplererUrl)->restr}
79+
14 │ </a>
80+
81+
I'm not sure what to parse here when looking at "=".
82+
1083
let x = ((div ~children:[] ())[@JSX ])
1184
[@@@ ]
12-
;;[%rescript.exprhole ][@@ ]
85+
;;[%rescript.exprhole ][@@ ]
86+
let x =
87+
((Component.createElement ~prop1:(([%rescript.exprhole ])
88+
[@res.namedArgLoc ]) ~prop2:(({js|value2|js})[@res.namedArgLoc ])
89+
~prop3:((C.createElement ~children:[] ())[@res.namedArgLoc ][@JSX ])
90+
~_spreadProps:((props)[@res.namedArgLoc ]) ~props:(((module Foo))
91+
[@res.namedArgLoc ]) ~children:[] ())
92+
[@JSX ])
93+
let x =
94+
((Component.createElement ?prop0:((prop0)[@res.namedArgLoc ])
95+
~prop1:(([|1;2;3|])[@res.namedArgLoc ]) ~prop2:(([%rescript.exprhole ])
96+
[@res.namedArgLoc ]) ~prop3:((value3)[@res.namedArgLoc ][@res.braces ])
97+
?prop4:((value4)[@res.namedArgLoc ]) ~children:[] ())
98+
[@JSX ])
99+
let x =
100+
((Component.createElement ~prop1:((value1)[@res.namedArgLoc ])
101+
~prop2:(({js|value2|js})[@res.namedArgLoc ])
102+
~prop3:((C.createElement ~children:[] ())[@res.namedArgLoc ][@JSX ])
103+
~_spreadProps:((props)[@res.namedArgLoc ])
104+
~props4:(([%rescript.exprhole ])[@res.namedArgLoc ]) ~children:[] ())
105+
[@JSX ])
106+
let x =
107+
((Component.createElement ~className:((Styles.something)
108+
[@res.namedArgLoc ]) ~prop2:((fun v -> ((f (v + 1))[@res.braces ]))
109+
[@res.namedArgLoc ][@res.braces ]) ~prop1:(([%rescript.exprhole ])
110+
[@res.namedArgLoc ]) ~prop3:((1)[@res.namedArgLoc ]) ~children:[] ())
111+
[@JSX ])
112+
let x =
113+
((a ~prop:(([%rescript.exprhole ])[@res.namedArgLoc ])
114+
~href:(({j|https://$txExplererUrl/tx/$txHash|j})
115+
[@res.namedArgLoc ][@res.braces ][@res.template ])
116+
~target:(({js|_blank|js})[@res.namedArgLoc ])
117+
~rel:(({js|noopener noreferrer|js})[@res.namedArgLoc ])
118+
~children:[((({js|View the transaction on |js} ^ txExplererUrl) |.
119+
restr)
120+
[@res.braces ])] ())
121+
[@JSX ])
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
11
let x = <div @ @@@ />
2+
3+
let x = <Component prop1= prop2="value2" prop3=<C /> {...props} props=module(Foo) />
4+
5+
let x = <Component ?prop0 prop1=[1,2,3] prop2= prop3={value3} prop4=?value4 />
6+
7+
let x = <Component prop1=value1 prop2="value2" prop3=<C /> {...props} props4= />
8+
9+
let x = <Component className=Styles.something prop2={v => {f(v + 1)}} prop1= prop3=1 />
10+
11+
let x =
12+
<a prop= href={j`https://$txExplererUrl/tx/$txHash`} target="_blank" rel="noopener noreferrer">
13+
{("View the transaction on " ++ txExplererUrl)->restr}
14+
</a>

0 commit comments

Comments
 (0)