Skip to content

Remove fewer braces syntax for now #2801

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
May 15, 2023
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: 2 additions & 1 deletion _overviews/toolkit/testing-asynchronous.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
6 changes: 4 additions & 2 deletions _overviews/toolkit/testing-exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
3 changes: 2 additions & 1 deletion _overviews/toolkit/testing-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
15 changes: 10 additions & 5 deletions _overviews/toolkit/testing-run-only.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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 %}
Expand Down
3 changes: 2 additions & 1 deletion _overviews/toolkit/testing-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
6 changes: 4 additions & 2 deletions _overviews/toolkit/testing-suite.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -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 %}
Expand Down
6 changes: 4 additions & 2 deletions _overviews/toolkit/testing-what-else.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand Down