diff --git a/src/test/scala/steps/annotation/toString.scala b/src/test/scala/steps/annotation/toString.scala new file mode 100644 index 0000000..d4dd521 --- /dev/null +++ b/src/test/scala/steps/annotation/toString.scala @@ -0,0 +1,31 @@ +package steps.annotation + +import scala.annotation.experimental +import scala.language.experimental.clauseInterleaving + +@toString +@experimental +class Foo1(val a: Int, val b: String) + +@toString +@experimental +class Foo2(a: Int, b: String) + +@toString +@experimental +class Foo3(var a: Int, var b: String) + +@toString +@experimental +class Foo4(a: Int, b: String)(c: Int) + +@experimental +class AssertToStringBehaviour extends munit.FunSuite: + + test("@toString works with all kinds of classes"): + assertEquals(Foo1(1, "hello").toString(), "Foo1(1, hello)") + assertEquals(Foo2(1, "hello").toString(), "Foo2(1, hello)") + assertEquals(Foo3(1, "hello").toString(), "Foo3(1, hello)") + assertEquals(Foo4(1, "hello")(2).toString(), "Foo4(1, hello, 2)") + +end AssertToStringBehaviour \ No newline at end of file