Skip to content

Commit 112297d

Browse files
committed
Use separate directory for ast mapping tests
1 parent 786edb7 commit 112297d

File tree

12 files changed

+112
-80
lines changed

12 files changed

+112
-80
lines changed

scripts/test_syntax.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ while read file; do
4343
done <temp/files.txt
4444

4545
# printing with ast conversion
46-
find syntax_tests/data/{printer,conversion} -name "*.res" -o -name "*.resi" -o -name "*.ml" -o -name "*.mli" >temp/files.txt
46+
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
4848
$DUNE_BIN_DIR/res_parser -test-ast-conversion $file &> $(exp $file) & maybeWait
4949
done <temp/files.txt

tests/syntax_tests/data/conversion/reason/expected/namedArgs.res.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,47 @@ let wizard = Wizard.make(
22
~spriteSheet=wizard,
33
~hp=999999999999999,
44
~mp=50,
5-
~coordinates=//~coordinates={x: 0., y:0. z: 0.},
6-
{x: 40, y: 100., z: 0.},
5+
//~coordinates={x: 0., y:0. z: 0.},
6+
~coordinates={x: 40, y: 100., z: 0.},
77
// /* c0 */ ~gpuCoordinates= /* c1 */ gpuBuffer[10] /* c2 */, // trailing
88
)
99

1010
apply(
11+
// above
1112
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
13+
// below
1214
~bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
15+
// here
1316
~cccccccccccccccccccccccccccccccc,
1417
)
1518

1619
applyOptional(
20+
// above
1721
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?,
22+
// below
1823
~bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb?,
24+
// here
1925
~cccccccccccccccccccccccccccccccc?,
2026
)
2127

2228
foo(
29+
// c0
2330
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: int,
31+
// c1
2432
~bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: int,
33+
// c2
2534
~cccccccccccccccccccccccccccccc: int,
2635
)
2736

2837
let f = (
2938
~isItemActive=?,
39+
// array((name, href))
3040
~headers: array<(string, string)>,
3141
~moduleName: string,
42+
// foo
3243
~x,
33-
~d: /* c1 */ e,
44+
// above
45+
/* c0 */ ~d: /* c1 */ e, // end
3446
~from as // does it work
3547
hometown,
3648
) => {
@@ -44,6 +56,7 @@ let make = (
4456
~theme: ColorTheme.t,
4557
~components: Mdx.Components.t,
4658
~sidebarState: (bool, (bool => bool) => unit),
59+
// (Sidebar, toggleSidebar) ... for toggling sidebar in mobile view
4760
~sidebar: React.element,
4861
~breadcrumbs: option<list<UrlPath.breadcrumb>>=?,
4962
~children,

tests/syntax_tests/data/printer/comments/expected/expr.res.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ let multiply = (/* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => {
218218
// test
219219
}
220220

221-
let multiply = (~x=/* c0 */ m1, ~y=/* c2 */ m2) => ()
221+
let multiply = (~x=/* c0 */ m1 /* c1 */, ~y=/* c2 */ m2 /* c3 */) => ()
222222

223-
let f = (~greeting, ~from as /* c2 */ /* c3 */ /* c4 */ hometown /* c5 */, ~x=?) => /* c7 */ ()
223+
let f = (
224+
/* c0 */ ~greeting /* c1 */,
225+
/* c2 */ ~from as /* c3 */ /* c4 */ hometown /* c5 */,
226+
/* c6 */ ~x=?,
227+
) => /* c7 */ ()
224228

225229
let multiply = (type /* c-2 */ t /* c-1 */, /* c0 */ m1 /* c1 */, /* c2 */ m2 /* c3 */) => ()
226230
let multiply = (

tests/syntax_tests/data/printer/comments/expected/jsx.res.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ module Cite = {
2424
/>
2525

2626
<A
27-
value=// comment1
28-
""
27+
// comment1
28+
value=""
2929
// comment2
3030
>
3131
<B /* comment3 */ />

tests/syntax_tests/data/printer/comments/expected/namedArgs.res.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,49 @@ let wizard = Wizard.make(
22
~spriteSheet=wizard,
33
~hp=999999999999999,
44
~mp=50,
5-
~coordinates=//~coordinates={x: 0., y:0. z: 0.},
6-
{x: 40, y: 100., z: 0.},
7-
~gpuCoordinates=/* c0 */ /* c1 */ gpuBuffer[10] /* c2 */, // trailing
5+
//~coordinates={x: 0., y:0. z: 0.},
6+
~coordinates={x: 40, y: 100., z: 0.},
7+
/* c0 */ ~gpuCoordinates=/* c1 */ gpuBuffer[10] /* c2 */, // trailing
88
)
99

1010
apply(
11+
// above
1112
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
13+
// below
1214
~bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
15+
// here
1316
~cccccccccccccccccccccccccccccccc,
1417
)
1518

1619
applyOptional(
20+
// above
1721
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?,
22+
// below
1823
~bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb?,
24+
// here
1925
~cccccccccccccccccccccccccccccccc?,
2026
)
2127

2228
foo(
29+
// c0
2330
~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: int,
31+
// c1
2432
~bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb: int,
33+
// c2
2534
~cccccccccccccccccccccccccccccc: int,
2635
)
2736

2837
let f = (
2938
~isItemActive=?,
39+
// array((name, href))
3040
~headers: array<(string, string)>,
3141
~moduleName: string,
42+
// foo
3243
~x,
33-
~d: /* c1 */ e,
34-
~from as // does it work
35-
hometown,
44+
// above
45+
/* c0 */ ~d: /* c1 */ e, // end
46+
// does it work
47+
~from as hometown,
3648
) => {
3749
let a = 1
3850
let b = 2
@@ -44,6 +56,7 @@ let make = (
4456
~theme: ColorTheme.t,
4557
~components: Mdx.Components.t,
4658
~sidebarState: (bool, (bool => bool) => unit),
59+
// (Sidebar, toggleSidebar) ... for toggling sidebar in mobile view
4760
~sidebar: React.element,
4861
~breadcrumbs: option<list<UrlPath.breadcrumb>>=?,
4962
~children,

tests/syntax_tests/data/printer/comments/expected/typexpr.res.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ type add = /* before */ (
4141
/* c2 */ int /* c3 */,
4242
) => /* before return */ int /* after */
4343
type add = /* before */ (
44-
~a: /* c0 */ int /* c1 */,
45-
~b: /* c2 */ int /* c3 */,
44+
/* c0 */ ~a: int /* c1 */,
45+
/* c2 */ ~b: int /* c3 */,
4646
) => /* before return */ int /* after */
4747
type multiply = /* before */ (
48-
~fn: /* c0 */ (
48+
/* c0 */ ~fn: (
4949
/* cinner0 */ int /* cinner1 */,
5050
/* cinner2 */ int /* cinner3 */,
5151
) => /* cx */ int /* c1 */,
52-
~b: /* c2 */ int /* c3 */,
52+
/* c2 */ ~b: int /* c3 */,
5353
) => int /* after */
5454
type make = (
5555
~activity: ActivityFlow_Activity.t,
@@ -58,15 +58,15 @@ type make = (
5858
~next: (string, string, array<string>) => unit,
5959
~hapticFeedback: unit => unit,
6060
~participants: Belt.Set.String.t,
61-
~openPhotoFeed: // here
61+
// here
6262

6363
// above
64-
/* c0 */ /* c1 */ (
65-
~feedId: /* c2 */ /* c3 */ option<string> /* c4 */,
64+
/* c0 */ ~openPhotoFeed: /* c1 */ (
65+
/* c2 */ ~feedId: /* c3 */ option<string> /* c4 */,
6666
/* c5 */ unit /* c6 */,
6767
) => /* c7 */ unit /* c8 */,
68-
~getAnother: // only provide this when it shows a random activity
69-
unit => unit=?,
68+
// only provide this when it shows a random activity
69+
~getAnother: unit => unit=?,
7070
) => React.element
7171

7272
//type f = /* c0 */ ~a: /* c1 */ int /* c2 */ => /* c3 */ int /* c4 */
@@ -81,10 +81,10 @@ type jsUser = /* before */ {
8181
} /* after */
8282

8383
external test: (
84-
~int: // comment 1
85-
int,
86-
~int: // comment 2
87-
int,
84+
// comment 1
85+
~int: int,
86+
// comment 2
87+
~int: int,
8888
) => unit = "test"
8989

9090
external another_test: (

tests/syntax_tests/data/printer/expr/expected/Uncurried.res.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ let () = ignore(3)
88

99
let foo = /* ddd */ x => x
1010

11-
let f = (~a) => a
11+
let f = (
12+
// comment
13+
~a,
14+
) => a

tests/syntax_tests/data/printer/expr/expected/UncurriedByDefault.res.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ let _ = setTimeout(() => {
4545
}, 100)
4646

4747
let _ = @att x => 34
48-
let _ = @res.async @att async x => 34
48+
let _ = @att async x => 34
4949
let _ = preserveAttr(@att x => 34)
50-
let _ = preserveAttr(@res.async @att async x => 34)
50+
let _ = preserveAttr(@att async x => 34)
5151

5252
let t0 = (type a b, l: list<a>, x: a) => list{x, ...l}
5353
let t1 = (type a b, l: list<a>, x: a) => list{x, ...l}
@@ -127,9 +127,9 @@ let _ = setTimeout(() => {
127127
}, 100)
128128

129129
let _ = @att x => 34
130-
let _ = @res.async @att async x => 34
130+
let _ = @att async x => 34
131131
let _ = preserveAttr(@att x => 34)
132-
let _ = preserveAttr(@res.async @att async x => 34)
132+
let _ = preserveAttr(@att async x => 34)
133133

134134
let t0 = (type a b, l: list<a>, x: a) => list{x, ...l}
135135
let t1 = (type a b, l: list<a>, x: a) => list{x, ...l}

tests/syntax_tests/data/printer/expr/expected/asyncAwait.res.txt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
let sequentialAwait =
2-
@res.async
3-
async () => {
4-
let result1 = await paused("first")
5-
nodeJsAssert.equal(result1, "first")
6-
7-
let result2 = await paused("second")
8-
nodeJsAssert.equal(result2, "second")
9-
}
1+
let sequentialAwait = async () => {
2+
let result1 = await paused("first")
3+
nodeJsAssert.equal(result1, "first")
4+
5+
let result2 = await paused("second")
6+
nodeJsAssert.equal(result2, "second")
7+
}
108

11-
let f = @res.async async () => ()
12-
let f = @res.async async () => ()
13-
let f = @res.async async f => f()
14-
let f = @res.async async (a, b) => a + b
15-
let f = @res.async async (a, b) => a + b
9+
let f = async () => ()
10+
let f = async () => ()
11+
let f = async f => f()
12+
let f = async (a, b) => a + b
13+
let f = async (a, b) => a + b
1614

1715
let maybeSomeValue = switch await fetchData(url) {
1816
| data => Some(data)
@@ -34,7 +32,9 @@ user.data = await fetch()
3432
let inBinaryExpression = await x->Js.Promise.resolve + 1
3533
let inBinaryExpression = await x->Js.Promise.resolve + await y->Js.Promise.resolve
3634

37-
let withCallback = @res.async async () => @res.async async x => await x->Js.promise.resolve + 1
35+
let withCallback = async () => {
36+
async x => await x->Js.promise.resolve + 1
37+
}
3838

3939
let () = await (await fetch(url))->(await resolve)
4040

@@ -47,7 +47,7 @@ let _ = await f
4747
let _ = await %extension
4848
let _ = await "test"
4949
let _ = await ((a, b) => a + b)
50-
let _ = await (@res.async async (a, b) => a + b)
50+
let _ = await (async (a, b) => a + b)
5151
let _ = await (
5252
switch x {
5353
| A => ()
@@ -102,16 +102,16 @@ let _ = await {
102102
Js.Promise.resolve(x)
103103
}
104104

105-
let f1 = @res.async async (~x, ~y) => x + y
106-
let f2 = @res.async async (@foo ~x, @bar ~y) => x + y
107-
let f3 = @res.async @foo async (~x as @bar @zz z, ~y) => x + y
108-
let f4 = @res.async async x => x
109-
let f5 = @res.async async x => @res.async async y => 3
110-
let f6 = @res.async async (~x1, ~x2) => @res.async async y => 3
111-
let f7 = @res.async async x => @res.async async (~y) => 3
112-
let f8 = @res.async async (~x1, ~x2) => @res.async async (~y) => 3
113-
let f9 = x => @res.async async (~y) => 3
114-
let f10 = x => @res.async async y => 3
105+
let f1 = async (~x, ~y) => x + y
106+
let f2 = async (@foo ~x, @bar ~y) => x + y
107+
let f3 = @foo async (~x as @bar @zz z, ~y) => x + y
108+
let f4 = async x => x
109+
let f5 = async x => async y => 3
110+
let f6 = async (~x1, ~x2) => async y => 3
111+
let f7 = async x => async (~y) => 3
112+
let f8 = async (~x1, ~x2) => async (~y) => 3
113+
let f9 = x => async (~y) => 3
114+
let f10 = x => async y => 3
115115
let f11 = (~x) => (~y) => 3
116116

117117
let f12 = @a (@b x) => 3
@@ -122,7 +122,7 @@ let aw = @foo (server->start)->foo
122122
let aw = (await (3 ** 4))->foo
123123

124124
let foo = async(~a=34)
125-
let bar = @res.async async (~a) => a + 1
125+
let bar = async (~a) => a + 1
126126

127127
let a1 = (await 3) + (await 4)
128128
let a2 = (await 3) ** (await 4)
@@ -141,12 +141,12 @@ let c3 = x => @foo y => x + y
141141
type t1 = int => string => bool
142142
type t2 = (int, string) => bool
143143

144-
let f = async (type a, @res.async ()) => {
144+
let f = async (type a, ()) => {
145145
await Js.Promise.resolve()
146146
}
147147

148-
let attr1 = @res.async @a async x => x + 1
149-
let attr2 = @a async (type a, @res.async ()) => (type b c, x) => 3
150-
let attr3 = @a (type a, ()) => async (type b c, @res.async x) => 3
151-
let attr4 = @a (type a, ()) => @b async (type b c, @res.async x) => 3
152-
let attr5: int => promise<int> = @a @b async (type a b c, @res.async ()) => (x: a) => x
148+
let attr1 = @a async x => x + 1
149+
let attr2 = @a async (type a, ()) => (type b c, x) => 3
150+
let attr3 = @a (type a, ()) => async (type b c, x) => 3
151+
let attr4 = @a (type a, ()) => @b async (type b c, x) => 3
152+
let attr5: int => promise<int> = @a @b async (type a b c, ()) => (x: a) => x

0 commit comments

Comments
 (0)