Skip to content

Commit c6d9537

Browse files
committed
Add new test cases
1 parent 112297d commit c6d9537

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

scripts/test_syntax.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ done <temp/files.txt
4545
# printing with ast conversion
4646
find syntax_tests/data/ast-mapping -name "*.res" -o -name "*.resi" -o -name "*.ml" -o -name "*.mli" >temp/files.txt
4747
while read file; do
48-
$DUNE_BIN_DIR/res_parser -test-ast-conversion $file &> $(exp $file) & maybeWait
48+
$DUNE_BIN_DIR/res_parser -test-ast-conversion -jsx-version 4 -jsx-mode "automatic" $file &> $(exp $file) & maybeWait
4949
done <temp/files.txt
5050

5151
# printing with ppx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
let emptyUnary = <input />
2+
3+
let emptyNonunary = <div></div>
4+
5+
let emptyUnaryWithAttributes = <input type_="text" />
6+
7+
let emptyNonunaryWithAttributes = <div className="container"></div>
8+
9+
let elementWithChildren = <div>
10+
<h1>{React.string("Hi")}</h1>
11+
<p>{React.string("Hello")}</p>
12+
</div>
13+
14+
let elementWithChildrenAndAttributes = <div className="container">
15+
<h1>{React.string("Hi")}</h1>
16+
<p>{React.string("Hello")}</p>
17+
</div>
18+
19+
let elementWithConditionalChildren = <div>
20+
{if true {
21+
<h1>{React.string("Hi")}</h1>
22+
} else {
23+
React.null
24+
}}
25+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
let empty = <></>
2+
3+
let fragmentWithBracedExpresssion = <>{React.int(1 + 2)}</>
4+
5+
let fragmentWithJSXElements = <>
6+
<h1>{React.string("Hi")}</h1>
7+
<p>{React.string("Hello")}</p>
8+
</>
9+
10+
let nestedFragments = <>
11+
<h1>{React.string("Hi")}</h1>
12+
<p>{React.string("Hello")}</p>
13+
<>{React.string("Bye")}</>
14+
</>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
let emptyUnary = ReactDOM.jsx("input", {})
2+
3+
let emptyNonunary = ReactDOM.jsx("div", {})
4+
5+
let emptyUnaryWithAttributes = ReactDOM.jsx("input", {type_: "text"})
6+
7+
let emptyNonunaryWithAttributes = ReactDOM.jsx("div", {className: "container"})
8+
9+
let elementWithChildren = ReactDOM.jsxs(
10+
"div",
11+
{
12+
children: React.array([
13+
ReactDOM.jsx("h1", {children: ?ReactDOM.someElement({React.string("Hi")})}),
14+
ReactDOM.jsx("p", {children: ?ReactDOM.someElement({React.string("Hello")})}),
15+
]),
16+
},
17+
)
18+
19+
let elementWithChildrenAndAttributes = ReactDOM.jsxs(
20+
"div",
21+
{
22+
className: "container",
23+
children: React.array([
24+
ReactDOM.jsx("h1", {children: ?ReactDOM.someElement({React.string("Hi")})}),
25+
ReactDOM.jsx("p", {children: ?ReactDOM.someElement({React.string("Hello")})}),
26+
]),
27+
},
28+
)
29+
30+
let elementWithConditionalChildren = ReactDOM.jsx(
31+
"div",
32+
{
33+
children: ?ReactDOM.someElement({
34+
if true {
35+
ReactDOM.jsx("h1", {children: ?ReactDOM.someElement({React.string("Hi")})})
36+
} else {
37+
React.null
38+
}
39+
}),
40+
},
41+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let empty = React.jsx(React.jsxFragment, {})
2+
3+
let fragmentWithBracedExpresssion = React.jsx(React.jsxFragment, {children: {React.int(1 + 2)}})
4+
5+
let fragmentWithJSXElements = React.jsxs(
6+
React.jsxFragment,
7+
{
8+
children: React.array([
9+
ReactDOM.jsx("h1", {children: ?ReactDOM.someElement({React.string("Hi")})}),
10+
ReactDOM.jsx("p", {children: ?ReactDOM.someElement({React.string("Hello")})}),
11+
]),
12+
},
13+
)
14+
15+
let nestedFragments = React.jsxs(
16+
React.jsxFragment,
17+
{
18+
children: React.array([
19+
ReactDOM.jsx("h1", {children: ?ReactDOM.someElement({React.string("Hi")})}),
20+
ReactDOM.jsx("p", {children: ?ReactDOM.someElement({React.string("Hello")})}),
21+
React.jsx(React.jsxFragment, {children: {React.string("Bye")}}),
22+
]),
23+
},
24+
)

0 commit comments

Comments
 (0)