-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
165 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") | ||
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") | ||
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.12.0") | ||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import munit.FunSuite | ||
|
||
class Scala3Tests extends FunSuite: | ||
test("an enum made of constants should have a normal toString") { | ||
assertEquals( | ||
ScalaVersion.Scala2.toString, | ||
// https://github.com/polyvariant/better-tostring/issues/60 | ||
// should be "ScalaVersion.Scala2" | ||
"Scala2" | ||
) | ||
assertEquals( | ||
ScalaVersion.Scala3.toString, | ||
// https://github.com/polyvariant/better-tostring/issues/60 | ||
// should be "ScalaVersion.Scala3" | ||
"Scala3" | ||
) | ||
} | ||
|
||
test("an enum being an ADT should get a custom toString") { | ||
assertEquals( | ||
User.LoggedIn("admin").toString, | ||
"User.LoggedIn(name = admin)" | ||
) | ||
assertEquals( | ||
User.Unauthorized.toString, | ||
// https://github.com/polyvariant/better-tostring/issues/60 | ||
// should be "User.Unauthorized" | ||
"Unauthorized" | ||
) | ||
} | ||
|
||
test("an enum with a custom toString should use it") { | ||
assertEquals( | ||
EnumCustomTostring.SimpleCase.toString, | ||
"example" | ||
) | ||
|
||
// https://github.com/polyvariant/better-tostring/issues/34 | ||
// we aren't there yet - need to be able to find inherited `toString`s first | ||
assertEquals( | ||
EnumCustomTostring.ParameterizedCase("foo").toString, | ||
// Should be "example" because the existing toString should take precedence. | ||
// Update the test when #34 is fixed. | ||
"EnumCustomTostring.ParameterizedCase(value = foo)" | ||
) | ||
} | ||
|
||
enum ScalaVersion: | ||
case Scala2, Scala3 | ||
|
||
enum EnumCustomTostring: | ||
case SimpleCase | ||
case ParameterizedCase(value: String) | ||
override def toString: String = "example" | ||
|
||
enum User: | ||
case LoggedIn(name: String) | ||
case Unauthorized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters