Skip to content

Commit 21952c8

Browse files
committed
Merge branch 'liufengyun-3.1.x-3' into 3.1.x
2 parents 7ccf348 + 94d5031 commit 21952c8

File tree

57 files changed

+1249
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1249
-890
lines changed

project/GenScalacticDotty.scala

Lines changed: 11 additions & 23 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

@@ -149,20 +143,14 @@ object GenScalacticDotty {
149143
def genTest(targetDir: File, version: String, scalaVersion: String): Seq[File] =
150144
copyDir("scalactic-test/src/test/scala/org/scalactic", "org/scalactic", targetDir,
151145
List(
152-
"ChainSpec.scala", // Compilation error to be investigated further
153-
"DecidersSpec.scala", // Compilation error to be investigated further
154-
"DifferSpec.scala", // Test failed when run to be investigate further.
155-
"DirectRequirementsSpec.scala", // macro expansion error: invalid prefix NoType
156-
"EverySpec.scala", // Compilation error to be investigated further
157-
"NormalizationSpec.scala", // Compilation error to be investigated further.
158-
"NormMethodsSpec.scala", // Compilation error to be investigated further.
159-
"OrSpec.scala", // Compilation error to be investigated further.
160-
"PrettifierSpec.scala", // Test failed with java.lang.IllegalAccessException
161-
"RequirementsSpec.scala", // Error during macro expansion
162-
"TolerantEquivalenceSpec.scala", // Compilation error to be investigated further.
163-
"TripleEqualsSpec.for210" // Old staff, we shall delete this soon.
146+
"TripleEqualsSpec.for210", // Old staff, we shall delete this soon.
147+
"FutureSugarSpec.scala" // instability, occasional timeout in CI
148+
)) ++
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
164153
)) ++
165-
//copyDir("scalactic-test/src/test/scala/org/scalactic/anyvals", "org/scalactic/anyvals", targetDir, List.empty) ++
166154
copyDir("scalactic-test/src/test/scala/org/scalactic/source", "org/scalactic/source", targetDir, List.empty)
167155

168156
}

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

Lines changed: 79 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ class ChainSpec extends UnitSpec {
135135
}
136136
}
137137
it should "have an apply method" in {
138-
Chain(1, 2, 3)(0) shouldEqual 1
139-
Chain(1, 2, 3)(1) shouldEqual 2
138+
Chain(1, 2, 3)(0) shouldEqual 1
139+
Chain(1, 2, 3)(1) shouldEqual 2
140140
Chain("hi")(0) shouldEqual "hi"
141141
Chain(7, 8, 9)(2) shouldEqual 9
142142
the [IndexOutOfBoundsException] thrownBy {
@@ -257,7 +257,7 @@ class ChainSpec extends UnitSpec {
257257
// Could have an implicit conversion from Every[Char] to CharSequence like
258258
// there is for Seq in Predef.
259259
/*
260-
scala> Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).collect { case i if i > 10 == 0 => i / 2 }
260+
scala> Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).collect { case i if i > 10 == 0 => i / 2 }
261261
res1: scala.collection.immutable.Vector[Int] = Vector()
262262
*/
263263
it should "have an collectFirst method" in {
@@ -286,13 +286,15 @@ class ChainSpec extends UnitSpec {
286286
e.contains(3) shouldBe true
287287
e.contains(4) shouldBe false
288288
val es = Chain("one", "two", "three")
289+
es.contains("one") shouldBe true
290+
es.contains("ONE") shouldBe false
291+
// SKIP-DOTTY-START
292+
// https://github.com/lampepfl/dotty/issues/6114
293+
implicit val strEq = StringNormalizations.lowerCased.toEquality
294+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
289295
es.contains("one") shouldBe true;
290-
es.contains("ONE") shouldBe false;
291-
{
292-
implicit val strEq = StringNormalizations.lowerCased.toEquality
293-
es.contains("one") shouldBe true;
294-
es.contains("ONE") shouldBe false
295-
}
296+
es.contains("ONE") shouldBe false
297+
// SKIP-DOTTY-END
296298
}
297299
// Decided to just overload one for GenSeq and one for Every. Could have done
298300
// what that has a Slicing nature, but that's a bit too fancy pants.
@@ -380,7 +382,7 @@ class ChainSpec extends UnitSpec {
380382
}
381383

382384
/*
383-
it should not have an drop method
385+
it should not have an drop method
384386
scala> Vector(1, 2, 3).drop(3)
385387
res1: scala.collection.immutable.Vector[Int] = Vector()
386388
@@ -545,14 +547,16 @@ class ChainSpec extends UnitSpec {
545547
Chain(1, 2, 3, 4, 5).indexOf(5, 3) shouldBe 4
546548

547549
val es = Chain("one", "two", "three")
548-
es.indexOf("one") shouldBe 0;
550+
es.indexOf("one") shouldBe 0
549551
es.indexOf("one", 1) shouldBe -1
550-
es.indexOf("ONE") shouldBe -1;
551-
{
552-
implicit val strEq = StringNormalizations.lowerCased.toEquality
553-
es.indexOf("one") shouldBe 0;
554-
es.indexOf("ONE") shouldBe -1
555-
}
552+
es.indexOf("ONE") shouldBe -1
553+
// SKIP-DOTTY-START
554+
// https://github.com/lampepfl/dotty/issues/6114
555+
implicit val strEq = StringNormalizations.lowerCased.toEquality
556+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
557+
es.indexOf("one") shouldBe 0;
558+
es.indexOf("ONE") shouldBe -1
559+
// SKIP-DOTTY-END
556560
}
557561
it should "have 2 indexOfSlice methods that take a GenSeq" in {
558562
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3))
@@ -573,12 +577,13 @@ class ChainSpec extends UnitSpec {
573577
es.indexOfSlice(List("one", "two")) shouldBe el.indexOfSlice(List("one", "two"))
574578
es.indexOfSlice(List("one", "two"), 1) shouldBe el.indexOfSlice(List("one", "two"), 1)
575579
es.indexOfSlice(List("ONE", "TWO")) shouldBe el.indexOfSlice(List("ONE", "TWO"))
576-
577-
{
578-
implicit val strEq = StringNormalizations.lowerCased.toEquality
579-
es.indexOfSlice(List("one", "two")) shouldBe 0
580-
es.indexOfSlice(List("ONE", "TWO")) shouldBe -1
581-
}
580+
// SKIP-DOTTY-START
581+
// https://github.com/lampepfl/dotty/issues/6114
582+
implicit val strEq = StringNormalizations.lowerCased.toEquality
583+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
584+
es.indexOfSlice(List("one", "two")) shouldBe 0
585+
es.indexOfSlice(List("ONE", "TWO")) shouldBe -1
586+
// SKIP-DOTTY-END
582587
}
583588
it should "have 2 indexOfSlice methods that take an Every" in {
584589
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3))
@@ -597,11 +602,13 @@ class ChainSpec extends UnitSpec {
597602
es.indexOfSlice(Every("one", "two"), 1) shouldBe el.indexOfSlice(Every("one", "two"), 1)
598603
es.indexOfSlice(Every("ONE", "TWO")) shouldBe el.indexOfSlice(Every("ONE", "TWO"))
599604

600-
{
601-
implicit val strEq = StringNormalizations.lowerCased.toEquality
602-
es.indexOfSlice(Every("one", "two")) shouldBe 0;
603-
es.indexOfSlice(Every("ONE", "TWO")) shouldBe -1
604-
}
605+
// SKIP-DOTTY-START
606+
// https://github.com/lampepfl/dotty/issues/6114
607+
implicit val strEq = StringNormalizations.lowerCased.toEquality
608+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
609+
es.indexOfSlice(Every("one", "two")) shouldBe 0;
610+
es.indexOfSlice(Every("ONE", "TWO")) shouldBe -1
611+
// SKIP-DOTTY-END
605612
}
606613
it should "have 2 indexOfSlice methods that take a Chain" in {
607614
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3))
@@ -620,11 +627,13 @@ class ChainSpec extends UnitSpec {
620627
es.indexOfSlice(Chain("one", "two"), 1) shouldBe el.indexOfSlice(List("one", "two"), 1)
621628
es.indexOfSlice(Chain("ONE", "TWO")) shouldBe el.indexOfSlice(List("ONE", "TWO"))
622629

623-
{
624-
implicit val strEq = StringNormalizations.lowerCased.toEquality
625-
es.indexOfSlice(Chain("one", "two")) shouldBe 0;
626-
es.indexOfSlice(Chain("ONE", "TWO")) shouldBe -1
627-
}
630+
// SKIP-DOTTY-START
631+
// https://github.com/lampepfl/dotty/issues/6114
632+
implicit val strEq = StringNormalizations.lowerCased.toEquality
633+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
634+
es.indexOfSlice(Chain("one", "two")) shouldBe 0;
635+
es.indexOfSlice(Chain("ONE", "TWO")) shouldBe -1
636+
// SKIP-DOTTY-END
628637
}
629638
it should "have 2 indexWhere methods" in {
630639
Chain(1, 2, 3, 4, 5).indexWhere(_ == 3) shouldBe 2
@@ -692,12 +701,14 @@ class ChainSpec extends UnitSpec {
692701
es.lastIndexOf("two") shouldBe 1
693702
es.lastIndexOf("three") shouldBe 2
694703
es.lastIndexOf("three", 1) shouldBe -1
695-
es.lastIndexOf("ONE") shouldBe -1;
696-
{
697-
implicit val strEq = StringNormalizations.lowerCased.toEquality
698-
es.lastIndexOf("one") shouldBe 0;
699-
es.lastIndexOf("ONE") shouldBe -1
700-
}
704+
es.lastIndexOf("ONE") shouldBe -1
705+
// SKIP-DOTTY-START
706+
// https://github.com/lampepfl/dotty/issues/6114
707+
implicit val strEq = StringNormalizations.lowerCased.toEquality
708+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
709+
es.lastIndexOf("one") shouldBe 0
710+
es.lastIndexOf("ONE") shouldBe -1
711+
// SKIP-DOTTY-END
701712
}
702713
it should "have 2 lastIndexOfSlice methods that take a GenSeq" in {
703714
Chain(1, 2, 3, 4, 5).lastIndexOfSlice(List(2, 3)) shouldBe 1
@@ -716,12 +727,14 @@ class ChainSpec extends UnitSpec {
716727
val es = Chain("one", "two", "three", "four", "five")
717728
es.lastIndexOfSlice(List("one", "two")) shouldBe 0;
718729
es.lastIndexOfSlice(List("two", "three"), 0) shouldBe -1
719-
es.lastIndexOfSlice(List("ONE", "TWO")) shouldBe -1;
720-
{
721-
implicit val strEq = StringNormalizations.lowerCased.toEquality
722-
es.lastIndexOfSlice(List("one", "two")) shouldBe 0;
723-
es.lastIndexOfSlice(List("ONE", "TWO")) shouldBe -1
724-
}
730+
es.lastIndexOfSlice(List("ONE", "TWO")) shouldBe -1
731+
// SKIP-DOTTY-START
732+
// https://github.com/lampepfl/dotty/issues/6114
733+
implicit val strEq = StringNormalizations.lowerCased.toEquality
734+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
735+
es.lastIndexOfSlice(List("one", "two")) shouldBe 0
736+
es.lastIndexOfSlice(List("ONE", "TWO")) shouldBe -1
737+
// SKIP-DOTTY-END
725738
}
726739
it should "have 2 lastIndexOfSlice methods that take an Every" in {
727740
Chain(1, 2, 3, 4, 5).lastIndexOfSlice(Every(2, 3)) shouldBe 1
@@ -735,14 +748,16 @@ class ChainSpec extends UnitSpec {
735748
Chain(1, 2, 3, 4, 5).lastIndexOfSlice(Every(1, 2, 3, 4, 5), -1) shouldBe -1
736749

737750
val es = Chain("one", "two", "three", "four", "five")
738-
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0;
751+
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0
739752
es.lastIndexOfSlice(Every("two", "three"), 0) shouldBe -1
740-
es.lastIndexOfSlice(Every("ONE", "TWO")) shouldBe -1;
741-
{
742-
implicit val strEq = StringNormalizations.lowerCased.toEquality
743-
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0;
744-
es.lastIndexOfSlice(Every("ONE", "TWO")) shouldBe -1
745-
}
753+
es.lastIndexOfSlice(Every("ONE", "TWO")) shouldBe -1
754+
// SKIP-DOTTY-START
755+
// https://github.com/lampepfl/dotty/issues/6114
756+
implicit val strEq = StringNormalizations.lowerCased.toEquality
757+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
758+
es.lastIndexOfSlice(Every("one", "two")) shouldBe 0
759+
es.lastIndexOfSlice(Every("ONE", "TWO")) shouldBe -1
760+
// SKIP-DOTTY-END
746761
}
747762
it should "have 2 lastIndexOfSlice methods that take a Chain" in {
748763
Chain(1, 2, 3, 4, 5).lastIndexOfSlice(Chain(2, 3)) shouldBe 1
@@ -758,12 +773,14 @@ class ChainSpec extends UnitSpec {
758773
val es = Chain("one", "two", "three", "four", "five")
759774
es.lastIndexOfSlice(Chain("one", "two")) shouldBe 0;
760775
es.lastIndexOfSlice(Chain("two", "three"), 0) shouldBe -1
761-
es.lastIndexOfSlice(Chain("ONE", "TWO")) shouldBe -1;
762-
{
763-
implicit val strEq = StringNormalizations.lowerCased.toEquality
764-
es.lastIndexOfSlice(Chain("one", "two")) shouldBe 0;
765-
es.lastIndexOfSlice(Chain("ONE", "TWO")) shouldBe -1
766-
}
776+
es.lastIndexOfSlice(Chain("ONE", "TWO")) shouldBe -1
777+
// SKIP-DOTTY-START
778+
// https://github.com/lampepfl/dotty/issues/6114
779+
implicit val strEq = StringNormalizations.lowerCased.toEquality
780+
//DOTTY-ONLY implicit val strEq: NormalizingEquality[String] = StringNormalizations.lowerCased.toEquality
781+
es.lastIndexOfSlice(Chain("one", "two")) shouldBe 0
782+
es.lastIndexOfSlice(Chain("ONE", "TWO")) shouldBe -1
783+
// SKIP-DOTTY-END
767784
}
768785
it should "have 2 lastIndexWhere methods" in {
769786
Chain(1, 2, 3, 4, 5).lastIndexWhere(_ == 2) shouldBe 1
@@ -829,8 +846,11 @@ class ChainSpec extends UnitSpec {
829846
}
830847
it should "have a mkString method" in {
831848

849+
// SKIP-DOTTY-START
850+
// https://github.com/lampepfl/dotty/issues/6705
832851
Chain("hi").mkString shouldBe "hi"
833852
Chain(1, 2, 3).mkString shouldBe "123"
853+
// SKIP-DOTTY-END
834854

835855
Chain("hi").mkString("#") shouldBe "hi"
836856
Chain(1, 2, 3).mkString("#") shouldBe "1#2#3"
@@ -1217,7 +1237,7 @@ class ChainSpec extends UnitSpec {
12171237
scala> Vector(1, 2, 3).take(-1)
12181238
res12: scala.collection.immutable.Vector[Int] = Vector()
12191239
1220-
it should not have a takeRight method
1240+
it should not have a takeRight method
12211241
scala> Vector(1).takeRight(1)
12221242
res13: scala.collection.immutable.Vector[Int] = Vector(1)
12231243
scala> Vector(1).takeRight(0)

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,29 @@ import org.scalatest._
2020
class DecidersSpec extends FunSpec with Explicitly with StringNormalizations {
2121

2222
describe("The 'decided by' syntax") {
23-
it("should enable users to explicitly choose an Equality for a === use") {
24-
23+
it("should enable users to explicitly choose an Equality for a === use") {
2524
assert(3 === 3)
2625
assert(3 !== 4)
27-
implicit val e = new Equality[Int] {
28-
def areEqual(a: Int, b: Any): Boolean = a != b
26+
27+
{
28+
implicit val e: Equality[Int] = new Equality[Int] {
29+
def areEqual(a: Int, b: Any): Boolean = a != b
30+
}
31+
32+
assert(3 !== 3)
33+
assert(3 === 4)
34+
// And now with "decided by" to go back to defaultEquality
35+
assert((3 === 3) (decided by defaultEquality))
36+
assert(!(3 === 4) (decided by defaultEquality))
37+
assert((3 !== 4) (decided by defaultEquality))
38+
assert(!(3 !== 3) (decided by defaultEquality))
2939
}
30-
assert(3 !== 3)
31-
assert(3 === 4)
32-
// And now with "decided by" to go back to defaultEquality
33-
assert((3 === 3) (decided by defaultEquality))
34-
assert(!(3 === 4) (decided by defaultEquality))
35-
assert((3 !== 4) (decided by defaultEquality))
36-
assert(!(3 !== 3) (decided by defaultEquality))
3740
}
3841
}
3942

4043
describe("The 'after being' syntax") {
4144

42-
it("should enable users to explicitly choose a Normalization for a === use") {
45+
it("should enable users to explicitly choose a Normalization for a === use") {
4346

4447
assert("hello" !== "HELLO")
4548
assert(("hello" === "HELLo") (after being lowerCased))
@@ -53,7 +56,7 @@ class DecidersSpec extends FunSpec with Explicitly with StringNormalizations {
5356
assert(("hello" !== "Helloooo") (after being lowerCased))
5457
}
5558

56-
it("should enable users to explicitly build a Normalization for a === use by composing with 'and', with or without parens") {
59+
it("should enable users to explicitly build a Normalization for a === use by composing with 'and', with or without parens") {
5760

5861
assert("hello" !== "HELLO")
5962
assert(("hello" === " HELLo ") (after being (lowerCased and trimmed)))
@@ -74,7 +77,7 @@ class DecidersSpec extends FunSpec with Explicitly with StringNormalizations {
7477
assert((" HeLlO" === "HeLlO\n") (after being lowerCased and trimmed))
7578
}
7679

77-
it("should enable users to explicitly specify an equality and one or more normalizations") {
80+
it("should enable users to explicitly specify an equality and one or more normalizations") {
7881

7982
implicit val e = new Equality[String] {
8083
def areEqual(a: String, b: Any): Boolean = a != b

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class DifferSpec extends FunSpec {
293293
assert(
294294
ObjectDiffer.difference(a, b, Prettifier.default).analysis ==
295295
(
296-
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13")
296+
if (ScalacticVersions.BuiltForScalaVersion == "2.12" || ScalacticVersions.BuiltForScalaVersion == "2.13" || ScalacticVersions.BuiltForScalaVersion.startsWith("0."))
297297
Some("DifferSpec$Foo(b: List(0: 123 -> 1234, 1: 1234 -> ), bar: DifferSpec$Bar(i: 5 -> 66), parent: Some(value: DifferSpec$Bar(s: \"[asdf]\" -> \"[qwer]\")))")
298298
else
299299
Some("DifferSpec$Foo(b: List(0: 123 -> 1234, 1: 1234 -> ), bar: DifferSpec$Bar(i: 5 -> 66), parent: Some(x: DifferSpec$Bar(s: \"[asdf]\" -> \"[qwer]\")))")

0 commit comments

Comments
 (0)