Skip to content

Commit 4ff1c0b

Browse files
committed
Merge branch 'cheeseng-pass-2.13-tests' into 3.1.x
2 parents 85c28c4 + 09667cf commit 4ff1c0b

File tree

20 files changed

+283
-330
lines changed

20 files changed

+283
-330
lines changed

project/GenColCompatHelper.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,18 @@ object GenColCompatHelper {
5555
|
5656
| object Factory {}
5757
|
58-
| def className(col: scala.collection.Iterable[_]): String = org.scalactic.NameUtil.getSimpleNameOfAnObjectsClass(col)
58+
| def className(col: scala.collection.Iterable[_]): String = {
59+
| val colToString = col.toString
60+
| val bracketIdx = colToString.indexOf("(")
61+
| if (bracketIdx >= 0)
62+
| colToString.take(bracketIdx)
63+
| else
64+
| org.scalactic.NameUtil.getSimpleNameOfAnObjectsClass(col)
65+
| }
5966
|
6067
| def newBuilder[A, C](f: Factory[A, C]): scala.collection.mutable.Builder[A, C] = f.newBuilder
68+
|
69+
| type StringOps = scala.collection.StringOps
6170
|}
6271
|
6372
""".stripMargin
@@ -118,6 +127,8 @@ object GenColCompatHelper {
118127
| def className(col: scala.collection.GenTraversable[_]): String = col.stringPrefix
119128
|
120129
| def newBuilder[A, C](f: Factory[A, C]): scala.collection.mutable.Builder[A, C] = f.apply()
130+
|
131+
| type StringOps = scala.collection.immutable.StringOps
121132
|}
122133
|
123134
""".stripMargin

project/templates/Every.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ sealed abstract class Every[+T] protected (underlying: Vector[T]) extends Partia
537537
* That is, every key <code>k</code> is bound to an <code>Every</code> of those elements <code>x</code> for which <code>f(x)</code> equals <code>k</code>.
538538
* </p>
539539
*/
540-
final def groupBy[K](f: T => K): Map[K, Every[T]] = {
540+
final def groupBy[K](f: T => K) = {
541541
val mapKToVec = underlying.groupBy(f)
542-
mapKToVec.mapValues { vec => Every(vec.head, vec.tail: _*) }
542+
(mapKToVec.mapValues { vec => Every(vec.head, vec.tail: _*) }).toMap
543543
}
544544

545545
/**

scalactic-macro/src/main/resources/org/scalactic/ScalacticBundle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,5 @@ notLiteralFiniteFloat=PosFiniteFloat.apply can only be invoked on a floating poi
107107
notValidFiniteDouble=PosFiniteDouble.apply can only be invoked on a finite (n != Double.PositiveInfinity && n != Double.NegativeInfinity) floating point literal, like FiniteDouble(42.0).
108108
notLiteralFiniteDouble=PosFiniteDouble.apply can only be invoked on a floating point literal, like FiniteDouble(42.0). Please use FiniteDouble.from instead.
109109
notValidNumericChar=NumericChar.apply can only be invoked on Char literals that are numbers, like '8'.
110-
notLiteralNumericChar=NumericChar.apply can only be invoked on Char literals that are numbers, like '8'. Please use NumericChar.from instead.
110+
notLiteralNumericChar=NumericChar.apply can only be invoked on Char literals that are numbers, like '8'. Please use NumericChar.from instead.
111+
invalidSize=Invalid size: {0}

scalactic-macro/src/main/scala/org/scalactic/anyvals/NumericString.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,8 @@ final class NumericString private (val value: String) extends AnyVal {
950950
* defined and collecting the results. The
951951
* order of the elements is preserved.
952952
*/
953-
def collect[B](pf: PartialFunction[Char, B]): String =
954-
value.collect(pf).mkString
953+
def collect(pf: PartialFunction[Char, Char]) =
954+
value.collect(pf)
955955

956956
/**
957957
* Finds the first character of the `NumericString` for
@@ -1908,32 +1908,30 @@ final class NumericString private (val value: String) extends AnyVal {
19081908
* @return a new string containing the prefix scan of the
19091909
* elements in this `NumericString`
19101910
*/
1911-
def scan[B >: Char](z: B)(op: (B, B) B): IndexedSeq[B] =
1911+
def scan(z: Char)(op: (Char, Char) Char) =
19121912
value.scan(z)(op)
19131913

19141914
/** Produces a collection containing cumulative results of applying the
19151915
* operator going left to right.
19161916
*
1917-
* @tparam B the type of the elements in the resulting collection
19181917
* @param z the initial value
19191918
* @param op the binary operator applied to the intermediate
19201919
* result and the element
19211920
* @return collection with intermediate results
19221921
*/
1923-
def scanLeft[B](z: B)(op: (B, Char) B): IndexedSeq[B] =
1922+
def scanLeft(z: String)(op: (String, Char) String) =
19241923
value.scanLeft(z)(op)
19251924

19261925
/** Produces a collection containing cumulative results of
19271926
* applying the operator going right to left. The head of
19281927
* the collection is the last cumulative result.
19291928
*
1930-
* @tparam B the type of the elements in the resulting collection
19311929
* @param z the initial value
19321930
* @param op the binary operator applied to the intermediate
19331931
* result and the element
19341932
* @return collection with intermediate results
19351933
*/
1936-
def scanRight[B](z: B)(op: (Char, B) B): IndexedSeq[B] =
1934+
def scanRight(z: String)(op: (Char, String) String) =
19371935
value.scanRight(z)(op)
19381936

19391937

@@ -2393,7 +2391,7 @@ final class NumericString private (val value: String) extends AnyVal {
23932391
* `NumericString` followed by all elements
23942392
* of `that`.
23952393
*/
2396-
def union[B >: Char](that: Seq[B]): IndexedSeq[B] =
2394+
def union(that: Seq[Char]) =
23972395
value.union(that)
23982396

23992397
/** A copy of this `NumericString` with one single replaced element.

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

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -555,65 +555,71 @@ class ChainSpec extends UnitSpec {
555555
}
556556
}
557557
it should "have 2 indexOfSlice methods that take a GenSeq" in {
558-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3)) shouldBe 1
559-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3) shouldBe -1
560-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3) shouldBe -1
561-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5)) shouldBe -1
562-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(5)) shouldBe 4
563-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5)) shouldBe 0
564-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0) shouldBe 0
565-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1) shouldBe -1
566-
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1) shouldBe 0
567-
Chain(1, 2, 3, 4, 5).indexOfSlice(List.empty) shouldBe 0
568-
Chain(1, 2, 3, 4, 5).indexOfSlice(List.empty, 6) shouldBe -1
569-
Chain(1, 2, 3, 4, 5).indexOfSlice(List.empty, 4) shouldBe 4
558+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3))
559+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3)
560+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3)
561+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5))
562+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(5))
563+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5))
564+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0)
565+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1)
566+
Chain(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1)
567+
Chain(1, 2, 3, 4, 5).indexOfSlice(List.empty) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List.empty)
568+
Chain(1, 2, 3, 4, 5).indexOfSlice(List.empty, 6) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List.empty, 6)
569+
Chain(1, 2, 3, 4, 5).indexOfSlice(List.empty, 4) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List.empty, 4)
570570

571571
val es = Chain("one", "two", "three", "four", "five")
572-
es.indexOfSlice(List("one", "two")) shouldBe 0;
573-
es.indexOfSlice(List("one", "two"), 1) shouldBe -1
574-
es.indexOfSlice(List("ONE", "TWO")) shouldBe -1;
572+
val el = List("one", "two", "three", "four", "five")
573+
es.indexOfSlice(List("one", "two")) shouldBe el.indexOfSlice(List("one", "two"))
574+
es.indexOfSlice(List("one", "two"), 1) shouldBe el.indexOfSlice(List("one", "two"), 1)
575+
es.indexOfSlice(List("ONE", "TWO")) shouldBe el.indexOfSlice(List("ONE", "TWO"))
576+
575577
{
576578
implicit val strEq = StringNormalizations.lowerCased.toEquality
577-
es.indexOfSlice(List("one", "two")) shouldBe 0;
579+
es.indexOfSlice(List("one", "two")) shouldBe 0
578580
es.indexOfSlice(List("ONE", "TWO")) shouldBe -1
579581
}
580582
}
581583
it should "have 2 indexOfSlice methods that take an Every" in {
582-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3)) shouldBe 1
583-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3), 3) shouldBe -1
584-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3, 5), 3) shouldBe -1
585-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3, 5)) shouldBe -1
586-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(5)) shouldBe 4
587-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5)) shouldBe 0
588-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), 0) shouldBe 0
589-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), 1) shouldBe -1
590-
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), -1) shouldBe 0
584+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3))
585+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3), 3)
586+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3, 5), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3, 5), 3)
587+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3, 5))
588+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(5))
589+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5))
590+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), 0) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), 0)
591+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), 1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), 1)
592+
Chain(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), -1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(Every(1, 2, 3, 4, 5), -1)
591593

592594
val es = Chain("one", "two", "three", "four", "five")
593-
es.indexOfSlice(Every("one", "two")) shouldBe 0;
594-
es.indexOfSlice(Every("one", "two"), 1) shouldBe -1
595-
es.indexOfSlice(Every("ONE", "TWO")) shouldBe -1;
595+
val el = List("one", "two", "three", "four", "five")
596+
es.indexOfSlice(Every("one", "two")) shouldBe el.indexOfSlice(Every("one", "two"))
597+
es.indexOfSlice(Every("one", "two"), 1) shouldBe el.indexOfSlice(Every("one", "two"), 1)
598+
es.indexOfSlice(Every("ONE", "TWO")) shouldBe el.indexOfSlice(Every("ONE", "TWO"))
599+
596600
{
597601
implicit val strEq = StringNormalizations.lowerCased.toEquality
598602
es.indexOfSlice(Every("one", "two")) shouldBe 0;
599603
es.indexOfSlice(Every("ONE", "TWO")) shouldBe -1
600604
}
601605
}
602606
it should "have 2 indexOfSlice methods that take a Chain" in {
603-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3)) shouldBe 1
604-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3), 3) shouldBe -1
605-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3, 5), 3) shouldBe -1
606-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3, 5)) shouldBe -1
607-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(5)) shouldBe 4
608-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5)) shouldBe 0
609-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5), 0) shouldBe 0
610-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5), 1) shouldBe -1
611-
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5), -1) shouldBe 0
607+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3))
608+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3)
609+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3, 5), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3)
610+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(2, 3, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5))
611+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(5))
612+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5))
613+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5), 0) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0)
614+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5), 1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1)
615+
Chain(1, 2, 3, 4, 5).indexOfSlice(Chain(1, 2, 3, 4, 5), -1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1)
612616

613617
val es = Chain("one", "two", "three", "four", "five")
614-
es.indexOfSlice(Chain("one", "two")) shouldBe 0;
615-
es.indexOfSlice(Chain("one", "two"), 1) shouldBe -1
616-
es.indexOfSlice(Chain("ONE", "TWO")) shouldBe -1;
618+
val el = Chain("one", "two", "three", "four", "five")
619+
es.indexOfSlice(Chain("one", "two")) shouldBe el.indexOfSlice(List("one", "two"))
620+
es.indexOfSlice(Chain("one", "two"), 1) shouldBe el.indexOfSlice(List("one", "two"), 1)
621+
es.indexOfSlice(Chain("ONE", "TWO")) shouldBe el.indexOfSlice(List("ONE", "TWO"))
622+
617623
{
618624
implicit val strEq = StringNormalizations.lowerCased.toEquality
619625
es.indexOfSlice(Chain("one", "two")) shouldBe 0;

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -480,18 +480,18 @@ class EverySpec extends UnitSpec {
480480
Every(1, 2, 3, 4, 5).indexOf(5, 3) shouldBe 4
481481
}
482482
it should "have 2 indexOfSlice methods that take a GenSeq" in {
483-
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3)) shouldBe 1
484-
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3) shouldBe -1
485-
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3) shouldBe -1
486-
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5)) shouldBe -1
487-
Every(1, 2, 3, 4, 5).indexOfSlice(List(5)) shouldBe 4
488-
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5)) shouldBe 0
489-
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0) shouldBe 0
490-
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1) shouldBe -1
491-
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1) shouldBe 0
492-
Every(1, 2, 3, 4, 5).indexOfSlice(List.empty) shouldBe 0
493-
Every(1, 2, 3, 4, 5).indexOfSlice(List.empty, 6) shouldBe -1
494-
Every(1, 2, 3, 4, 5).indexOfSlice(List.empty, 4) shouldBe 4
483+
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3))
484+
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3), 3)
485+
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5), 3)
486+
Every(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(2, 3, 5))
487+
Every(1, 2, 3, 4, 5).indexOfSlice(List(5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(5))
488+
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5)) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5))
489+
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 0)
490+
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), 1)
491+
Every(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List(1, 2, 3, 4, 5), -1)
492+
Every(1, 2, 3, 4, 5).indexOfSlice(List.empty) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List.empty)
493+
Every(1, 2, 3, 4, 5).indexOfSlice(List.empty, 6) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List.empty, 6)
494+
Every(1, 2, 3, 4, 5).indexOfSlice(List.empty, 4) shouldBe List(1, 2, 3, 4, 5).indexOfSlice(List.empty, 4)
495495
}
496496
it should "have 2 indexOfSlice methods that take an Every" in {
497497
Every(1, 2, 3, 4, 5).indexOfSlice(Every(2, 3)) shouldBe 1

0 commit comments

Comments
 (0)