Skip to content

Format jscomp/test #6983

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

Merged
merged 1 commit into from
Aug 27, 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
3 changes: 1 addition & 2 deletions jscomp/test/AsInUncurriedExternals.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ let mo = makeOptions

let options = mo(~name="foo", ())

let shouldNotFail: (~objectMode: _, ~name: string) => int = (~objectMode, ~name) =>
3
let shouldNotFail: (~objectMode: _, ~name: string) => int = (~objectMode, ~name) => 3
6 changes: 3 additions & 3 deletions jscomp/test/Coercion.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ let x = 1

let xx = (x :> float)

type r1 = {x:int}
type r2 = {x:int}
type r1 = {x: int}
type r2 = {x: int}

type t1 = array<r1>
type t2 = array<r2>

let foo = (x: t1) => { x :> t2 }
let foo = (x: t1) => {(x :> t2)}
7 changes: 3 additions & 4 deletions jscomp/test/DerivingAccessorsCurried.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
//In curried mode

@deriving(accessors)
type myRecord = { myField: int }
type myRecord = {myField: int}

@deriving(accessors)
type variant = | NoParam | Num(int) | DoubleNum(int, int)
type variant = NoParam | Num(int) | DoubleNum(int, int)

//Asserts the correct signature for derived accessor
let _myFieldAlias: myRecord => int = myField
Expand All @@ -16,6 +16,5 @@ let _doubleNumAlias: (int, int) => variant = doubleNum
//Asserts that inference works when composing
//with derived functions
let compose = (a, accessor) => accessor(a)
let _composedMyField = compose({ myField: 1 }, myField)
let _composedMyField = compose({myField: 1}, myField)
let _composedNum = compose(1, num)

7 changes: 3 additions & 4 deletions jscomp/test/DerivingAccessorsUncurried.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
@@uncurried

@deriving(accessors)
type myRecord = { myField: int }
type myRecord = {myField: int}

@deriving(accessors)
type variant = | NoParam | Num(int) | DoubleNum(int, int)
type variant = NoParam | Num(int) | DoubleNum(int, int)

//Asserts the correct signature for derived accessor
let _myFieldAlias: myRecord => int = myField
Expand All @@ -17,6 +17,5 @@ let _doubleNumAlias: (int, int) => variant = doubleNum
//Asserts that inference works when composing
//with derived functions
let compose = (a, accessor) => accessor(a)
let _composedMyField = compose({ myField: 1 }, myField)
let _composedMyField = compose({myField: 1}, myField)
let _composedNum = compose(1, num)

10 changes: 5 additions & 5 deletions jscomp/test/DisambiguateOptionalFields.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
type t1 = {x:int, y:int}
type t2 = {x:int, y:int, z?:int}
type t1 = {x: int, y: int}
type t2 = {x: int, y: int, z?: int}

let f1 = (v:t1) => v.x
let f2 = (v:t2) => v.x
let f1 = (v: t1) => v.x
let f2 = (v: t2) => v.x

let v = {x:3, y:4}
let v = {x: 3, y: 4}
let res = f2(v) // Check that t2 shadows t1
6 changes: 3 additions & 3 deletions jscomp/test/EmptyRecord.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type allOptRec = {n?: int, s?:string}
type allOptRec = {n?: int, s?: string}

let construct = (b) => b ? {n:0} : {}
let construct = b => b ? {n: 0} : {}

// let z = {}
// Error: Empty record literal {} should be type annotated or used in a record context.

type emptyrec = {}

let er : emptyrec = {}
let er: emptyrec = {}
2 changes: 1 addition & 1 deletion jscomp/test/Import.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let eachIntAsync = async (list: list<int>, f: int => unit) => {
}

let eachIntLazy = (list: list<int>, f: int => unit) =>
Js.import(Belt.List.forEach) |> Js.Promise.then_(each => list->each(f)->Js.Promise.resolve)
Js.Promise.then_(each => list->each(f)->Js.Promise.resolve, Js.import(Belt.List.forEach))

let _ = list{1, 2, 3}->eachIntLazy(n => Js.log2("lazy", n))
let _ = list{1, 2, 3}->eachIntAsync(n => Js.log2("async", n))
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/RecordOrObject.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type rx = {x: int}
type ry = {y: string}
type rxi = {...rx, i?:int}
type rxi = {...rx, i?: int}
type rxy = {...rx, ...ry} // this is a record

let vxy: rxy = {x: 10, y: "abc"}
let xxi : rxi = {x:10}
let xxi: rxi = {x: 10}

type ox = {"x": int}
type oy = {"y": int}
Expand Down
8 changes: 4 additions & 4 deletions jscomp/test/SafePromises.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
let nestedPromise = async (xxx: promise<promise<int>>) => {
let xx = await xxx

let _ = xx->Js.Promise2.then(x => Js.log2("Promise2.then", x) |> Js.Promise.resolve)
let _ = xx->Js.Promise2.then(x => Js.Promise.resolve(Js.log2("Promise2.then", x)))
let _ = xx->Js.Promise2.catch(x => {
Js.log2("Promise2.catch_", x)
0 |> Js.Promise.resolve
Js.Promise.resolve(0)
})

// This crashes
let _ = Js.Promise.then_(x => Js.log2("Promise.then_", x) |> Js.Promise.resolve, xx)
let _ = Js.Promise.then_(x => Js.Promise.resolve(Js.log2("Promise.then_", x)), xx)
}

let create = async (x) => {
let create = async x => {
Js.log2("create", x)
x
}
Expand Down
30 changes: 20 additions & 10 deletions jscomp/test/UncurriedAlways.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

let foo = (x, y) => x + y

let z = foo(. 3, 4)
let z = foo(3, 4)

let bar = (. x, y) => x + y
let bar = (x, y) => x + y

let b = bar(3, 4)

let w = 3->foo(4)

let a = 3->foo(. 4)
let a = 3->foo(4)

Js.log(a) // Test automatic uncurried application

let _ = Js.Array2.map([1], (. x) => x + 1)
let _ = Js.Array2.map([1], x => x + 1)

let ptl = @res.partial foo(10) // force partial application
let ptl = foo(10, ...) // force partial application

let foo2 = (x, y) => x + y
let bar2: _ => _ = foo2(_, 3)
Expand All @@ -31,7 +31,7 @@ let q: cmp = _ => Jsx.null // Check that subtyping works past type definitions
let inl = () => ()

@inline
let inl2 = (x,y) => x+y
let inl2 = (x, y) => x + y

module AllLabels = {
let foo = (~x, ~y, ~z) => (x, y, z)
Expand All @@ -54,7 +54,17 @@ module OptAtEnd = {
}

module OptMixed = {
let foo = (~d1="d1=0", ~x, ~d2="d2=0", ~y, ~d3="d3=0", ~z, ~d4="d4=0", ~w, ~d5="d5=0") => (d1, x, d2, y, d3, z, d4, w, d5)
let foo = (~d1="d1=0", ~x, ~d2="d2=0", ~y, ~d3="d3=0", ~z, ~d4="d4=0", ~w, ~d5="d5=0") => (
d1,
x,
d2,
y,
d3,
z,
d4,
w,
d5,
)

let ptl = foo(~y="y", ~w="w", ...)

Expand All @@ -72,7 +82,7 @@ let fn = cb => {

fn(s => Js.log(#foo(s)))

let fn1 = (a, b, ()) => a() + b
let fn1 = (a, b, ()) => a() + b

let a = fn1(() => 1, 2, _)

Expand All @@ -93,7 +103,7 @@ module PartialApplication = {

module ReverseApplication = {
let hello1 = (y, f) => f(y)
let hello2 = (y, f) => y |> f
let hello2 = (y, f) => f(y)
}

module Pipe = {
Expand All @@ -104,4 +114,4 @@ module Pipe = {
let f3 = (foo, x) => foo(x)

let f4 = (x, f) => x->f(3)
}
}
41 changes: 20 additions & 21 deletions jscomp/test/UncurriedExternals.res
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
module StandardNotation = {
external raise: (. exn) => 'a = "%raise"
let dd = () => raise(. Not_found)
external raise: exn => 'a = "%raise"
let dd = () => raise(Not_found)

@val external sum: (. float, float) => float = "sum"
let h = sum(. 1.0, 2.0)
@val external sum: (float, float) => float = "sum"
let h = sum(1.0, 2.0)

module M: {
let sum: (. float, float) => float
let sum: (float, float) => float
} = {
external sum: (. float, float) => float = "sum"
external sum: (float, float) => float = "sum"
}
let hh = M.sum(. 1.0, 2.0)
let hh = M.sum(1.0, 2.0)

external mod_float: (. float, float) => float = "?fmod_float"
let mf = mod_float(. 3., 4.)
external mod_float: (float, float) => float = "?fmod_float"
let mf = mod_float(3., 4.)

@get_index external get: (. array<string>, int) => option<'a> = ""
let tg = arr => arr->get(. 0)
@get_index external get: (array<string>, int) => option<'a> = ""
let tg = arr => arr->get(0)

@val external copy: (. @as(json`{}`) _, string) => string = "Object.assign"
let tc = copy(. "abc")
@val external copy: (@as(json`{}`) _, string) => string = "Object.assign"
let tc = copy("abc")

external toException: (. exn) => exn = "%identity"
let te = toException(. Not_found)
external toException: exn => exn = "%identity"
let te = toException(Not_found)

@obj external ccreate: (. unit) => string = ""
let tcr = ccreate(.)
@obj external ccreate: unit => string = ""
let tcr = ccreate()

type counter
@set external setIncrementC: (counter, @this (counter, int) => unit) => unit = "increment"
let tsiC = c => setIncrementC(c, @this (me, amount) => Js.log(me))
@set external setIncrementU: (. counter, @this (. counter, int) => unit) => unit = "increment"
let tsiU = c => setIncrementU(.c, @this (. me, amount) => Js.log(me))
@set external setIncrementU: (counter, @this (counter, int) => unit) => unit = "increment"
let tsiU = c => setIncrementU(c, @this (me, amount) => Js.log(me))

@module("react")
external useState: ((unit => 'state)) => ('state, ('state => 'state) => unit) =
"useState"
external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState"
let (get, set) = useState(() => 3)
}

Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/UncurriedPervasives.res
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@@uncurried
let n : _ => unit = ignore // Check that we're pulling in uncurried pervasives
let n: _ => unit = ignore // Check that we're pulling in uncurried pervasives
10 changes: 5 additions & 5 deletions jscomp/test/UntaggedVariants.res
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,16 @@ module OptionUnboxingHeuristic = {

module TestFunctionCase = {
@unboxed
type t = Array(array<int>) | Record({x: int}) | Function((. int) => int)
type t = Array(array<int>) | Record({x: int}) | Function(int => int)

let classify = v =>
switch v {
| Record({x}) => x
| Array(a) => a[0]
| Function(f) => f(. 3)
| Function(f) => f(3)
}

let ff = Function((. x) => x + 1)
let ff = Function(x => x + 1)
}

module ComplexPattern = {
Expand Down Expand Up @@ -416,14 +416,14 @@ module AllInstanceofTypes = {

module Aliased = {
type dict = Js.Dict.t<string>
type fn = (. unit) => option<string>
type fn = unit => option<string>
@unboxed type t = Object(dict) | String(string) | Function(fn)

let test = (t: t) => {
switch t {
| Object(d) => d->Js.Dict.get("Hello")
| String(s) => Some(s)
| Function(fn) => fn(.)
| Function(fn) => fn()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/VariantSpreads.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module S = {
type x = Foo | Bar
type s = Five(int) | Six
type x = Foo | Bar
type s = Five(int) | Six
}

type a = One(bool, S.x) | Two
Expand All @@ -17,4 +17,4 @@ let ddd: b = Six
type f = One({name: string, age?: int}) | Two
type q = | ...f | Three

let q: q = One({name: "hello"})
let q: q = One({name: "hello"})
2 changes: 1 addition & 1 deletion jscomp/test/a_filename_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let eq = (loc, x, y) => {
list{(loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Eq(x, y)), ...suites.contents}
}

let test = (x,y) => Ext_filename_test.node_relative_path(true, x, y)
let test = (x, y) => Ext_filename_test.node_relative_path(true, x, y)
let () = /* TODO: adapt these tests to run on Windows. */
if platform !== #win32 {
eq(
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/alias_default_value_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module C4 = {

module C6 = {
module type Comp = {
let xx : int
let xx: int
@react.component
let make: unit => React.element
}
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/argv_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ let arg_spec = {
Arg.parse_argv(["prog.exe", "-c", "-d"], arg_spec, anno_fun, usage_msg)

{
assert (compile.contents == true)
assert (test.contents == false)
assert(compile.contents == true)
assert(test.contents == false)
}
2 changes: 1 addition & 1 deletion jscomp/test/ari_regress_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let suites = {
_ => Eq(
14,
{
v(1) |> ignore
ignore(v(1))
v(1)
},
),
Expand Down
Loading