Skip to content

Tests: Js -> Stdlib #11

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
124 changes: 62 additions & 62 deletions tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ let eToplevel = Etoplevel

let eInside = Inside.Einside

Js.log(eInside)
Console.log(eInside)

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ let rec emitModuleAccessPath = moduleAccessPath =>
| Kaboom => ""
}

let () = Js.log(Kaboom)
let () = Console.log(Kaboom)

16 changes: 8 additions & 8 deletions tests/analysis_tests/tests-reanalyze/deadcode/src/DeadTest.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let _ = Js.log(ImmutableArray.fromArray)
let _ = Console.log(ImmutableArray.fromArray)
let fortytwo = 42

@genType
Expand Down Expand Up @@ -66,11 +66,11 @@ module MM: {
}

let _ = {
Js.log(MM.x)
Console.log(MM.x)
44
}

let () = Js.log(DeadValueTest.valueAlive)
let () = Console.log(DeadValueTest.valueAlive)

let rec unusedRec = () => unusedRec()

Expand All @@ -95,7 +95,7 @@ and bar = () => foo()

let withDefaultValue = (~paramWithDefault=3, y) => paramWithDefault + y

let () = Js.log(DeadRT.Root("xzz"))
let () = Console.log(DeadRT.Root("xzz"))

module type LocalDynamicallyLoadedComponent2 = module type of DynamicallyLoadedComponent

Expand All @@ -107,7 +107,7 @@ let zzz = {
let a3 = 3
}

let () = Js.log(<DynamicallyLoadedComponent s="" />)
let () = Console.log(<DynamicallyLoadedComponent s="" />)

let second = 1

Expand All @@ -116,9 +116,9 @@ let deadRef = ref(12)
@react.component
let make = (~s) => React.string(s)

let () = Js.log(make)
let () = Console.log(make)

let theSideEffectIsLogging = Js.log(123)
let theSideEffectIsLogging = Console.log(123)

let stringLengthNoSideEffects = String.length("sdkdl")

Expand All @@ -139,7 +139,7 @@ module WithInclude: {
include T
}

Js.log(WithInclude.A)
Console.log(WithInclude.A)

@dead
let funWithInnerVars = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module Dep = {
exception MyOtherException

let ddjdj = 34
Js.log(ddjdj)
Console.log(ddjdj)
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ let fPrimed = x => 3.0 * x * x - 4.0 * x - 11.0

let result = newton(~f, ~fPrimed, ~initial=5.0, ~threshold=0.0003)

Js.log2(result, f(result))
Console.log2(result, f(result))

16 changes: 8 additions & 8 deletions tests/analysis_tests/tests-reanalyze/deadcode/src/OptArg.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ let foo = (~x=1, ~y=2, ~z=3, w) => x + y + z + w

let bar = (~x=?, ~y, ~z=?, w) => y + w

Js.log(foo(~x=3, 4))
Console.log(foo(~x=3, 4))

Js.log(bar(~y=3, 4))
Console.log(bar(~y=3, 4))

let threeArgs = (~a=1, ~b=2, ~c=3, d) => a + b + c + d

Js.log(threeArgs(~a=4, ~c=7, 1))
Js.log(threeArgs(~a=4, 1))
Console.log(threeArgs(~a=4, ~c=7, 1))
Console.log(threeArgs(~a=4, 1))

let twoArgs = (~a=1, ~b=2, c) => a + b + c

Js.log(1 |> twoArgs)
Console.log(1 |> twoArgs)

let oneArg = (~a=1, ~z, b) => a + b

let wrapOneArg = (~a=?, n) => oneArg(~a?, ~z=33, n)

Js.log(wrapOneArg(~a=3, 44))
Console.log(wrapOneArg(~a=3, 44))

let fourArgs = (~a=1, ~b=2, ~c=3, ~d=4, n) => a + b + c + d + n

let wrapfourArgs = (~a=?, ~b=?, ~c=?, n) => fourArgs(~a?, ~b?, ~c?, n)

Js.log(wrapfourArgs(~a=3, ~c=44, 44))
Js.log(wrapfourArgs(~b=4, ~c=44, 44))
Console.log(wrapfourArgs(~a=3, ~c=44, 44))
Console.log(wrapfourArgs(~b=4, ~c=44, 44))

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type tabState = {

let userData = ({a, b}): userData => {a: a, b: b}

Js.log(userData)
Console.log(userData)

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Js.log(DeadExn.Etoplevel)
Console.log(DeadExn.Etoplevel)

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Js.log(OptArg.bar(~z=3, ~y=3, 4))
Console.log(OptArg.bar(~z=3, ~y=3, 4))

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

let bar = () => foo(~x=12, 3)

Js.log(bar)
Console.log(bar)

let notSuppressesOptArgs = (~x=1, ~y=2, ~z=3, w) => x + y + z + w

Expand Down
12 changes: 6 additions & 6 deletions tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ let callback2 = auth => auth.login()
let callback2U = auth => auth.loginU(.)

@genType
let sumU = (. n, m) => Js.log4("sumU 2nd arg", m, "result", n + m)
let sumU = (. n, m) => Console.log4("sumU 2nd arg", m, "result", n + m)

@genType
let sumU2 = (. n, . m) => Js.log4("sumU2 2nd arg", m, "result", n + m)
let sumU2 = (. n, . m) => Console.log4("sumU2 2nd arg", m, "result", n + m)

@genType
let sumCurried = n => {
Js.log2("sumCurried 1st arg", n)
m => Js.log4("sumCurried 2nd arg", m, "result", n + m)
Console.log2("sumCurried 1st arg", n)
m => Console.log4("sumCurried 2nd arg", m, "result", n + m)
}

@genType
let sumLblCurried = (s: string, ~n) => {
Js.log3(s, "sumLblCurried 1st arg", n)
(~m) => Js.log4("sumLblCurried 2nd arg", m, "result", n + m)
Console.log3(s, "sumLblCurried 1st arg", n)
(~m) => Console.log4("sumLblCurried 2nd arg", m, "result", n + m)
}

Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ let testWithPayload = (x: withPayload) => x
@genType
let printVariantWithPayload = (x: withPayload) =>
switch x {
| #a => Js.log("printVariantWithPayload: a")
| #b => Js.log("printVariantWithPayload: b")
| #True => Js.log("printVariantWithPayload: True")
| #Twenty => Js.log("printVariantWithPayload: Twenty")
| #Half => Js.log("printVariantWithPayload: Half")
| #c(payload) => Js.log4("printVariantWithPayload x:", payload.x, "y:", payload.y)
| #a => Console.log("printVariantWithPayload: a")
| #b => Console.log("printVariantWithPayload: b")
| #True => Console.log("printVariantWithPayload: True")
| #Twenty => Console.log("printVariantWithPayload: Twenty")
| #Half => Console.log("printVariantWithPayload: Half")
| #c(payload) => Console.log4("printVariantWithPayload x:", payload.x, "y:", payload.y)
}

@genType
Expand All @@ -39,9 +39,9 @@ let testManyPayloads = (x: manyPayloads) => x
@genType
let printManyPayloads = (x: manyPayloads) =>
switch x {
| #one(n) => Js.log2("printManyPayloads one:", n)
| #two(s1, s2) => Js.log3("printManyPayloads two:", s1, s2)
| #three(payload) => Js.log4("printManyPayloads x:", payload.x, "y:", payload.y)
| #one(n) => Console.log2("printManyPayloads one:", n)
| #two(s1, s2) => Console.log3("printManyPayloads two:", s1, s2)
| #three(payload) => Console.log4("printManyPayloads x:", payload.x, "y:", payload.y)
}

@genType
Expand All @@ -67,20 +67,20 @@ let testVariantWithPayloads = (x: variantWithPayloads) => x
@genType
let printVariantWithPayloads = x =>
switch x {
| A => Js.log2("printVariantWithPayloads", "A")
| B(x) => Js.log2("printVariantWithPayloads", "B(" ++ (string_of_int(x) ++ ")"))
| A => Console.log2("printVariantWithPayloads", "A")
| B(x) => Console.log2("printVariantWithPayloads", "B(" ++ (string_of_int(x) ++ ")"))
| C(x, y) =>
Js.log2(
Console.log2(
"printVariantWithPayloads",
"C(" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ ")"))),
)
| D((x, y)) =>
Js.log2(
Console.log2(
"printVariantWithPayloads",
"D((" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ "))"))),
)
| E(x, s, y) =>
Js.log2(
Console.log2(
"printVariantWithPayloads",
"E(" ++ (string_of_int(x) ++ (", " ++ (s ++ (", " ++ (string_of_int(y) ++ ")"))))),
)
Expand Down
2 changes: 1 addition & 1 deletion tests/build_tests/case/src/demo.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log("Hello, ReScript")
let () = Console.log("Hello, ReScript")
2 changes: 1 addition & 1 deletion tests/build_tests/case2/src/X.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log("Hello, ReScript")
let () = Console.log("Hello, ReScript")
2 changes: 1 addition & 1 deletion tests/build_tests/deprecated-package-specs/src/Index.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log("Hello, ReScript")
let () = Console.log("Hello, ReScript")
2 changes: 1 addition & 1 deletion tests/build_tests/devonly/src/demo.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log(Depdemo.a)
let () = Console.log(Depdemo.a)
2 changes: 1 addition & 1 deletion tests/build_tests/devonly/src2/hellodep.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Js.log(Hello.v)
Console.log(Hello.v)
2 changes: 1 addition & 1 deletion tests/build_tests/hyphen2/y-src/demo.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log("Hello, ReScript")
let () = Console.log("Hello, ReScript")
2 changes: 1 addition & 1 deletion tests/build_tests/install/src/Foo.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let main = () => Js.log("hello")
let main = () => Console.log("hello")
2 changes: 1 addition & 1 deletion tests/build_tests/ns/src/demo.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log(Hello.a + Hello.b)
let () = Console.log(Hello.a + Hello.b)
2 changes: 1 addition & 1 deletion tests/build_tests/post-build/src/demo.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let () = Js.log("Hello, ReScript")
let () = Console.log("Hello, ReScript")
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

3 │ let foo = (fakeDict: fakeDict<'a>) => {
4 │ switch fakeDict {
5 │ | {someUndefinedField: 1} => Js.log("one")
6 │ | _ => Js.log("not one")
5 │ | {someUndefinedField: 1} => Console.log("one")
6 │ | _ => Console.log("not one")
7 │ }

The field someUndefinedField does not belong to type fakeDict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

1 │ let foo = dict =>
2 │ switch dict {
3 │ | dict{"one": 1, "two": "hello"} => Js.log("one")
4 │ | _ => Js.log("not one")
3 │ | dict{"one": 1, "two": "hello"} => Console.log("one")
4 │ | _ => Console.log("not one")
5 │ }

This pattern matches values of type string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
2 ┆ switch dict {
3 ┆ | dict{"one": 1} =>
4 ┆ let _: dict<string> = dict
5 ┆ Js.log("one")
6 ┆ | _ => Js.log("not one")
5 ┆ Console.log("one")
6 ┆ | _ => Console.log("not one")

This has type: dict<int>
But it's expected to have type: dict<string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

3 │ let constrainedAsDict = (dict: x) =>
4 │ switch dict {
5 │ | dict{"one": "one"} => Js.log("one")
6 │ | _ => Js.log("not one")
5 │ | dict{"one": "one"} => Console.log("one")
6 │ | _ => Console.log("not one")
7 │ }

This pattern matches values of type dict<string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

5 │ let lookup = (b: b) =>
6 │ switch b {
7 │ | ...c as c => Js.log(c)
8 │ | Four => Js.log("four")
9 │ | Five => Js.log("five")
7 │ | ...c as c => Console.log(c)
8 │ | Four => Console.log("four")
9 │ | Five => Console.log("five")

Type c is not a subtype of b
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

5 │ let lookup = (b: b) =>
6 │ switch b {
7 │ | ...c as c => Js.log(c)
8 │ | Four => Js.log("four")
9 │ | Five => Js.log("five")
7 │ | ...c as c => Console.log(c)
8 │ | Four => Console.log("four")
9 │ | Five => Console.log("five")

The type c
is not a variant type
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
9 │ @val external x: myType = "myVariable"
10 │
11 │ switch x {
12 │ | #first => Js.log("first")
12 │ | #first => Console.log("first")
13 │ }
14 │

Expand Down
12 changes: 6 additions & 6 deletions tests/build_tests/super_errors/expected/warnings5.res.expected
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

10 │
11 │ switch y {
12 │ | {otherValue: false} => Js.log("first")
12 │ | {otherValue: false} => Console.log("first")
13 │ }
14 │

Expand All @@ -18,7 +18,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
9 │ @val external y: someRecord = "otherVariable"
10 │
11 │ switch y {
12 │ | {otherValue: false} => Js.log("first")
12 │ | {otherValue: false} => Console.log("first")
13 │ }
14 │
15 │ switch y {
Expand All @@ -32,7 +32,7 @@ Either bind these labels explicitly or add ', _' to the pattern.

14 │
15 │ switch y {
16 │ | {typ: WithPayload(true)} => Js.log("first")
16 │ | {typ: WithPayload(true)} => Console.log("first")
17 │ }
18 │

Expand All @@ -46,7 +46,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
13 │ }
14 │
15 │ switch y {
16 │ | {typ: WithPayload(true)} => Js.log("first")
16 │ | {typ: WithPayload(true)} => Console.log("first")
17 │ }
18 │
19 │ let arr = [1]
Expand All @@ -62,7 +62,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
19 │ let arr = [1]
20 │
21 │ switch arr {
22 │ | [] => Js.log("")
22 │ | [] => Console.log("")
23 │ }
24 │
25 │ switch arr {
Expand All @@ -77,7 +77,7 @@ Either bind these labels explicitly or add ', _' to the pattern.
23 │ }
24 │
25 │ switch arr {
26 │ | [one] => Js.log(one)
26 │ | [one] => Console.log(one)
27 │ }
28 │
29 │ switch arr {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
let f = (a, b) => a + b

f(2, 2)->Js.log
f(2, 2)->Console.log
Loading