Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format build_tests #7079

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ shopt -s extglob

dune build @fmt --auto-promote

files=$(find runtime tests/tests -type f \( -name "*.res" -o -name "*.resi" \))
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*")
./rescript format $files
2 changes: 1 addition & 1 deletion scripts/format_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case "$(uname -s)" in
fi

echo "Checking ReScript code formatting..."
files=$(find runtime tests/tests -type f \( -name "*.res" -o -name "*.resi" \))
files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*")
if ./rescript format -check $files; then
printf "${successGreen}✅ ReScript code formatting ok.${reset}\n"
else
Expand Down
2 changes: 1 addition & 1 deletion tests/build_tests/cycle1/src/A.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include A

let x = 42
let x = 42
2 changes: 1 addition & 1 deletion tests/build_tests/cycle1/src/A.resi
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let x : int
let x: int
137 changes: 54 additions & 83 deletions tests/build_tests/react_ppx/src/React.res
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module Suspense = {
* only way to safely have any type of state and be able to update it correctly.
*/
@module("react")
external useState: ((unit => 'state)) => ('state, ('state => 'state) => unit) = "useState"
external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState"

@module("react")
external useReducer: (('state, 'action) => 'state, 'state) => ('state, 'action => unit) =
Expand All @@ -122,118 +122,95 @@ external useReducerWithMapState: (
) => ('state, 'action => unit) = "useReducer"

@module("react")
external useEffect: ((unit => option<unit => unit>)) => unit = "useEffect"
external useEffect: (unit => option<unit => unit>) => unit = "useEffect"
@module("react")
external useEffect0: ((unit => option<unit => unit>), @as(json`[]`) _) => unit =
"useEffect"
external useEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit = "useEffect"
@module("react")
external useEffect1: ((unit => option<unit => unit>), array<'a>) => unit = "useEffect"
external useEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useEffect"
@module("react")
external useEffect2: ((unit => option<unit => unit>), ('a, 'b)) => unit = "useEffect"
external useEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useEffect"
@module("react")
external useEffect3: ((unit => option<unit => unit>), ('a, 'b, 'c)) => unit = "useEffect"
external useEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useEffect"
@module("react")
external useEffect4: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd)) => unit =
"useEffect"
external useEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit = "useEffect"
@module("react")
external useEffect5: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd, 'e)) => unit =
"useEffect"
external useEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit = "useEffect"
@module("react")
external useEffect6: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd, 'e, 'f)) => unit =
"useEffect"
external useEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit = "useEffect"
@module("react")
external useEffect7: (
(unit => option<unit => unit>),
('a, 'b, 'c, 'd, 'e, 'f, 'g),
) => unit = "useEffect"
external useEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit =
"useEffect"

@module("react")
external useLayoutEffect: ((unit => option<unit => unit>)) => unit = "useLayoutEffect"
external useLayoutEffect: (unit => option<unit => unit>) => unit = "useLayoutEffect"
@module("react")
external useLayoutEffect0: ((unit => option<unit => unit>), @as(json`[]`) _) => unit =
external useLayoutEffect0: (unit => option<unit => unit>, @as(json`[]`) _) => unit =
"useLayoutEffect"
@module("react")
external useLayoutEffect1: ((unit => option<unit => unit>), array<'a>) => unit =
"useLayoutEffect"
external useLayoutEffect1: (unit => option<unit => unit>, array<'a>) => unit = "useLayoutEffect"
@module("react")
external useLayoutEffect2: ((unit => option<unit => unit>), ('a, 'b)) => unit =
"useLayoutEffect"
external useLayoutEffect2: (unit => option<unit => unit>, ('a, 'b)) => unit = "useLayoutEffect"
@module("react")
external useLayoutEffect3: ((unit => option<unit => unit>), ('a, 'b, 'c)) => unit =
"useLayoutEffect"
external useLayoutEffect3: (unit => option<unit => unit>, ('a, 'b, 'c)) => unit = "useLayoutEffect"
@module("react")
external useLayoutEffect4: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd)) => unit =
external useLayoutEffect4: (unit => option<unit => unit>, ('a, 'b, 'c, 'd)) => unit =
"useLayoutEffect"
@module("react")
external useLayoutEffect5: ((unit => option<unit => unit>), ('a, 'b, 'c, 'd, 'e)) => unit =
external useLayoutEffect5: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e)) => unit =
"useLayoutEffect"
@module("react")
external useLayoutEffect6: (
(unit => option<unit => unit>),
('a, 'b, 'c, 'd, 'e, 'f),
) => unit = "useLayoutEffect"
external useLayoutEffect6: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f)) => unit =
"useLayoutEffect"
@module("react")
external useLayoutEffect7: (
(unit => option<unit => unit>),
('a, 'b, 'c, 'd, 'e, 'f, 'g),
) => unit = "useLayoutEffect"
external useLayoutEffect7: (unit => option<unit => unit>, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => unit =
"useLayoutEffect"

@module("react")
external useMemo: ((unit => 'any)) => 'any = "useMemo"
external useMemo: (unit => 'any) => 'any = "useMemo"
@module("react")
external useMemo0: ((unit => 'any), @as(json`[]`) _) => 'any = "useMemo"
external useMemo0: (unit => 'any, @as(json`[]`) _) => 'any = "useMemo"
@module("react")
external useMemo1: ((unit => 'any), array<'a>) => 'any = "useMemo"
external useMemo1: (unit => 'any, array<'a>) => 'any = "useMemo"
@module("react")
external useMemo2: ((unit => 'any), ('a, 'b)) => 'any = "useMemo"
external useMemo2: (unit => 'any, ('a, 'b)) => 'any = "useMemo"
@module("react")
external useMemo3: ((unit => 'any), ('a, 'b, 'c)) => 'any = "useMemo"
external useMemo3: (unit => 'any, ('a, 'b, 'c)) => 'any = "useMemo"
@module("react")
external useMemo4: ((unit => 'any), ('a, 'b, 'c, 'd)) => 'any = "useMemo"
external useMemo4: (unit => 'any, ('a, 'b, 'c, 'd)) => 'any = "useMemo"
@module("react")
external useMemo5: ((unit => 'any), ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo"
external useMemo5: (unit => 'any, ('a, 'b, 'c, 'd, 'e)) => 'any = "useMemo"
@module("react")
external useMemo6: ((unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo"
external useMemo6: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f)) => 'any = "useMemo"
@module("react")
external useMemo7: ((unit => 'any), ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo"
external useMemo7: (unit => 'any, ('a, 'b, 'c, 'd, 'e, 'f, 'g)) => 'any = "useMemo"

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

@module("react")
external useCallback: (('input => 'output)) => callback<'input, 'output> = "useCallback"
@module("react")
external useCallback0: (
('input => 'output),
@as(json`[]`) _,
) => callback<'input, 'output> = "useCallback"
external useCallback: ('input => 'output) => callback<'input, 'output> = "useCallback"
@module("react")
external useCallback1: (('input => 'output), array<'a>) => callback<'input, 'output> =
external useCallback0: ('input => 'output, @as(json`[]`) _) => callback<'input, 'output> =
"useCallback"
@module("react")
external useCallback2: (('input => 'output), ('a, 'b)) => callback<'input, 'output> =
"useCallback"
external useCallback1: ('input => 'output, array<'a>) => callback<'input, 'output> = "useCallback"
@module("react")
external useCallback2: ('input => 'output, ('a, 'b)) => callback<'input, 'output> = "useCallback"
@module("react")
external useCallback3: (('input => 'output), ('a, 'b, 'c)) => callback<'input, 'output> =
external useCallback3: ('input => 'output, ('a, 'b, 'c)) => callback<'input, 'output> =
"useCallback"
@module("react")
external useCallback4: (
('input => 'output),
('a, 'b, 'c, 'd),
) => callback<'input, 'output> = "useCallback"
external useCallback4: ('input => 'output, ('a, 'b, 'c, 'd)) => callback<'input, 'output> =
"useCallback"
@module("react")
external useCallback5: (
('input => 'output),
('a, 'b, 'c, 'd, 'e),
) => callback<'input, 'output> = "useCallback"
external useCallback5: ('input => 'output, ('a, 'b, 'c, 'd, 'e)) => callback<'input, 'output> =
"useCallback"
@module("react")
external useCallback6: (
('input => 'output),
('a, 'b, 'c, 'd, 'e, 'f),
) => callback<'input, 'output> = "useCallback"
external useCallback6: ('input => 'output, ('a, 'b, 'c, 'd, 'e, 'f)) => callback<'input, 'output> =
"useCallback"
@module("react")
external useCallback7: (
('input => 'output),
'input => 'output,
('a, 'b, 'c, 'd, 'e, 'f, 'g),
) => callback<'input, 'output> = "useCallback"

Expand All @@ -245,56 +222,50 @@ external useContext: Context.t<'any> => 'any = "useContext"
@module("react")
external useImperativeHandle0: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
unit => 'value,
@as(json`[]`) _,
) => unit = "useImperativeHandle"

@module("react")
external useImperativeHandle1: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
array<'a>,
) => unit = "useImperativeHandle"
external useImperativeHandle1: (Js.Nullable.t<Ref.t<'value>>, unit => 'value, array<'a>) => unit =
"useImperativeHandle"

@module("react")
external useImperativeHandle2: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
('a, 'b),
) => unit = "useImperativeHandle"
external useImperativeHandle2: (Js.Nullable.t<Ref.t<'value>>, unit => 'value, ('a, 'b)) => unit =
"useImperativeHandle"

@module("react")
external useImperativeHandle3: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
unit => 'value,
('a, 'b, 'c),
) => unit = "useImperativeHandle"

@module("react")
external useImperativeHandle4: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
unit => 'value,
('a, 'b, 'c, 'd),
) => unit = "useImperativeHandle"

@module("react")
external useImperativeHandle5: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
unit => 'value,
('a, 'b, 'c, 'd, 'e),
) => unit = "useImperativeHandle"

@module("react")
external useImperativeHandle6: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
unit => 'value,
('a, 'b, 'c, 'd, 'e, 'f),
) => unit = "useImperativeHandle"

@module("react")
external useImperativeHandle7: (
Js.Nullable.t<Ref.t<'value>>,
(unit => 'value),
unit => 'value,
('a, 'b, 'c, 'd, 'e, 'f, 'g),
) => unit = "useImperativeHandle"

Expand Down
12 changes: 6 additions & 6 deletions tests/build_tests/react_ppx/src/gpr_3987_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ let makeContainer = text => {

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

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

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

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

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

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

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

let _ = <Gpr3987ReproError value="test" onChange={(. _, _) => ()} />
let _ = <Gpr3987ReproError value="test" onChange={(_, _) => ()} />
4 changes: 2 additions & 2 deletions tests/build_tests/react_ppx/src/recursive_component_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module Rec = {
@react.component
let rec make = (~b) => {
mm({b:b})
mm({b: b})
}
and mm = (x) => make({b: ! x.b})
and mm = x => make({b: !x.b})
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
We've found a bug for you!
/.../fixtures/RecordInclusion.res:3:5-5:1

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

Expand All @@ -15,8 +15,8 @@
type t<'a, 'b, 'c> = {x: int, y: list<('a, 'c)>, z: int}
is not included in
type t<'a, 'b, 'c> = {x: int, y: list<('a, 'b)>, z: int}
/.../fixtures/RecordInclusion.res:2:3-55:
/.../fixtures/RecordInclusion.res:2:3-58:
Expected declaration
/.../fixtures/RecordInclusion.res:4:3-55:
/.../fixtures/RecordInclusion.res:4:3-58:
Actual declaration
The types for field y are not equal.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
We've found a bug for you!
/.../fixtures/UncurriedArgsNotApplied.res:3:15-21

1 │ let apply = (fn: (. unit) => option<int>) => fn(. ())
1 │ let apply = (fn: unit => option<int>) => fn()
2 │
3 │ let _ = apply(Some(1))
4 │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
3 │ } = {
4 │  type t = | @as(null) A
5 │ }
6 │

Signature mismatch:
Modules do not match:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
We've found a bug for you!
/.../fixtures/arity_mismatch.res:2:21-27

1 │ let makeVar = (. ~f, ()) => 34
2 │ let makeVariables = makeVar(.~f=f => f)
1 │ let makeVar = (~f, ()) => 34
2 │ let makeVariables = makeVar(~f=f => f)
3 │

This function has type (~f: 'a => 'a, unit) => int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
We've found a bug for you!
/.../fixtures/arity_mismatch2.res:2:21-27

1 │ let makeVar = (. f, ()) => 34
2 │ let makeVariables = makeVar(. 1, 2, 3)
1 │ let makeVar = (f, ()) => 34
2 │ let makeVariables = makeVar(1, 2, 3)
3 │

This function has type ('a, unit) => int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

1 │ let expectCurried = f => f(1) + 2
2 │
3 │ let z1 = expectCurried((. x, y) => x+y)
3 │ let z1 = expectCurried((x, y) => x + y)
4 │

This function expected 1 argument, but got 2
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
3 │ }
4 │
5 │ let x = stringDict.name
6 │

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