Skip to content

Commit 5748d14

Browse files
authored
Format jscomp/test (rescript-lang#6983)
1 parent c8ed227 commit 5748d14

File tree

180 files changed

+1654
-1613
lines changed

Some content is hidden

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

180 files changed

+1654
-1613
lines changed

jscomp/test/AsInUncurriedExternals.res

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ let mo = makeOptions
1212

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

15-
let shouldNotFail: (~objectMode: _, ~name: string) => int = (~objectMode, ~name) =>
16-
3
15+
let shouldNotFail: (~objectMode: _, ~name: string) => int = (~objectMode, ~name) => 3

jscomp/test/Coercion.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ let x = 1
22

33
let xx = (x :> float)
44

5-
type r1 = {x:int}
6-
type r2 = {x:int}
5+
type r1 = {x: int}
6+
type r2 = {x: int}
77

88
type t1 = array<r1>
99
type t2 = array<r2>
1010

11-
let foo = (x: t1) => { x :> t2 }
11+
let foo = (x: t1) => {(x :> t2)}

jscomp/test/DerivingAccessorsCurried.res

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
//In curried mode
33

44
@deriving(accessors)
5-
type myRecord = { myField: int }
5+
type myRecord = {myField: int}
66

77
@deriving(accessors)
8-
type variant = | NoParam | Num(int) | DoubleNum(int, int)
8+
type variant = NoParam | Num(int) | DoubleNum(int, int)
99

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

jscomp/test/DerivingAccessorsUncurried.res

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
@@uncurried
44

55
@deriving(accessors)
6-
type myRecord = { myField: int }
6+
type myRecord = {myField: int}
77

88
@deriving(accessors)
9-
type variant = | NoParam | Num(int) | DoubleNum(int, int)
9+
type variant = NoParam | Num(int) | DoubleNum(int, int)
1010

1111
//Asserts the correct signature for derived accessor
1212
let _myFieldAlias: myRecord => int = myField
@@ -17,6 +17,5 @@ let _doubleNumAlias: (int, int) => variant = doubleNum
1717
//Asserts that inference works when composing
1818
//with derived functions
1919
let compose = (a, accessor) => accessor(a)
20-
let _composedMyField = compose({ myField: 1 }, myField)
20+
let _composedMyField = compose({myField: 1}, myField)
2121
let _composedNum = compose(1, num)
22-
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
type t1 = {x:int, y:int}
2-
type t2 = {x:int, y:int, z?:int}
1+
type t1 = {x: int, y: int}
2+
type t2 = {x: int, y: int, z?: int}
33

4-
let f1 = (v:t1) => v.x
5-
let f2 = (v:t2) => v.x
4+
let f1 = (v: t1) => v.x
5+
let f2 = (v: t2) => v.x
66

7-
let v = {x:3, y:4}
7+
let v = {x: 3, y: 4}
88
let res = f2(v) // Check that t2 shadows t1

jscomp/test/EmptyRecord.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
type allOptRec = {n?: int, s?:string}
1+
type allOptRec = {n?: int, s?: string}
22

3-
let construct = (b) => b ? {n:0} : {}
3+
let construct = b => b ? {n: 0} : {}
44

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

88
type emptyrec = {}
99

10-
let er : emptyrec = {}
10+
let er: emptyrec = {}

jscomp/test/Import.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let eachIntAsync = async (list: list<int>, f: int => unit) => {
33
}
44

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

88
let _ = list{1, 2, 3}->eachIntLazy(n => Js.log2("lazy", n))
99
let _ = list{1, 2, 3}->eachIntAsync(n => Js.log2("async", n))

jscomp/test/RecordOrObject.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
type rx = {x: int}
22
type ry = {y: string}
3-
type rxi = {...rx, i?:int}
3+
type rxi = {...rx, i?: int}
44
type rxy = {...rx, ...ry} // this is a record
55

66
let vxy: rxy = {x: 10, y: "abc"}
7-
let xxi : rxi = {x:10}
7+
let xxi: rxi = {x: 10}
88

99
type ox = {"x": int}
1010
type oy = {"y": int}

jscomp/test/SafePromises.res

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
let nestedPromise = async (xxx: promise<promise<int>>) => {
44
let xx = await xxx
55

6-
let _ = xx->Js.Promise2.then(x => Js.log2("Promise2.then", x) |> Js.Promise.resolve)
6+
let _ = xx->Js.Promise2.then(x => Js.Promise.resolve(Js.log2("Promise2.then", x)))
77
let _ = xx->Js.Promise2.catch(x => {
88
Js.log2("Promise2.catch_", x)
9-
0 |> Js.Promise.resolve
9+
Js.Promise.resolve(0)
1010
})
1111

1212
// This crashes
13-
let _ = Js.Promise.then_(x => Js.log2("Promise.then_", x) |> Js.Promise.resolve, xx)
13+
let _ = Js.Promise.then_(x => Js.Promise.resolve(Js.log2("Promise.then_", x)), xx)
1414
}
1515

16-
let create = async (x) => {
16+
let create = async x => {
1717
Js.log2("create", x)
1818
x
1919
}

jscomp/test/UncurriedAlways.res

+20-10
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

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

5-
let z = foo(. 3, 4)
5+
let z = foo(3, 4)
66

7-
let bar = (. x, y) => x + y
7+
let bar = (x, y) => x + y
88

99
let b = bar(3, 4)
1010

1111
let w = 3->foo(4)
1212

13-
let a = 3->foo(. 4)
13+
let a = 3->foo(4)
1414

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

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

19-
let ptl = @res.partial foo(10) // force partial application
19+
let ptl = foo(10, ...) // force partial application
2020

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

3333
@inline
34-
let inl2 = (x,y) => x+y
34+
let inl2 = (x, y) => x + y
3535

3636
module AllLabels = {
3737
let foo = (~x, ~y, ~z) => (x, y, z)
@@ -54,7 +54,17 @@ module OptAtEnd = {
5454
}
5555

5656
module OptMixed = {
57-
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)
57+
let foo = (~d1="d1=0", ~x, ~d2="d2=0", ~y, ~d3="d3=0", ~z, ~d4="d4=0", ~w, ~d5="d5=0") => (
58+
d1,
59+
x,
60+
d2,
61+
y,
62+
d3,
63+
z,
64+
d4,
65+
w,
66+
d5,
67+
)
5868

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

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

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

75-
let fn1 = (a, b, ()) => a() + b
85+
let fn1 = (a, b, ()) => a() + b
7686

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

@@ -93,7 +103,7 @@ module PartialApplication = {
93103

94104
module ReverseApplication = {
95105
let hello1 = (y, f) => f(y)
96-
let hello2 = (y, f) => y |> f
106+
let hello2 = (y, f) => f(y)
97107
}
98108

99109
module Pipe = {
@@ -104,4 +114,4 @@ module Pipe = {
104114
let f3 = (foo, x) => foo(x)
105115

106116
let f4 = (x, f) => x->f(3)
107-
}
117+
}

jscomp/test/UncurriedExternals.res

+20-21
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
module StandardNotation = {
2-
external raise: (. exn) => 'a = "%raise"
3-
let dd = () => raise(. Not_found)
2+
external raise: exn => 'a = "%raise"
3+
let dd = () => raise(Not_found)
44

5-
@val external sum: (. float, float) => float = "sum"
6-
let h = sum(. 1.0, 2.0)
5+
@val external sum: (float, float) => float = "sum"
6+
let h = sum(1.0, 2.0)
77

88
module M: {
9-
let sum: (. float, float) => float
9+
let sum: (float, float) => float
1010
} = {
11-
external sum: (. float, float) => float = "sum"
11+
external sum: (float, float) => float = "sum"
1212
}
13-
let hh = M.sum(. 1.0, 2.0)
13+
let hh = M.sum(1.0, 2.0)
1414

15-
external mod_float: (. float, float) => float = "?fmod_float"
16-
let mf = mod_float(. 3., 4.)
15+
external mod_float: (float, float) => float = "?fmod_float"
16+
let mf = mod_float(3., 4.)
1717

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

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

24-
external toException: (. exn) => exn = "%identity"
25-
let te = toException(. Not_found)
24+
external toException: exn => exn = "%identity"
25+
let te = toException(Not_found)
2626

27-
@obj external ccreate: (. unit) => string = ""
28-
let tcr = ccreate(.)
27+
@obj external ccreate: unit => string = ""
28+
let tcr = ccreate()
2929

3030
type counter
3131
@set external setIncrementC: (counter, @this (counter, int) => unit) => unit = "increment"
3232
let tsiC = c => setIncrementC(c, @this (me, amount) => Js.log(me))
33-
@set external setIncrementU: (. counter, @this (. counter, int) => unit) => unit = "increment"
34-
let tsiU = c => setIncrementU(.c, @this (. me, amount) => Js.log(me))
33+
@set external setIncrementU: (counter, @this (counter, int) => unit) => unit = "increment"
34+
let tsiU = c => setIncrementU(c, @this (me, amount) => Js.log(me))
3535

3636
@module("react")
37-
external useState: ((unit => 'state)) => ('state, ('state => 'state) => unit) =
38-
"useState"
37+
external useState: (unit => 'state) => ('state, ('state => 'state) => unit) = "useState"
3938
let (get, set) = useState(() => 3)
4039
}
4140

jscomp/test/UncurriedPervasives.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@@uncurried
2-
let n : _ => unit = ignore // Check that we're pulling in uncurried pervasives
2+
let n: _ => unit = ignore // Check that we're pulling in uncurried pervasives

jscomp/test/UntaggedVariants.res

+5-5
Original file line numberDiff line numberDiff line change
@@ -296,16 +296,16 @@ module OptionUnboxingHeuristic = {
296296

297297
module TestFunctionCase = {
298298
@unboxed
299-
type t = Array(array<int>) | Record({x: int}) | Function((. int) => int)
299+
type t = Array(array<int>) | Record({x: int}) | Function(int => int)
300300

301301
let classify = v =>
302302
switch v {
303303
| Record({x}) => x
304304
| Array(a) => a[0]
305-
| Function(f) => f(. 3)
305+
| Function(f) => f(3)
306306
}
307307

308-
let ff = Function((. x) => x + 1)
308+
let ff = Function(x => x + 1)
309309
}
310310

311311
module ComplexPattern = {
@@ -416,14 +416,14 @@ module AllInstanceofTypes = {
416416

417417
module Aliased = {
418418
type dict = Js.Dict.t<string>
419-
type fn = (. unit) => option<string>
419+
type fn = unit => option<string>
420420
@unboxed type t = Object(dict) | String(string) | Function(fn)
421421

422422
let test = (t: t) => {
423423
switch t {
424424
| Object(d) => d->Js.Dict.get("Hello")
425425
| String(s) => Some(s)
426-
| Function(fn) => fn(.)
426+
| Function(fn) => fn()
427427
}
428428
}
429429
}

jscomp/test/VariantSpreads.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module S = {
2-
type x = Foo | Bar
3-
type s = Five(int) | Six
2+
type x = Foo | Bar
3+
type s = Five(int) | Six
44
}
55

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

20-
let q: q = One({name: "hello"})
20+
let q: q = One({name: "hello"})

jscomp/test/a_filename_test.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let eq = (loc, x, y) => {
99
list{(loc ++ (" id " ++ string_of_int(test_id.contents)), _ => Mt.Eq(x, y)), ...suites.contents}
1010
}
1111

12-
let test = (x,y) => Ext_filename_test.node_relative_path(true, x, y)
12+
let test = (x, y) => Ext_filename_test.node_relative_path(true, x, y)
1313
let () = /* TODO: adapt these tests to run on Windows. */
1414
if platform !== #win32 {
1515
eq(

jscomp/test/alias_default_value_test.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module C4 = {
3535

3636
module C6 = {
3737
module type Comp = {
38-
let xx : int
38+
let xx: int
3939
@react.component
4040
let make: unit => React.element
4141
}

jscomp/test/argv_test.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ let arg_spec = {
1111
Arg.parse_argv(["prog.exe", "-c", "-d"], arg_spec, anno_fun, usage_msg)
1212

1313
{
14-
assert (compile.contents == true)
15-
assert (test.contents == false)
14+
assert(compile.contents == true)
15+
assert(test.contents == false)
1616
}

jscomp/test/ari_regress_test.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let suites = {
2626
_ => Eq(
2727
14,
2828
{
29-
v(1) |> ignore
29+
ignore(v(1))
3030
v(1)
3131
},
3232
),

0 commit comments

Comments
 (0)