From a933c633c3e69d77c8667fc27bff9bb5b2abb666 Mon Sep 17 00:00:00 2001 From: Szymon Rodziewicz Date: Mon, 15 May 2023 14:21:46 +0200 Subject: [PATCH] Remove fewer braces syntax for now --- _overviews/toolkit/testing-asynchronous.md | 3 ++- _overviews/toolkit/testing-exceptions.md | 6 ++++-- _overviews/toolkit/testing-resources.md | 3 ++- _overviews/toolkit/testing-run-only.md | 15 ++++++++++----- _overviews/toolkit/testing-run.md | 3 ++- _overviews/toolkit/testing-suite.md | 6 ++++-- _overviews/toolkit/testing-what-else.md | 6 ++++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/_overviews/toolkit/testing-asynchronous.md b/_overviews/toolkit/testing-asynchronous.md index 68862cc1cc..1311af6b9b 100644 --- a/_overviews/toolkit/testing-asynchronous.md +++ b/_overviews/toolkit/testing-asynchronous.md @@ -68,13 +68,14 @@ class AsyncMathLibTests extends munit.FunSuite { import scala.concurrent.ExecutionContext.Implicits.global class AsyncMathLibTests extends munit.FunSuite: - test("square"): + test("square") { for squareOf3 <- AsyncMathLib.square(3) squareOfMinus4 <- AsyncMathLib.square(-4) yield assertEquals(squareOf3, 9) assertEquals(squareOfMinus4, 16) + } ``` {% endtab %} {% endtabs %} diff --git a/_overviews/toolkit/testing-exceptions.md b/_overviews/toolkit/testing-exceptions.md index 0e26e51bd5..f2a880d68f 100644 --- a/_overviews/toolkit/testing-exceptions.md +++ b/_overviews/toolkit/testing-exceptions.md @@ -34,11 +34,13 @@ class FileTests extends munit.FunSuite { import java.nio.file.NoSuchFileException class FileTests extends munit.FunSuite: - test("read missing file"): + test("read missing file") { val missingFile = os.pwd / "missing.txt" - intercept[NoSuchFileException]: + intercept[NoSuchFileException] { // the code that should throw an exception os.read(missingFile) + } + } ``` {% endtab %} {% endtabs %} diff --git a/_overviews/toolkit/testing-resources.md b/_overviews/toolkit/testing-resources.md index 9e0d45f51f..50733256e7 100644 --- a/_overviews/toolkit/testing-resources.md +++ b/_overviews/toolkit/testing-resources.md @@ -82,9 +82,10 @@ using2TempFiles.test("merge two files") { val using2TempFiles: FunFixture[(os.Path, os.Path)] = FunFixture.map2(usingTempFile, usingTempFile) -using2TempFiles.test("merge two files"): +using2TempFiles.test("merge two files") { (file1, file2) => // body of the test +} ``` {% endtab %} {% endtabs %} diff --git a/_overviews/toolkit/testing-run-only.md b/_overviews/toolkit/testing-run-only.md index af6ba02cd7..fcd56fde3c 100644 --- a/_overviews/toolkit/testing-run-only.md +++ b/_overviews/toolkit/testing-run-only.md @@ -53,10 +53,12 @@ class MathSuite extends munit.FunSuite { {% tab 'Scala 3' %} ```scala class MathSuite extends munit.FunSuite: - test("addition"): + test("addition") { assert(1 + 1 == 2) - test("multiplication".only): + } + test("multiplication".only) { assert(3 * 7 == 21) + } ``` {% endtab %} {% endtabs %} @@ -88,12 +90,15 @@ class MathSuite extends munit.FunSuite { {% tab 'Scala 3' %} ```scala class MathSuite extends munit.FunSuite: - test("addition".ignore): + test("addition".ignore) { assert(1 + 1 == 2) - test("multiplication"): + } + test("multiplication") { assert(3 * 7 == 21) - test("remainder"): + } + test("remainder") { assert(13 % 5 == 3) + } ``` {% endtab %} {% endtabs %} diff --git a/_overviews/toolkit/testing-run.md b/_overviews/toolkit/testing-run.md index cb3fde0ade..12b0871289 100644 --- a/_overviews/toolkit/testing-run.md +++ b/_overviews/toolkit/testing-run.md @@ -62,10 +62,11 @@ test("failing test") { {% endtab %} {% tab 'Scala 3' %} ```scala -test("failing test"): +test("failing test") { val obtained = 2 + 3 val expected = 4 assertEquals(obtained, expected) +} ``` {% endtab %} {% endtabs %} diff --git a/_overviews/toolkit/testing-suite.md b/_overviews/toolkit/testing-suite.md index 23c717a414..7c068edfe7 100644 --- a/_overviews/toolkit/testing-suite.md +++ b/_overviews/toolkit/testing-suite.md @@ -78,10 +78,11 @@ class MyTests extends munit.FunSuite { package example class MyTests extends munit.FunSuite: - test("sum of two integers"): + test("sum of two integers") { val obtained = 2 + 2 val expected = 4 assertEquals(obtained, expected) + } ``` {% endtab %} {% endtabs %} @@ -115,11 +116,12 @@ test("all even numbers") { {% endtab %} {% tab 'Scala 3' %} ```scala -test("all even numbers"): +test("all even numbers") { val input: List[Int] = List(1, 2, 3, 4) val obtainedResults: List[Int] = input.map(_ * 2) // check that obtained values are all even numbers assert(obtainedResults.forall(x => x % 2 == 0)) +} ``` {% endtab %} {% endtabs %} diff --git a/_overviews/toolkit/testing-what-else.md b/_overviews/toolkit/testing-what-else.md index 305765ec30..4c0672af1a 100644 --- a/_overviews/toolkit/testing-what-else.md +++ b/_overviews/toolkit/testing-what-else.md @@ -49,9 +49,10 @@ test("home directory") { ```scala import scala.util.Properties -test("home directory"): +test("home directory") { assume(Properties.isLinux, "this test runs only on Linux") assert(os.home.toString.startsWith("/home/")) +} ``` {% endtab %} {% endtabs %} @@ -73,8 +74,9 @@ test("requests".flaky) { {% endtab %} {% tab 'Scala 3' %} ```scala -test("requests".flaky): +test("requests".flaky) { // I/O heavy tests that sometimes fail +} ``` {% endtab %} {% endtabs %}