Skip to content

Commit 4be5ea0

Browse files
authored
Format build_tests (#7079)
1 parent f5c780f commit 4be5ea0

File tree

95 files changed

+262
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+262
-294
lines changed

scripts/format.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ shopt -s extglob
44

55
dune build @fmt --auto-promote
66

7-
files=$(find runtime tests/tests -type f \( -name "*.res" -o -name "*.resi" \))
7+
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*")
88
./rescript format $files

scripts/format_check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ case "$(uname -s)" in
1717
fi
1818

1919
echo "Checking ReScript code formatting..."
20-
files=$(find runtime tests/tests -type f \( -name "*.res" -o -name "*.resi" \))
20+
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*")
2121
if ./rescript format -check $files; then
2222
printf "${successGreen}✅ ReScript code formatting ok.${reset}\n"
2323
else

tests/build_tests/cycle1/src/A.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include A
22

3-
let x = 42
3+
let x = 42

tests/build_tests/cycle1/src/A.resi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
let x : int
1+
let x: int

tests/build_tests/react_ppx/src/React.res

+54-83
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module Suspense = {
108108
* only way to safely have any type of state and be able to update it correctly.
109109
*/
110110
@module("react")
111-
external useState: ((unit => 'state)) => ('state, ('state => 'state) => unit) = "useState"
111+
external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState"
112112

113113
@module("react")
114114
external useReducer: (('state, 'action) => 'state, 'state) => ('state, 'action => unit) =
@@ -122,118 +122,95 @@ external useReducerWithMapState: (
122122
) => ('state, 'action => unit) = "useReducer"
123123

124124
@module("react")
125-
external useEffect: ((unit => option<unit => unit>)) => unit = "useEffect"
125+
external useEffect: (unit => option<unit => unit>) => unit = "useEffect"
126126
@module("react")
127-
external useEffect0: ((unit => option<unit => unit>), @as(json`[]`) _) => unit =
128-
"useEffect"
127+
external useEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit = "useEffect"
129128
@module("react")
130-
external useEffect1: ((unit => option<unit => unit>), array<'a>) => unit = "useEffect"
129+
external useEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useEffect"
131130
@module("react")
132-
external useEffect2: ((unit => option<unit => unit>), ('a, 'b)) => unit = "useEffect"
131+
external useEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useEffect"
133132
@module("react")
134-
external useEffect3: ((unit => option<unit => unit>), ('a, 'b, 'c)) => unit = "useEffect"
133+
external useEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useEffect"
135134
@module("react")
136-
external useEffect4: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd)) => unit =
137-
"useEffect"
135+
external useEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit = "useEffect"
138136
@module("react")
139-
external useEffect5: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd, 'e)) => unit =
140-
"useEffect"
137+
external useEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect"
141138
@module("react")
142-
external useEffect6: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit =
143-
"useEffect"
139+
external useEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect"
144140
@module("react")
145-
external useEffect7: (
146-
(unit => option<unit => unit>),
147-
('a, 'b, 'c, 'd, 'e, 'f, 'g),
148-
) => unit = "useEffect"
141+
external useEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit =
142+
"useEffect"
149143

150144
@module("react")
151-
external useLayoutEffect: ((unit => option<unit => unit>)) => unit = "useLayoutEffect"
145+
external useLayoutEffect: (unit => option<unit => unit>) => unit = "useLayoutEffect"
152146
@module("react")
153-
external useLayoutEffect0: ((unit => option<unit => unit>), @as(json`[]`) _) => unit =
147+
external useLayoutEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit =
154148
"useLayoutEffect"
155149
@module("react")
156-
external useLayoutEffect1: ((unit => option<unit => unit>), array<'a>) => unit =
157-
"useLayoutEffect"
150+
external useLayoutEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useLayoutEffect"
158151
@module("react")
159-
external useLayoutEffect2: ((unit => option<unit => unit>), ('a, 'b)) => unit =
160-
"useLayoutEffect"
152+
external useLayoutEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useLayoutEffect"
161153
@module("react")
162-
external useLayoutEffect3: ((unit => option<unit => unit>), ('a, 'b, 'c)) => unit =
163-
"useLayoutEffect"
154+
external useLayoutEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useLayoutEffect"
164155
@module("react")
165-
external useLayoutEffect4: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd)) => unit =
156+
external useLayoutEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit =
166157
"useLayoutEffect"
167158
@module("react")
168-
external useLayoutEffect5: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd, 'e)) => unit =
159+
external useLayoutEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit =
169160
"useLayoutEffect"
170161
@module("react")
171-
external useLayoutEffect6: (
172-
(unit => option<unit => unit>),
173-
('a, 'b, 'c, 'd, 'e, 'f),
174-
) => unit = "useLayoutEffect"
162+
external useLayoutEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit =
163+
"useLayoutEffect"
175164
@module("react")
176-
external useLayoutEffect7: (
177-
(unit => option<unit => unit>),
178-
('a, 'b, 'c, 'd, 'e, 'f, 'g),
179-
) => unit = "useLayoutEffect"
165+
external useLayoutEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit =
166+
"useLayoutEffect"
180167

181168
@module("react")
182-
external useMemo: ((unit => 'any)) => 'any = "useMemo"
169+
external useMemo: (unit => 'any) => 'any = "useMemo"
183170
@module("react")
184-
external useMemo0: ((unit => 'any), @as(json`[]`) _) => 'any = "useMemo"
171+
external useMemo0: (unit => 'any, @as(json`[]`) _) => 'any = "useMemo"
185172
@module("react")
186-
external useMemo1: ((unit => 'any), array<'a>) => 'any = "useMemo"
173+
external useMemo1: (unit => 'any, array<'a>) => 'any = "useMemo"
187174
@module("react")
188-
external useMemo2: ((unit => 'any), ('a, 'b)) => 'any = "useMemo"
175+
external useMemo2: (unit => 'any, ('a, 'b)) => 'any = "useMemo"
189176
@module("react")
190-
external useMemo3: ((unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo"
177+
external useMemo3: (unit => 'any, ('a, 'b, 'c)) => 'any = "useMemo"
191178
@module("react")
192-
external useMemo4: ((unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo"
179+
external useMemo4: (unit => 'any, ('a, 'b, 'c, 'd)) => 'any = "useMemo"
193180
@module("react")
194-
external useMemo5: ((unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo"
181+
external useMemo5: (unit => 'any, ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo"
195182
@module("react")
196-
external useMemo6: ((unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo"
183+
external useMemo6: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo"
197184
@module("react")
198-
external useMemo7: ((unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo"
185+
external useMemo7: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo"
199186

200187
/* This is used as return values */
201188
type callback<'input, 'output> = 'input => 'output
202189

203190
@module("react")
204-
external useCallback: (('input => 'output)) => callback<'input, 'output> = "useCallback"
205-
@module("react")
206-
external useCallback0: (
207-
('input => 'output),
208-
@as(json`[]`) _,
209-
) => callback<'input, 'output> = "useCallback"
191+
external useCallback: ('input => 'output) => callback<'input, 'output> = "useCallback"
210192
@module("react")
211-
external useCallback1: (('input => 'output), array<'a>) => callback<'input, 'output> =
193+
external useCallback0: ('input => 'output, @as(json`[]`) _) => callback<'input, 'output> =
212194
"useCallback"
213195
@module("react")
214-
external useCallback2: (('input => 'output), ('a, 'b)) => callback<'input, 'output> =
215-
"useCallback"
196+
external useCallback1: ('input => 'output, array<'a>) => callback<'input, 'output> = "useCallback"
197+
@module("react")
198+
external useCallback2: ('input => 'output, ('a, 'b)) => callback<'input, 'output> = "useCallback"
216199
@module("react")
217-
external useCallback3: (('input => 'output), ('a, 'b, 'c)) => callback<'input, 'output> =
200+
external useCallback3: ('input => 'output, ('a, 'b, 'c)) => callback<'input, 'output> =
218201
"useCallback"
219202
@module("react")
220-
external useCallback4: (
221-
('input => 'output),
222-
('a, 'b, 'c, 'd),
223-
) => callback<'input, 'output> = "useCallback"
203+
external useCallback4: ('input => 'output, ('a, 'b, 'c, 'd)) => callback<'input, 'output> =
204+
"useCallback"
224205
@module("react")
225-
external useCallback5: (
226-
('input => 'output),
227-
('a, 'b, 'c, 'd, 'e),
228-
) => callback<'input, 'output> = "useCallback"
206+
external useCallback5: ('input => 'output, ('a, 'b, 'c, 'd, 'e)) => callback<'input, 'output> =
207+
"useCallback"
229208
@module("react")
230-
external useCallback6: (
231-
('input => 'output),
232-
('a, 'b, 'c, 'd, 'e, 'f),
233-
) => callback<'input, 'output> = "useCallback"
209+
external useCallback6: ('input => 'output, ('a, 'b, 'c, 'd, 'e, 'f)) => callback<'input, 'output> =
210+
"useCallback"
234211
@module("react")
235212
external useCallback7: (
236-
('input => 'output),
213+
'input => 'output,
237214
('a, 'b, 'c, 'd, 'e, 'f, 'g),
238215
) => callback<'input, 'output> = "useCallback"
239216

@@ -245,56 +222,50 @@ external useContext: Context.t<'any> => 'any = "useContext"
245222
@module("react")
246223
external useImperativeHandle0: (
247224
Js.Nullable.t<Ref.t<'value>>,
248-
(unit => 'value),
225+
unit => 'value,
249226
@as(json`[]`) _,
250227
) => unit = "useImperativeHandle"
251228

252229
@module("react")
253-
external useImperativeHandle1: (
254-
Js.Nullable.t<Ref.t<'value>>,
255-
(unit => 'value),
256-
array<'a>,
257-
) => unit = "useImperativeHandle"
230+
external useImperativeHandle1: (Js.Nullable.t<Ref.t<'value>>, unit => 'value, array<'a>) => unit =
231+
"useImperativeHandle"
258232

259233
@module("react")
260-
external useImperativeHandle2: (
261-
Js.Nullable.t<Ref.t<'value>>,
262-
(unit => 'value),
263-
('a, 'b),
264-
) => unit = "useImperativeHandle"
234+
external useImperativeHandle2: (Js.Nullable.t<Ref.t<'value>>, unit => 'value, ('a, 'b)) => unit =
235+
"useImperativeHandle"
265236

266237
@module("react")
267238
external useImperativeHandle3: (
268239
Js.Nullable.t<Ref.t<'value>>,
269-
(unit => 'value),
240+
unit => 'value,
270241
('a, 'b, 'c),
271242
) => unit = "useImperativeHandle"
272243

273244
@module("react")
274245
external useImperativeHandle4: (
275246
Js.Nullable.t<Ref.t<'value>>,
276-
(unit => 'value),
247+
unit => 'value,
277248
('a, 'b, 'c, 'd),
278249
) => unit = "useImperativeHandle"
279250

280251
@module("react")
281252
external useImperativeHandle5: (
282253
Js.Nullable.t<Ref.t<'value>>,
283-
(unit => 'value),
254+
unit => 'value,
284255
('a, 'b, 'c, 'd, 'e),
285256
) => unit = "useImperativeHandle"
286257

287258
@module("react")
288259
external useImperativeHandle6: (
289260
Js.Nullable.t<Ref.t<'value>>,
290-
(unit => 'value),
261+
unit => 'value,
291262
('a, 'b, 'c, 'd, 'e, 'f),
292263
) => unit = "useImperativeHandle"
293264

294265
@module("react")
295266
external useImperativeHandle7: (
296267
Js.Nullable.t<Ref.t<'value>>,
297-
(unit => 'value),
268+
unit => 'value,
298269
('a, 'b, 'c, 'd, 'e, 'f, 'g),
299270
) => unit = "useImperativeHandle"
300271

tests/build_tests/react_ppx/src/gpr_3987_test.res

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ let makeContainer = text => {
2424

2525
/* This uncurried prop definition compiles */
2626
module Gpr3987ReproOk = {
27-
type props = {value: string, onChange: (. string, int) => unit}
27+
type props = {value: string, onChange: (string, int) => unit}
2828

2929
let make = (_props: props) => React.null
3030
}
3131

32-
let _ = <Gpr3987ReproOk value="test" onChange={(. _, _) => ()} />
32+
let _ = <Gpr3987ReproOk value="test" onChange={(_, _) => ()} />
3333

3434
/* Extracted type for the uncurried prop compiles as well */
3535
module Gpr3987ReproOk2 = {
36-
type onChange = (. string, int) => unit
36+
type onChange = (string, int) => unit
3737

3838
@react.component
3939
let make = (~value as _, ~onChange as _: onChange) => React.null
4040
}
4141

42-
let _ = <Gpr3987ReproOk2 value="test" onChange={(. _, _) => ()} />
42+
let _ = <Gpr3987ReproOk2 value="test" onChange={(_, _) => ()} />
4343

4444
/* Inline uncurried prop type causes an error */
4545
module Gpr3987ReproError = {
4646
@react.component
47-
let make = (~value as _: string, ~onChange as _: (. string, int) => unit) => React.null
47+
let make = (~value as _: string, ~onChange as _: (string, int) => unit) => React.null
4848
}
4949

50-
let _ = <Gpr3987ReproError value="test" onChange={(. _, _) => ()} />
50+
let _ = <Gpr3987ReproError value="test" onChange={(_, _) => ()} />

tests/build_tests/react_ppx/src/recursive_component_test.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
module Rec = {
99
@react.component
1010
let rec make = (~b) => {
11-
mm({b:b})
11+
mm({b: b})
1212
}
13-
and mm = (x) => make({b: ! x.b})
13+
and mm = x => make({b: !x.b})
1414
}

tests/build_tests/super_errors/expected/RecordInclusion.res.expected

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
We've found a bug for you!
33
/.../fixtures/RecordInclusion.res:3:5-5:1
44

5-
1 │ module M : {
6-
2 │ type t<'a, 'b, 'c> = {x:int, y:list<('a, 'b)>, z:int}
5+
1 │ module M: {
6+
2 │ type t<'a, 'b, 'c> = {x: int, y: list<('a, 'b)>, z: int}
77
3 │ } = {
8-
4 │  type t<'a, 'b, 'c> = {x:int, y:list<('a, 'c)>, z:int}
8+
4 │  type t<'a, 'b, 'c> = {x: int, y: list<('a, 'c)>, z: int}
99
5 │ }
1010
6 │
1111

@@ -15,8 +15,8 @@
1515
type t<'a, 'b, 'c> = {x: int, y: list<('a, 'c)>, z: int}
1616
is not included in
1717
type t<'a, 'b, 'c> = {x: int, y: list<('a, 'b)>, z: int}
18-
/.../fixtures/RecordInclusion.res:2:3-55:
18+
/.../fixtures/RecordInclusion.res:2:3-58:
1919
Expected declaration
20-
/.../fixtures/RecordInclusion.res:4:3-55:
20+
/.../fixtures/RecordInclusion.res:4:3-58:
2121
Actual declaration
2222
The types for field y are not equal.

tests/build_tests/super_errors/expected/UncurriedArgsNotApplied.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
We've found a bug for you!
33
/.../fixtures/UncurriedArgsNotApplied.res:3:15-21
44

5-
1 │ let apply = (fn: (. unit) => option<int>) => fn(. ())
5+
1 │ let apply = (fn: unit => option<int>) => fn()
66
2 │
77
3 │ let _ = apply(Some(1))
88
4 │

tests/build_tests/super_errors/expected/UntaggedImplIntf.res.expected

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
3 │ } = {
88
4 │  type t = | @as(null) A
99
5 │ }
10+
6 │
1011

1112
Signature mismatch:
1213
Modules do not match:

tests/build_tests/super_errors/expected/arity_mismatch.res.expected

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
We've found a bug for you!
33
/.../fixtures/arity_mismatch.res:2:21-27
44

5-
1 │ let makeVar = (. ~f, ()) => 34
6-
2 │ let makeVariables = makeVar(.~f=f => f)
5+
1 │ let makeVar = (~f, ()) => 34
6+
2 │ let makeVariables = makeVar(~f=f => f)
77
3 │
88

99
This function has type (~f: 'a => 'a, unit) => int

tests/build_tests/super_errors/expected/arity_mismatch2.res.expected

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
We've found a bug for you!
33
/.../fixtures/arity_mismatch2.res:2:21-27
44

5-
1 │ let makeVar = (. f, ()) => 34
6-
2 │ let makeVariables = makeVar(. 1, 2, 3)
5+
1 │ let makeVar = (f, ()) => 34
6+
2 │ let makeVariables = makeVar(1, 2, 3)
77
3 │
88

99
This function has type ('a, unit) => int

tests/build_tests/super_errors/expected/curried_expected.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1 │ let expectCurried = f => f(1) + 2
66
2 │
7-
3 │ let z1 = expectCurried((. x, y) => x+y)
7+
3 │ let z1 = expectCurried((x, y) => x + y)
88
4 │
99

1010
This function expected 1 argument, but got 2

tests/build_tests/super_errors/expected/dict_record_style_field_access.res.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
3 │ }
66
4 │
77
5 │ let x = stringDict.name
8+
6 │
89

910
Direct field access on a dict is not supported. Use Dict.get instead.

0 commit comments

Comments
 (0)