Skip to content

Commit e8ab5db

Browse files
committed
Fix RequirementsSpec for Dotty
1 parent a6735d1 commit e8ab5db

File tree

2 files changed

+74
-25
lines changed

2 files changed

+74
-25
lines changed

project/GenScalacticDotty.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ object GenScalacticDotty {
149149
def genTest(targetDir: File, version: String, scalaVersion: String): Seq[File] =
150150
copyDir("scalactic-test/src/test/scala/org/scalactic", "org/scalactic", targetDir,
151151
List(
152-
"RequirementsSpec.scala", // Error during macro expansion
153152
"TolerantEquivalenceSpec.scala", // Compilation error to be investigated further.
154153
"TripleEqualsSpec.for210", // Old staff, we shall delete this soon.
155154
"FutureSugarSpec.scala" // instability, occasional timeout in CI

scalactic-test/src/test/scala/org/scalactic/RequirementsSpec.scala

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
6161
FailureMessages.wasLessThanOrEqualTo(prettifier, left, right)
6262

6363
def commaAnd(left: String, right: String): String =
64+
// SKIP-DOTTY-START
6465
FailureMessages.commaAnd(prettifier, UnquotedString(left), UnquotedString(right))
66+
// SKIP-DOTTY-END
67+
//DOTTY-ONLY FailureMessages.commaAnd(prettifier, left, right)
6568

6669
def commaBut(left: String, right: String): String =
70+
// SKIP-DOTTY-START
6771
FailureMessages.commaBut(prettifier, UnquotedString(left), UnquotedString(right))
72+
// SKIP-DOTTY-END
73+
//DOTTY-ONLY FailureMessages.commaBut(prettifier, left, right)
6874

6975
def wasFalse(left: String): String =
7076
left + " was false"
@@ -215,18 +221,18 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
215221
assert(e.getMessage == didNotEqual(a, b))
216222
}
217223

218-
it("should throw IllegalArgumentException when is used to check a == null") {
224+
it("should throw IllegalArgumentException when is used to check a == -1") {
219225
val e = intercept[IllegalArgumentException] {
220-
require(a == null)
226+
require(a == -1)
221227
}
222-
assert(e.getMessage == didNotEqual(a, null))
228+
assert(e.getMessage == didNotEqual(a, -1))
223229
}
224230

225-
it("should throw IllegalArgumentException when is used to check null == a") {
231+
it("should throw IllegalArgumentException when is used to check -1 == a") {
226232
val e = intercept[IllegalArgumentException] {
227-
require(null == a)
233+
require(-1 == a)
228234
}
229-
assert(e.getMessage == didNotEqual(null, a))
235+
assert(e.getMessage == didNotEqual(-1, a))
230236
}
231237

232238
it("should do nothing when is used to check a === 3") {
@@ -527,6 +533,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
527533
}
528534
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
529535
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")))
536+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
537+
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(3)" + lineSeparator + "}")))
530538
else
531539
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")))
532540
}
@@ -541,6 +549,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
541549
}
542550
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
543551
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)))
552+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
553+
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)))
544554
else
545555
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)))
546556
}
@@ -868,6 +878,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
868878
require(s4.isEmpty)
869879
}
870880

881+
// SKIP-DOTTY-START
882+
// TODO: missing support for `.isEmpty`, `.length`, `.size`, `.exists`, `.isInstanceOf`
871883
it("should throw IllegalArgumentException with correct message and stack depth when is used to check s3.isEmpty") {
872884
val e = intercept[IllegalArgumentException] {
873885
require(s3.isEmpty)
@@ -1170,6 +1182,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
11701182
}
11711183
assert(e.getMessage == wasFalse("ci1.exists(321)"))
11721184
}
1185+
// SKIP-DOTTY-END
11731186

11741187
def woof(f: => Unit) = "woof"
11751188
def meow(x: Int = 0, y: Int = 3) = "meow"
@@ -1201,6 +1214,9 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
12011214
""".stripMargin)
12021215
}
12031216

1217+
// SKIP-DOTTY-START
1218+
// ambiguous implicit:
1219+
// both method convertToCheckingEqualizer in trait TypeCheckedTripleEquals and method convertToEqualizer in trait TripleEquals provide an extension method `===` on String(org)
12041220
it("should compile when used with org === xxx with TypeCheckedTripleEquals that shadow org.scalactic") {
12051221
assertCompiles(
12061222
"""
@@ -1212,6 +1228,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
12121228
|}
12131229
""".stripMargin)
12141230
}
1231+
// SKIP-DOTTY-END
12151232

12161233
it("should compile when used with org.aCustomMethod that shadow org.scalactic") {
12171234
assertCompiles(
@@ -1350,18 +1367,18 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
13501367
assert(e.getMessage == didNotEqual(a, b) + ", dude")
13511368
}
13521369

1353-
it("should throw IllegalArgumentException when is used to check a == null") {
1370+
it("should throw IllegalArgumentException when is used to check a == -1") {
13541371
val e = intercept[IllegalArgumentException] {
1355-
require(a == null, ". dude")
1372+
require(a == -1, ". dude")
13561373
}
1357-
assert(e.getMessage == didNotEqual(a, null) + ". dude")
1374+
assert(e.getMessage == didNotEqual(a, -1) + ". dude")
13581375
}
13591376

1360-
it("should throw IllegalArgumentException when is used to check null == a") {
1377+
it("should throw IllegalArgumentException when is used to check -1 == a") {
13611378
val e = intercept[IllegalArgumentException] {
1362-
require(null == a, "; dude")
1379+
require(-1 == a, "; dude")
13631380
}
1364-
assert(e.getMessage == didNotEqual(null, a) + "; dude")
1381+
assert(e.getMessage == didNotEqual(-1, a) + "; dude")
13651382
}
13661383

13671384
it("should throw IllegalArgumentException when is used to check 3 != a") {
@@ -1673,6 +1690,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
16731690
}
16741691
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
16751692
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")) + ", dude")
1693+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
1694+
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(3)" + lineSeparator + "}")) + ", dude")
16761695
else
16771696
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")) + ", dude")
16781697
}
@@ -1687,6 +1706,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
16871706
}
16881707
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
16891708
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)) + ", dude")
1709+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
1710+
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)) + ", dude")
16901711
else
16911712
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)) + ", dude")
16921713
}
@@ -2014,6 +2035,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
20142035
require(s4.isEmpty, ", dude")
20152036
}
20162037

2038+
// SKIP-DOTTY-START
2039+
// TODO: missing support for `.isEmpty`, `.length`, `.size`, `.exists`, `.isInstanceOf`
20172040
it("should throw IllegalArgumentException with correct message and stack depth when is used to check s3.isEmpty") {
20182041
val e = intercept[IllegalArgumentException] {
20192042
require(s3.isEmpty, ", dude")
@@ -2316,6 +2339,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
23162339
}
23172340
assert(e.getMessage == wasFalse("ci1.exists(321)") + ", dude")
23182341
}
2342+
// SKIP-DOTTY-END
23192343

23202344
def woof(f: => Unit) = "woof"
23212345
def meow(x: Int = 0, y: Int = 3) = "meow"
@@ -2347,6 +2371,9 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
23472371
""".stripMargin)
23482372
}
23492373

2374+
// SKIP-DOTTY-START
2375+
// ambiguous implicit:
2376+
// both method convertToCheckingEqualizer in trait TypeCheckedTripleEquals and method convertToEqualizer in trait TripleEquals provide an extension method `===` on String(org)
23502377
it("should compile when used with org === xxx with TypeCheckedTripleEquals that shadow org.scalactic") {
23512378
assertCompiles(
23522379
"""
@@ -2358,6 +2385,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
23582385
|}
23592386
""".stripMargin)
23602387
}
2388+
// SKIP-DOTTY-END
23612389

23622390
it("should compile when used with org.aCustomMethod that shadow org.scalactic") {
23632391
assertCompiles(
@@ -2467,18 +2495,18 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
24672495
assert(e.getMessage == didNotEqual(a, b))
24682496
}
24692497

2470-
it("should throw IllegalStateException when is used to check a == null") {
2498+
it("should throw IllegalStateException when is used to check a == -1") {
24712499
val e = intercept[IllegalStateException] {
2472-
requireState(a == null)
2500+
requireState(a == -1)
24732501
}
2474-
assert(e.getMessage == didNotEqual(a, null))
2502+
assert(e.getMessage == didNotEqual(a, -1))
24752503
}
24762504

2477-
it("should throw IllegalStateException when is used to check null == a") {
2505+
it("should throw IllegalStateException when is used to check -1 == a") {
24782506
val e = intercept[IllegalStateException] {
2479-
requireState(null == a)
2507+
requireState(-1 == a)
24802508
}
2481-
assert(e.getMessage == didNotEqual(null, a))
2509+
assert(e.getMessage == didNotEqual(-1, a))
24822510
}
24832511

24842512
it("should do nothing when is used to check a === 3") {
@@ -2779,6 +2807,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
27792807
}
27802808
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
27812809
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")))
2810+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
2811+
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(3)" + lineSeparator + "}")))
27822812
else
27832813
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")))
27842814
}
@@ -2793,6 +2823,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
27932823
}
27942824
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
27952825
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)))
2826+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
2827+
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)))
27962828
else
27972829
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)))
27982830
}
@@ -3120,6 +3152,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
31203152
requireState(s4.isEmpty)
31213153
}
31223154

3155+
// SKIP-DOTTY-START
3156+
// TODO: missing support for `.isEmpty`, `.length`, `.size`, `.exists`, `.isInstanceOf`
31233157
it("should throw IllegalStateException with correct message and stack depth when is used to check s3.isEmpty") {
31243158
val e = intercept[IllegalStateException] {
31253159
requireState(s3.isEmpty)
@@ -3422,6 +3456,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
34223456
}
34233457
assert(e.getMessage == wasFalse("ci1.exists(321)"))
34243458
}
3459+
// SKIP-DOTTY-END
34253460

34263461
def woof(f: => Unit) = "woof"
34273462
def meow(x: Int = 0, y: Int = 3) = "meow"
@@ -3453,6 +3488,9 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
34533488
""".stripMargin)
34543489
}
34553490

3491+
// SKIP-DOTTY-START
3492+
// ambiguous implicit:
3493+
// both method convertToCheckingEqualizer in trait TypeCheckedTripleEquals and method convertToEqualizer in trait TripleEquals provide an extension method `===` on String(org)
34563494
it("should compile when used with org === xxx with TypeCheckedTripleEquals that shadow org.scalactic") {
34573495
assertCompiles(
34583496
"""
@@ -3464,6 +3502,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
34643502
|}
34653503
""".stripMargin)
34663504
}
3505+
// SKIP-DOTTY-END
34673506

34683507
it("should compile when used with org.aCustomMethod that shadow org.scalactic") {
34693508
assertCompiles(
@@ -3602,18 +3641,18 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
36023641
assert(e.getMessage == didNotEqual(a, b) + ", dude")
36033642
}
36043643

3605-
it("should throw IllegalStateException when is used to check a == null") {
3644+
it("should throw IllegalStateException when is used to check a == -1") {
36063645
val e = intercept[IllegalStateException] {
3607-
requireState(a == null, ". dude")
3646+
requireState(a == -1, ". dude")
36083647
}
3609-
assert(e.getMessage == didNotEqual(a, null) + ". dude")
3648+
assert(e.getMessage == didNotEqual(a, -1) + ". dude")
36103649
}
36113650

3612-
it("should throw IllegalStateException when is used to check null == a") {
3651+
it("should throw IllegalStateException when is used to check -1 == a") {
36133652
val e = intercept[IllegalStateException] {
3614-
requireState(null == a, "; dude")
3653+
requireState(-1 == a, "; dude")
36153654
}
3616-
assert(e.getMessage == didNotEqual(null, a) + "; dude")
3655+
assert(e.getMessage == didNotEqual(-1, a) + "; dude")
36173656
}
36183657

36193658
it("should throw IllegalStateException when is used to check 3 != a") {
@@ -3925,6 +3964,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
39253964
}
39263965
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
39273966
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")) + ", dude")
3967+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
3968+
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(3)" + lineSeparator + "}")) + ", dude")
39283969
else
39293970
assert(e.getMessage == commaBut(equaled(3, 3), wasFalse("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(3)" + lineSeparator + "}")) + ", dude")
39303971
}
@@ -3939,6 +3980,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
39393980
}
39403981
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
39413982
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)) + ", dude")
3983+
else if (ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
3984+
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.Predef.println(\"hi\")" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)) + ", dude")
39423985
else
39433986
assert(e.getMessage == commaBut(wasTrue("{" + lineSeparator + " scala.this.Predef.println(\"hi\");" + lineSeparator + " b.==(5)" + lineSeparator + "}"), didNotEqual(3, 5)) + ", dude")
39443987
}
@@ -4266,6 +4309,8 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
42664309
requireState(s4.isEmpty, ", dude")
42674310
}
42684311

4312+
// SKIP-DOTTY-START
4313+
// TODO: missing support for `.isEmpty`, `.length`, `.size`, `.exists`, `.isInstanceOf`
42694314
it("should throw IllegalStateException with correct message and stack depth when is used to check s3.isEmpty") {
42704315
val e = intercept[IllegalStateException] {
42714316
requireState(s3.isEmpty, ", dude")
@@ -4568,6 +4613,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
45684613
}
45694614
assert(e.getMessage == wasFalse("ci1.exists(321)") + ", dude")
45704615
}
4616+
// SKIP-DOTTY-END
45714617

45724618
def woof(f: => Unit) = "woof"
45734619
def meow(x: Int = 0, y: Int = 3) = "meow"
@@ -4599,6 +4645,9 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
45994645
""".stripMargin)
46004646
}
46014647

4648+
// SKIP-DOTTY-START
4649+
// ambiguous implicit:
4650+
// both method convertToCheckingEqualizer in trait TypeCheckedTripleEquals and method convertToEqualizer in trait TripleEquals provide an extension method `===` on String(org)
46024651
it("should compile when used with org === xxx with TypeCheckedTripleEquals that shadow org.scalactic") {
46034652
assertCompiles(
46044653
"""
@@ -4610,6 +4659,7 @@ class RequirementsSpec extends FunSpec with Requirements with OptionValues {
46104659
|}
46114660
""".stripMargin)
46124661
}
4662+
// SKIP-DOTTY-END
46134663

46144664
it("should compile when used with org.aCustomMethod that shadow org.scalactic") {
46154665
assertCompiles(

0 commit comments

Comments
 (0)