@@ -34,7 +34,7 @@ class MinByMaxByTest {
3434 * Any other exception is propagated.
3535 */
3636 def assertThrows [T <: Throwable : ClassTag ](body : => Any ,
37- checkMessage : String => Boolean = s => true ): Unit = {
37+ checkMessage : String => Boolean = s => true ): Unit = {
3838 assertThrown[T ](t => checkMessage(t.getMessage))(body)
3939 }
4040
@@ -49,7 +49,8 @@ class MinByMaxByTest {
4949 ae.addSuppressed(failed)
5050 throw ae
5151 case NonFatal (other) =>
52- val ae = new AssertionError (s " Wrong exception: expected ${implicitly[ClassTag [T ]]} but was ${other.getClass.getName}" )
52+ val ae = new AssertionError (
53+ s " Wrong exception: expected ${implicitly[ClassTag [T ]]} but was ${other.getClass.getName}" )
5354 ae.addSuppressed(other)
5455 throw ae
5556 }
@@ -65,21 +66,27 @@ class MinByMaxByTest {
6566 @ Test
6667 def testCorrectness () = {
6768 def f (x : Int ) = - 1 * x
68- val max = list.maxBy(f)
69- assertTrue(" f(list.maxBy(f)) should ≥ f(x) where x is any element of list." , list.forall(f(_) <= f(max)))
69+ val max = list.maxBy(f)
70+ assertTrue(" f(list.maxBy(f)) should ≥ f(x) where x is any element of list." ,
71+ list.forall(f(_) <= f(max)))
7072 val min = list.minBy(f)
71- assertTrue(" f(list.minBy(f)) should ≤ f(x) where x is any element of list." , list.forall(f(_) >= f(min)))
73+ assertTrue(" f(list.minBy(f)) should ≤ f(x) where x is any element of list." ,
74+ list.forall(f(_) >= f(min)))
7275 }
7376
7477 // Ensure that it always returns the first match if more than one element have the same largest/smallest f(x).
75- // Note that this behavior is not explicitly stated before.
78+ // Note that this behavior is not explicitly stated before.
7679 // To make it compatible with the previous implementation, I add this behavior to docs.
7780 @ Test
7881 def testReturnTheFirstMatch () = {
79- val d = List (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 )
82+ val d = List (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 )
8083 def f (x : Int ) = x % 3 ;
81- assert(d.maxBy(f) == 2 , " If multiple elements evaluated to the largest value, maxBy should return the first one." )
82- assert(d.minBy(f) == 3 , " If multiple elements evaluated to the largest value, minBy should return the first one." )
84+ assert(
85+ d.maxBy(f) == 2 ,
86+ " If multiple elements evaluated to the largest value, maxBy should return the first one." )
87+ assert(
88+ d.minBy(f) == 3 ,
89+ " If multiple elements evaluated to the largest value, minBy should return the first one." )
8390 }
8491
8592 // Make sure it evaluates f no more than list.length times.
@@ -91,15 +98,19 @@ class MinByMaxByTest {
9198 evaluatedCountOfMaxBy += 1
9299 x * 10
93100 })
94- assert(evaluatedCountOfMaxBy == list.length, s " maxBy: should evaluate f only ${list.length} times, but it evaluated $evaluatedCountOfMaxBy times. " )
101+ assert(
102+ evaluatedCountOfMaxBy == list.length,
103+ s " maxBy: should evaluate f only ${list.length} times, but it evaluated $evaluatedCountOfMaxBy times. " )
95104
96105 var evaluatedCountOfMinBy = 0
97106
98107 val min = list.minBy(x => {
99108 evaluatedCountOfMinBy += 1
100109 x * 10
101110 })
102- assert(evaluatedCountOfMinBy == list.length, s " minBy: should evaluate f only ${list.length} times, but it evaluated $evaluatedCountOfMinBy times. " )
111+ assert(
112+ evaluatedCountOfMinBy == list.length,
113+ s " minBy: should evaluate f only ${list.length} times, but it evaluated $evaluatedCountOfMinBy times. " )
103114 }
104115
105116 @ Test
@@ -125,6 +136,6 @@ class MinByMaxByTest {
125136 assert(seq.min.isNaN)
126137 assert(seq.max.isNaN)
127138 }
128- */
139+ */
129140
130141}
0 commit comments