Skip to content

Commit 7b103f1

Browse files
committed
Add tests ensuring platform defaults compatibility with the latest Scala Toolkit
1 parent 702530d commit 7b103f1

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

modules/integration/src/test/scala/scala/cli/integration/RunScalaJsTestDefinitions.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,22 @@ trait RunScalaJsTestDefinitions { _: RunTestDefinitions =>
265265
expect(output == "H")
266266
}
267267
}
268+
269+
test("js defaults & toolkit latest") {
270+
val msg = "Hello"
271+
TestInputs(
272+
os.rel / "script.sc" ->
273+
s"""//> using toolkit latest
274+
|//> using platform "scala-js"
275+
|import scala.scalajs.js
276+
|val console = js.Dynamic.global.console
277+
|val jsonString = "{\\"msg\\": \\"$msg\\"}"
278+
|val json: ujson.Value = ujson.read(jsonString)
279+
|console.log(json("msg").str)
280+
|""".stripMargin
281+
).fromRoot { root =>
282+
val result = os.proc(TestUtil.cli, "run", "script.sc").call(cwd = root)
283+
expect(result.out.trim() == msg)
284+
}
285+
}
268286
}

modules/integration/src/test/scala/scala/cli/integration/RunScalaNativeTestDefinitions.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,17 @@ trait RunScalaNativeTestDefinitions { _: RunTestDefinitions =>
300300
expect(output2 == "Hello from Main2")
301301
}
302302
}
303+
304+
test("native defaults & toolkit latest") {
305+
TestInputs(
306+
os.rel / "script.sc" ->
307+
"""//> using toolkit latest
308+
|//> using platform "scala-native"
309+
|println(os.pwd)
310+
|""".stripMargin
311+
).fromRoot { root =>
312+
val result = os.proc(TestUtil.cli, "run", "script.sc").call(cwd = root)
313+
expect(result.out.trim() == root.toString)
314+
}
315+
}
303316
}

0 commit comments

Comments
 (0)