Skip to content

Commit 8078a18

Browse files
committed
Fix anyvals test for Dotty
Tests about Float.NaN and Double.NaN are disabled due to the following bug: scala/scala3#6710
1 parent 2195e36 commit 8078a18

37 files changed

+532
-253
lines changed

project/GenScalacticDotty.scala

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,16 @@ object GenScalacticDotty {
9999
List(
100100
"BooleanMacro.scala", // Re-implemented
101101
"Requirements.scala", // Re-implemented
102-
"Snapshots.scala" // Pending macro re-implementation
102+
"Snapshots.scala" // Re-implemented
103103
)
104104
) ++
105105
copyDir("scalactic/src/main/scala/org/scalactic/exceptions", "org/scalactic/exceptions", targetDir, List.empty) ++
106106
copyDir("scalactic/src/main/scala/org/scalactic/source", "org/scalactic/source", targetDir,
107107
List(
108108
"Position.scala", // Re-implemented
109-
"TypeInfo.scala" // Pending macro re-implementation.
109+
"TypeInfo.scala" // Re-implemented
110110
)) ++
111-
copyFiles("scalactic/src/main/scala/org/scalactic/anyvals", "org/scalactic/anyvals", targetDir,
112-
List(
113-
"NonEmptyArray.scala",
114-
"NonEmptyList.scala",
115-
"End.scala"
116-
)
117-
)
111+
copyDir("scalactic/src/main/scala/org/scalactic/anyvals", "org/scalactic/anyvals", targetDir, List.empty)
118112

119113
def genMacroScala(targetDir: File, version: String, scalaVersion: String): Seq[File] =
120114
copyDir("scalactic-macro/src/main/scala/org/scalactic", "org/scalactic", targetDir,
@@ -127,7 +121,7 @@ object GenScalacticDotty {
127121
copyDir("scalactic-macro/src/main/scala/org/scalactic/source", "org/scalactic/source", targetDir,
128122
List(
129123
"PositionMacro.scala", // Already reimplemented in Position.scala
130-
"TypeInfoMacro.scala" // Not re-implemented yet
124+
"TypeInfoMacro.scala" // Already reimplemented
131125
)
132126
)
133127

@@ -152,7 +146,11 @@ object GenScalacticDotty {
152146
"TripleEqualsSpec.for210", // Old staff, we shall delete this soon.
153147
"FutureSugarSpec.scala" // instability, occasional timeout in CI
154148
)) ++
155-
//copyDir("scalactic-test/src/test/scala/org/scalactic/anyvals", "org/scalactic/anyvals", targetDir, List.empty) ++
149+
copyDir("scalactic-test/src/test/scala/org/scalactic/anyvals", "org/scalactic/anyvals", targetDir,
150+
List(
151+
"OddIntMacro.scala", // not used, scala2 macros
152+
"OddInt.scala" // not used, scala2 macros
153+
)) ++
156154
copyDir("scalactic-test/src/test/scala/org/scalactic/source", "org/scalactic/source", targetDir, List.empty)
157155

158156
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class ChainSpec extends UnitSpec {
291291
// SKIP-DOTTY-START
292292
// https://github.com/lampepfl/dotty/issues/6114
293293
{
294-
implicit val strEq = StringNormalizations.lowerCased.toEquality
294+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
295295
es.contains("one") shouldBe true;
296296
es.contains("ONE") shouldBe false
297297
}
@@ -554,7 +554,7 @@ class ChainSpec extends UnitSpec {
554554
// SKIP-DOTTY-START
555555
// https://github.com/lampepfl/dotty/issues/6114
556556
{
557-
implicit val strEq = StringNormalizations.lowerCased.toEquality
557+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
558558
es.indexOf("one") shouldBe 0;
559559
es.indexOf("ONE") shouldBe -1
560560
}
@@ -582,7 +582,7 @@ class ChainSpec extends UnitSpec {
582582
// SKIP-DOTTY-START
583583
// https://github.com/lampepfl/dotty/issues/6114
584584
{
585-
implicit val strEq = StringNormalizations.lowerCased.toEquality
585+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
586586
es.indexOfSlice(List("one", "two")) shouldBe 0
587587
es.indexOfSlice(List("ONE", "TWO")) shouldBe -1
588588
}
@@ -608,7 +608,7 @@ class ChainSpec extends UnitSpec {
608608
// SKIP-DOTTY-START
609609
// https://github.com/lampepfl/dotty/issues/6114
610610
{
611-
implicit val strEq = StringNormalizations.lowerCased.toEquality
611+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
612612
es.indexOfSlice(Every("one", "two")) shouldBe 0;
613613
es.indexOfSlice(Every("ONE", "TWO")) shouldBe -1
614614
}
@@ -634,7 +634,7 @@ class ChainSpec extends UnitSpec {
634634
// SKIP-DOTTY-START
635635
// https://github.com/lampepfl/dotty/issues/6114
636636
{
637-
implicit val strEq = StringNormalizations.lowerCased.toEquality
637+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
638638
es.indexOfSlice(Chain("one", "two")) shouldBe 0;
639639
es.indexOfSlice(Chain("ONE", "TWO")) shouldBe -1
640640
}
@@ -710,7 +710,7 @@ class ChainSpec extends UnitSpec {
710710
// SKIP-DOTTY-START
711711
// https://github.com/lampepfl/dotty/issues/6114
712712
{
713-
implicit val strEq = StringNormalizations.lowerCased.toEquality
713+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
714714
es.lastIndexOf("one") shouldBe 0
715715
es.lastIndexOf("ONE") shouldBe -1
716716
}
@@ -737,7 +737,7 @@ class ChainSpec extends UnitSpec {
737737
// SKIP-DOTTY-START
738738
// https://github.com/lampepfl/dotty/issues/6114
739739
{
740-
implicit val strEq = StringNormalizations.lowerCased.toEquality
740+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
741741
es.lastIndexOfSlice(List("one", "two")) shouldBe 0
742742
es.lastIndexOfSlice(List("ONE", "TWO")) shouldBe -1
743743
}
@@ -755,13 +755,13 @@ class ChainSpec extends UnitSpec {
755755
Chain(1, 2, 3, 4, 5).lastIndexOfSlice(Every(1, 2, 3, 4, 5), -1) shouldBe -1
756756

757757
val es = Chain("one", "two", "three", "four", "five")
758-
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0;
758+
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0
759759
es.lastIndexOfSlice(Every("two", "three"), 0) shouldBe -1
760760
es.lastIndexOfSlice(Every("ONE", "TWO")) shouldBe -1
761761
// SKIP-DOTTY-START
762762
// https://github.com/lampepfl/dotty/issues/6114
763763
{
764-
implicit val strEq = StringNormalizations.lowerCased.toEquality
764+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
765765
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0
766766
es.lastIndexOfSlice(Every("ONE", "TWO")) shouldBe -1
767767
}
@@ -785,7 +785,7 @@ class ChainSpec extends UnitSpec {
785785
// SKIP-DOTTY-START
786786
// https://github.com/lampepfl/dotty/issues/6114
787787
{
788-
implicit val strEq = StringNormalizations.lowerCased.toEquality
788+
implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
789789
es.lastIndexOfSlice(Chain("one", "two")) shouldBe 0
790790
es.lastIndexOfSlice(Chain("ONE", "TWO")) shouldBe -1
791791
}

scalactic-test/src/test/scala/org/scalactic/anyvals/FiniteDoubleSpec.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ class FiniteDoubleSpec extends FunSpec with Matchers with PropertyChecks with Ty
139139
FiniteDouble.goodOrElse(0.0)(i => i) shouldBe Good(FiniteDouble(0.0))
140140
FiniteDouble.goodOrElse(-1.1)(i => i) shouldBe Good(FiniteDouble(-1.1))
141141
FiniteDouble.goodOrElse(-99.0)(i => i) shouldBe Good(FiniteDouble(-99.0))
142+
// SKIP-DOTTY-START
143+
// not constant literal
142144
FiniteDouble.goodOrElse(Double.MinPositiveValue)(i => i) shouldBe Good(FiniteDouble(Double.MinPositiveValue))
145+
// SKIP-DOTTY-END
143146
}
144147
it("returns an error value produced by passing the given Double to the given function if the passed Double is NOT greater than 0, wrapped in a Bad") {
145148
FiniteDouble.goodOrElse(Double.NegativeInfinity)(i => s"$i did not taste good") shouldBe Bad("-Infinity did not taste good")
@@ -154,7 +157,10 @@ class FiniteDoubleSpec extends FunSpec with Matchers with PropertyChecks with Ty
154157
FiniteDouble.rightOrElse(0.0)(i => i) shouldBe Right(FiniteDouble(0.0))
155158
FiniteDouble.rightOrElse(-1.1)(i => i) shouldBe Right(FiniteDouble(-1.1))
156159
FiniteDouble.rightOrElse(-99.9)(i => i) shouldBe Right(FiniteDouble(-99.9))
160+
// SKIP-DOTTY-START
161+
// not constant literal
157162
FiniteDouble.rightOrElse(Double.MinPositiveValue)(i => i) shouldBe Right(FiniteDouble(Double.MinPositiveValue))
163+
// SKIP-DOTTY-END
158164
}
159165
it("returns an error value produced by passing the given Double to the given function if the passed Double is infinite, wrapped in a Left") {
160166
FiniteDouble.rightOrElse(Double.NegativeInfinity)(i => s"$i did not taste good") shouldBe Left("-Infinity did not taste good")

scalactic-test/src/test/scala/org/scalactic/anyvals/FiniteFloatSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ class FiniteFloatSpec extends FunSpec with Matchers with PropertyChecks with Typ
9191
it("throws AssertionError if the passed Float is infinite") {
9292
an [AssertionError] should be thrownBy FiniteFloat.ensuringValid(Float.PositiveInfinity)
9393
an [AssertionError] should be thrownBy FiniteFloat.ensuringValid(Float.NegativeInfinity)
94+
// SKIP-DOTTY-START
95+
// https://github.com/lampepfl/dotty/issues/6710
9496
an [AssertionError] should be thrownBy FiniteFloat.ensuringValid(Float.NaN)
97+
// SKIP-DOTTY-END
9598
}
9699
}
97100
describe("should offer a tryingValid factory method that") {

scalactic-test/src/test/scala/org/scalactic/anyvals/NegDoubleSpec.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ class NegDoubleSpec extends FunSpec with Matchers with PropertyChecks with TypeC
7474
an [AssertionError] should be thrownBy NegDouble.ensuringValid(0.00001)
7575
an [AssertionError] should be thrownBy NegDouble.ensuringValid(99.9)
7676
an [AssertionError] should be thrownBy NegDouble.ensuringValid(Double.PositiveInfinity)
77+
// SKIP-DOTTY-START
78+
// https://github.com/lampepfl/dotty/issues/6710
7779
an [AssertionError] should be thrownBy NegDouble.ensuringValid(Double.NaN)
80+
// SKIP-DOTTY-END
7881
}
7982
}
8083
describe("should offer a tryingValid factory method that") {
@@ -380,7 +383,10 @@ class NegDoubleSpec extends FunSpec with Matchers with PropertyChecks with TypeC
380383
NegDouble(-33.0).ensuringValid(_ => Double.NegativeInfinity) shouldEqual NegDouble.ensuringValid(Double.NegativeInfinity)
381384
an [AssertionError] should be thrownBy { NegDouble.MaxValue.ensuringValid(_ - NegDouble.MaxValue) }
382385
an [AssertionError] should be thrownBy { NegDouble.MaxValue.ensuringValid(_ => Double.PositiveInfinity) }
386+
// SKIP-DOTTY-START
387+
// https://github.com/lampepfl/dotty/issues/6710
383388
an [AssertionError] should be thrownBy { NegDouble.MaxValue.ensuringValid(_ => Double.NaN) }
389+
// SKIP-DOTTY-END
384390
}
385391
}
386392
}

scalactic-test/src/test/scala/org/scalactic/anyvals/NegFiniteDoubleSpec.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ class NegFiniteDoubleSpec extends FunSpec with Matchers with PropertyChecks with
7474
an [AssertionError] should be thrownBy NegFiniteDouble.ensuringValid(99.9)
7575
an [AssertionError] should be thrownBy NegFiniteDouble.ensuringValid(Double.PositiveInfinity)
7676
an [AssertionError] should be thrownBy NegFiniteDouble.ensuringValid(Double.NegativeInfinity)
77+
// SKIP-DOTTY-START
78+
// https://github.com/lampepfl/dotty/issues/6710
7779
an [AssertionError] should be thrownBy NegFiniteDouble.ensuringValid(Double.NaN)
80+
// SKIP-DOTTY-END
7881
}
7982
}
8083
describe("should offer a tryingValid factory method that") {
@@ -302,7 +305,10 @@ class NegFiniteDoubleSpec extends FunSpec with Matchers with PropertyChecks with
302305
an [AssertionError] should be thrownBy { NegFiniteDouble.MaxValue.ensuringValid(_ - NegFiniteDouble.MaxValue) }
303306
an [AssertionError] should be thrownBy { NegFiniteDouble.MaxValue.ensuringValid(_ => Double.PositiveInfinity) }
304307
an [AssertionError] should be thrownBy { NegFiniteDouble.MaxValue.ensuringValid(_ => Double.NegativeInfinity) }
308+
// SKIP-DOTTY-START
309+
// https://github.com/lampepfl/dotty/issues/6710
305310
an [AssertionError] should be thrownBy { NegFiniteDouble.MaxValue.ensuringValid(_ => Double.NaN) }
311+
// SKIP-DOTTY-END
306312
}
307313
}
308314
}

scalactic-test/src/test/scala/org/scalactic/anyvals/NegFiniteFloatSpec.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ trait NegFiniteFloatSpecSupport {
3939
case Success(bFloat: Float) if bFloat.isNaN => true
4040
case _ => false
4141
}
42-
case Success(double: Double) if double.isNaN =>
42+
case Success(double: Double) if double.isNaN =>
4343
b match {
4444
case Success(bDouble: Double) if bDouble.isNaN => true
4545
case _ => false
@@ -79,7 +79,10 @@ class NegFiniteFloatSpec extends FunSpec with Matchers with PropertyChecks with
7979
an [AssertionError] should be thrownBy NegFiniteFloat.ensuringValid(99.9F)
8080
an [AssertionError] should be thrownBy NegFiniteFloat.ensuringValid(Float.PositiveInfinity)
8181
an [AssertionError] should be thrownBy NegFiniteFloat.ensuringValid(Float.NegativeInfinity)
82+
// SKIP-DOTTY-START
83+
// https://github.com/lampepfl/dotty/issues/6710
8284
an [AssertionError] should be thrownBy NegFiniteFloat.ensuringValid(Float.NaN)
85+
// SKIP-DOTTY-END
8386
}
8487
}
8588
describe("should offer a tryingValid factory method that") {
@@ -284,6 +287,9 @@ class NegFiniteFloatSpec extends FunSpec with Matchers with PropertyChecks with
284287
an [AssertionError] should be thrownBy { NegFiniteFloat.MaxValue.ensuringValid(_ - NegFiniteFloat.MaxValue) }
285288
an [AssertionError] should be thrownBy { NegFiniteFloat.MaxValue.ensuringValid(_ => Float.PositiveInfinity) }
286289
an [AssertionError] should be thrownBy { NegFiniteFloat.MaxValue.ensuringValid(_ => Float.NegativeInfinity) }
290+
// SKIP-DOTTY-START
291+
// https://github.com/lampepfl/dotty/issues/6710
287292
an [AssertionError] should be thrownBy { NegFiniteFloat.MaxValue.ensuringValid(_ => Float.NaN) }
293+
// SKIP-DOTTY-END
288294
}
289295
}

scalactic-test/src/test/scala/org/scalactic/anyvals/NegFloatSpec.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ trait NegFloatSpecSupport {
3939
case Success(bFloat: Float) if bFloat.isNaN => true
4040
case _ => false
4141
}
42-
case Success(double: Double) if double.isNaN =>
42+
case Success(double: Double) if double.isNaN =>
4343
b match {
4444
case Success(bDouble: Double) if bDouble.isNaN => true
4545
case _ => false
@@ -79,7 +79,10 @@ class NegFloatSpec extends FunSpec with Matchers with PropertyChecks with TypeCh
7979
an [AssertionError] should be thrownBy NegFloat.ensuringValid(0.00001F)
8080
an [AssertionError] should be thrownBy NegFloat.ensuringValid(99.9F)
8181
an [AssertionError] should be thrownBy NegFloat.ensuringValid(Float.PositiveInfinity)
82+
// SKIP-DOTTY-START
83+
// https://github.com/lampepfl/dotty/issues/6710
8284
an [AssertionError] should be thrownBy NegFloat.ensuringValid(Float.NaN)
85+
// SKIP-DOTTY-END
8386
}
8487
}
8588
describe("should offer a tryingValid factory method that") {
@@ -372,6 +375,9 @@ class NegFloatSpec extends FunSpec with Matchers with PropertyChecks with TypeCh
372375
NegFloat(-33.0f).ensuringValid(_ => Float.NegativeInfinity) shouldEqual NegFloat.ensuringValid(Float.NegativeInfinity)
373376
an [AssertionError] should be thrownBy { NegFloat.MaxValue.ensuringValid(_ - NegFloat.MaxValue) }
374377
an [AssertionError] should be thrownBy { NegFloat.MaxValue.ensuringValid(_ => Float.PositiveInfinity) }
378+
// SKIP-DOTTY-START
379+
// https://github.com/lampepfl/dotty/issues/6710
375380
an [AssertionError] should be thrownBy { NegFloat.MaxValue.ensuringValid(_ => Float.NaN) }
381+
// SKIP-DOTTY-END
376382
}
377383
}

scalactic-test/src/test/scala/org/scalactic/anyvals/NegIntSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ class NegIntSpec extends FunSpec with Matchers with GeneratorDrivenPropertyCheck
150150
}
151151
it("should offer MaxValue and MinValue factory methods") {
152152
NegInt.MaxValue shouldEqual NegInt.from(-1).get
153+
// SKIP-DOTTY-START
154+
// not constant literal
153155
NegInt.MinValue shouldEqual NegInt(Int.MinValue)
156+
// SKIP-DOTTY-END
154157
}
155158

156159
it("should be sortable") {

scalactic-test/src/test/scala/org/scalactic/anyvals/NegLongSpec.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ class NegLongSpec extends FunSpec with Matchers with GeneratorDrivenPropertyChec
149149
}
150150
it("should offer MaxValue and MinValue factory methods") {
151151
NegLong.MaxValue shouldEqual NegLong.from(-1L).get
152+
// SKIP-DOTTY-START
153+
// not constant literal
152154
NegLong.MinValue shouldEqual NegLong(Long.MinValue)
155+
// SKIP-DOTTY-END
153156
}
154157

155158
it("should be sortable") {

0 commit comments

Comments
 (0)