Skip to content

Commit 23b01a3

Browse files
witgorxin
authored andcommitted
Resolve sbt warnings during build Ⅱ
Author: witgo <[email protected]> Closes #1153 from witgo/expectResult and squashes the following commits: 97541d8 [witgo] merge master ead26e7 [witgo] Resolve sbt warnings during build (cherry picked from commit 3cd5029) Signed-off-by: Reynold Xin <[email protected]>
1 parent 9dce7be commit 23b01a3

File tree

10 files changed

+94
-94
lines changed

10 files changed

+94
-94
lines changed

core/src/test/scala/org/apache/spark/AccumulatorSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class AccumulatorSuite extends FunSuite with ShouldMatchers with LocalSparkConte
6161
val acc : Accumulator[Int] = sc.accumulator(0)
6262

6363
val d = sc.parallelize(1 to 20)
64-
evaluating {d.foreach{x => acc.value = x}} should produce [Exception]
64+
an [Exception] should be thrownBy {d.foreach{x => acc.value = x}}
6565
}
6666

6767
test ("add value to collection accumulators") {
@@ -87,11 +87,11 @@ class AccumulatorSuite extends FunSuite with ShouldMatchers with LocalSparkConte
8787
sc = new SparkContext("local[" + nThreads + "]", "test")
8888
val acc: Accumulable[mutable.Set[Any], Any] = sc.accumulable(new mutable.HashSet[Any]())
8989
val d = sc.parallelize(1 to maxI)
90-
evaluating {
90+
an [SparkException] should be thrownBy {
9191
d.foreach {
9292
x => acc.value += x
9393
}
94-
} should produce [SparkException]
94+
}
9595
resetSparkContext()
9696
}
9797
}

core/src/test/scala/org/apache/spark/util/NextIteratorSuite.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,45 @@ import org.scalatest.matchers.ShouldMatchers
2727
class NextIteratorSuite extends FunSuite with ShouldMatchers {
2828
test("one iteration") {
2929
val i = new StubIterator(Buffer(1))
30-
i.hasNext should be === true
31-
i.next should be === 1
32-
i.hasNext should be === false
30+
i.hasNext should be (true)
31+
i.next should be (1)
32+
i.hasNext should be (false)
3333
intercept[NoSuchElementException] { i.next() }
3434
}
3535

3636
test("two iterations") {
3737
val i = new StubIterator(Buffer(1, 2))
38-
i.hasNext should be === true
39-
i.next should be === 1
40-
i.hasNext should be === true
41-
i.next should be === 2
42-
i.hasNext should be === false
38+
i.hasNext should be (true)
39+
i.next should be (1)
40+
i.hasNext should be (true)
41+
i.next should be (2)
42+
i.hasNext should be (false)
4343
intercept[NoSuchElementException] { i.next() }
4444
}
4545

4646
test("empty iteration") {
4747
val i = new StubIterator(Buffer())
48-
i.hasNext should be === false
48+
i.hasNext should be (false)
4949
intercept[NoSuchElementException] { i.next() }
5050
}
5151

5252
test("close is called once for empty iterations") {
5353
val i = new StubIterator(Buffer())
54-
i.hasNext should be === false
55-
i.hasNext should be === false
56-
i.closeCalled should be === 1
54+
i.hasNext should be (false)
55+
i.hasNext should be (false)
56+
i.closeCalled should be (1)
5757
}
5858

5959
test("close is called once for non-empty iterations") {
6060
val i = new StubIterator(Buffer(1, 2))
61-
i.next should be === 1
62-
i.next should be === 2
61+
i.next should be (1)
62+
i.next should be (2)
6363
// close isn't called until we check for the next element
64-
i.closeCalled should be === 0
65-
i.hasNext should be === false
66-
i.closeCalled should be === 1
67-
i.hasNext should be === false
68-
i.closeCalled should be === 1
64+
i.closeCalled should be (0)
65+
i.hasNext should be (false)
66+
i.closeCalled should be (1)
67+
i.hasNext should be (false)
68+
i.closeCalled should be (1)
6969
}
7070

7171
class StubIterator(ints: Buffer[Int]) extends NextIterator[Int] {

core/src/test/scala/org/apache/spark/util/SizeEstimatorSuite.scala

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,53 +63,53 @@ class SizeEstimatorSuite
6363
}
6464

6565
test("simple classes") {
66-
expectResult(16)(SizeEstimator.estimate(new DummyClass1))
67-
expectResult(16)(SizeEstimator.estimate(new DummyClass2))
68-
expectResult(24)(SizeEstimator.estimate(new DummyClass3))
69-
expectResult(24)(SizeEstimator.estimate(new DummyClass4(null)))
70-
expectResult(48)(SizeEstimator.estimate(new DummyClass4(new DummyClass3)))
66+
assertResult(16)(SizeEstimator.estimate(new DummyClass1))
67+
assertResult(16)(SizeEstimator.estimate(new DummyClass2))
68+
assertResult(24)(SizeEstimator.estimate(new DummyClass3))
69+
assertResult(24)(SizeEstimator.estimate(new DummyClass4(null)))
70+
assertResult(48)(SizeEstimator.estimate(new DummyClass4(new DummyClass3)))
7171
}
7272

7373
// NOTE: The String class definition varies across JDK versions (1.6 vs. 1.7) and vendors
7474
// (Sun vs IBM). Use a DummyString class to make tests deterministic.
7575
test("strings") {
76-
expectResult(40)(SizeEstimator.estimate(DummyString("")))
77-
expectResult(48)(SizeEstimator.estimate(DummyString("a")))
78-
expectResult(48)(SizeEstimator.estimate(DummyString("ab")))
79-
expectResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
76+
assertResult(40)(SizeEstimator.estimate(DummyString("")))
77+
assertResult(48)(SizeEstimator.estimate(DummyString("a")))
78+
assertResult(48)(SizeEstimator.estimate(DummyString("ab")))
79+
assertResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
8080
}
8181

8282
test("primitive arrays") {
83-
expectResult(32)(SizeEstimator.estimate(new Array[Byte](10)))
84-
expectResult(40)(SizeEstimator.estimate(new Array[Char](10)))
85-
expectResult(40)(SizeEstimator.estimate(new Array[Short](10)))
86-
expectResult(56)(SizeEstimator.estimate(new Array[Int](10)))
87-
expectResult(96)(SizeEstimator.estimate(new Array[Long](10)))
88-
expectResult(56)(SizeEstimator.estimate(new Array[Float](10)))
89-
expectResult(96)(SizeEstimator.estimate(new Array[Double](10)))
90-
expectResult(4016)(SizeEstimator.estimate(new Array[Int](1000)))
91-
expectResult(8016)(SizeEstimator.estimate(new Array[Long](1000)))
83+
assertResult(32)(SizeEstimator.estimate(new Array[Byte](10)))
84+
assertResult(40)(SizeEstimator.estimate(new Array[Char](10)))
85+
assertResult(40)(SizeEstimator.estimate(new Array[Short](10)))
86+
assertResult(56)(SizeEstimator.estimate(new Array[Int](10)))
87+
assertResult(96)(SizeEstimator.estimate(new Array[Long](10)))
88+
assertResult(56)(SizeEstimator.estimate(new Array[Float](10)))
89+
assertResult(96)(SizeEstimator.estimate(new Array[Double](10)))
90+
assertResult(4016)(SizeEstimator.estimate(new Array[Int](1000)))
91+
assertResult(8016)(SizeEstimator.estimate(new Array[Long](1000)))
9292
}
9393

9494
test("object arrays") {
9595
// Arrays containing nulls should just have one pointer per element
96-
expectResult(56)(SizeEstimator.estimate(new Array[String](10)))
97-
expectResult(56)(SizeEstimator.estimate(new Array[AnyRef](10)))
96+
assertResult(56)(SizeEstimator.estimate(new Array[String](10)))
97+
assertResult(56)(SizeEstimator.estimate(new Array[AnyRef](10)))
9898
// For object arrays with non-null elements, each object should take one pointer plus
9999
// however many bytes that class takes. (Note that Array.fill calls the code in its
100100
// second parameter separately for each object, so we get distinct objects.)
101-
expectResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass1)))
102-
expectResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass2)))
103-
expectResult(296)(SizeEstimator.estimate(Array.fill(10)(new DummyClass3)))
104-
expectResult(56)(SizeEstimator.estimate(Array(new DummyClass1, new DummyClass2)))
101+
assertResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass1)))
102+
assertResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass2)))
103+
assertResult(296)(SizeEstimator.estimate(Array.fill(10)(new DummyClass3)))
104+
assertResult(56)(SizeEstimator.estimate(Array(new DummyClass1, new DummyClass2)))
105105

106106
// Past size 100, our samples 100 elements, but we should still get the right size.
107-
expectResult(28016)(SizeEstimator.estimate(Array.fill(1000)(new DummyClass3)))
107+
assertResult(28016)(SizeEstimator.estimate(Array.fill(1000)(new DummyClass3)))
108108

109109
// If an array contains the *same* element many times, we should only count it once.
110110
val d1 = new DummyClass1
111-
expectResult(72)(SizeEstimator.estimate(Array.fill(10)(d1))) // 10 pointers plus 8-byte object
112-
expectResult(432)(SizeEstimator.estimate(Array.fill(100)(d1))) // 100 pointers plus 8-byte object
111+
assertResult(72)(SizeEstimator.estimate(Array.fill(10)(d1))) // 10 pointers plus 8-byte object
112+
assertResult(432)(SizeEstimator.estimate(Array.fill(100)(d1))) // 100 pointers plus 8-byte object
113113

114114
// Same thing with huge array containing the same element many times. Note that this won't
115115
// return exactly 4032 because it can't tell that *all* the elements will equal the first
@@ -127,10 +127,10 @@ class SizeEstimatorSuite
127127
val initialize = PrivateMethod[Unit]('initialize)
128128
SizeEstimator invokePrivate initialize()
129129

130-
expectResult(40)(SizeEstimator.estimate(DummyString("")))
131-
expectResult(48)(SizeEstimator.estimate(DummyString("a")))
132-
expectResult(48)(SizeEstimator.estimate(DummyString("ab")))
133-
expectResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
130+
assertResult(40)(SizeEstimator.estimate(DummyString("")))
131+
assertResult(48)(SizeEstimator.estimate(DummyString("a")))
132+
assertResult(48)(SizeEstimator.estimate(DummyString("ab")))
133+
assertResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
134134
resetOrClear("os.arch", arch)
135135
}
136136

@@ -142,10 +142,10 @@ class SizeEstimatorSuite
142142
val initialize = PrivateMethod[Unit]('initialize)
143143
SizeEstimator invokePrivate initialize()
144144

145-
expectResult(56)(SizeEstimator.estimate(DummyString("")))
146-
expectResult(64)(SizeEstimator.estimate(DummyString("a")))
147-
expectResult(64)(SizeEstimator.estimate(DummyString("ab")))
148-
expectResult(72)(SizeEstimator.estimate(DummyString("abcdefgh")))
145+
assertResult(56)(SizeEstimator.estimate(DummyString("")))
146+
assertResult(64)(SizeEstimator.estimate(DummyString("a")))
147+
assertResult(64)(SizeEstimator.estimate(DummyString("ab")))
148+
assertResult(72)(SizeEstimator.estimate(DummyString("abcdefgh")))
149149

150150
resetOrClear("os.arch", arch)
151151
resetOrClear("spark.test.useCompressedOops", oops)

sql/core/src/test/scala/org/apache/spark/sql/columnar/ColumnStatsSuite.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ColumnStatsSuite extends FunSuite {
3939

4040
test(s"$columnStatsName: empty") {
4141
val columnStats = columnStatsClass.newInstance()
42-
expectResult(columnStats.initialBounds, "Wrong initial bounds") {
42+
assertResult(columnStats.initialBounds, "Wrong initial bounds") {
4343
(columnStats.lowerBound, columnStats.upperBound)
4444
}
4545
}
@@ -54,8 +54,8 @@ class ColumnStatsSuite extends FunSuite {
5454
val values = rows.map(_.head.asInstanceOf[T#JvmType])
5555
val ordering = columnType.dataType.ordering.asInstanceOf[Ordering[T#JvmType]]
5656

57-
expectResult(values.min(ordering), "Wrong lower bound")(columnStats.lowerBound)
58-
expectResult(values.max(ordering), "Wrong upper bound")(columnStats.upperBound)
57+
assertResult(values.min(ordering), "Wrong lower bound")(columnStats.lowerBound)
58+
assertResult(values.max(ordering), "Wrong upper bound")(columnStats.upperBound)
5959
}
6060
}
6161
}

sql/core/src/test/scala/org/apache/spark/sql/columnar/ColumnTypeSuite.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ColumnTypeSuite extends FunSuite with Logging {
3535
BOOLEAN -> 1, STRING -> 8, BINARY -> 16, GENERIC -> 16)
3636

3737
checks.foreach { case (columnType, expectedSize) =>
38-
expectResult(expectedSize, s"Wrong defaultSize for $columnType") {
38+
assertResult(expectedSize, s"Wrong defaultSize for $columnType") {
3939
columnType.defaultSize
4040
}
4141
}
@@ -47,7 +47,7 @@ class ColumnTypeSuite extends FunSuite with Logging {
4747
value: JvmType,
4848
expected: Int) {
4949

50-
expectResult(expected, s"Wrong actualSize for $columnType") {
50+
assertResult(expected, s"Wrong actualSize for $columnType") {
5151
columnType.actualSize(value)
5252
}
5353
}
@@ -127,7 +127,7 @@ class ColumnTypeSuite extends FunSuite with Logging {
127127
val length = buffer.getInt()
128128
assert(length === serializedObj.length)
129129

130-
expectResult(obj, "Deserialized object didn't equal to the original object") {
130+
assertResult(obj, "Deserialized object didn't equal to the original object") {
131131
val bytes = new Array[Byte](length)
132132
buffer.get(bytes, 0, length)
133133
SparkSqlSerializer.deserialize(bytes)
@@ -136,7 +136,7 @@ class ColumnTypeSuite extends FunSuite with Logging {
136136
buffer.rewind()
137137
buffer.putInt(serializedObj.length).put(serializedObj)
138138

139-
expectResult(obj, "Deserialized object didn't equal to the original object") {
139+
assertResult(obj, "Deserialized object didn't equal to the original object") {
140140
buffer.rewind()
141141
SparkSqlSerializer.deserialize(GENERIC.extract(buffer))
142142
}

sql/core/src/test/scala/org/apache/spark/sql/columnar/NullableColumnBuilderSuite.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class NullableColumnBuilderSuite extends FunSuite {
4848
val columnBuilder = TestNullableColumnBuilder(columnType)
4949
val buffer = columnBuilder.build()
5050

51-
expectResult(columnType.typeId, "Wrong column type ID")(buffer.getInt())
52-
expectResult(0, "Wrong null count")(buffer.getInt())
51+
assertResult(columnType.typeId, "Wrong column type ID")(buffer.getInt())
52+
assertResult(0, "Wrong null count")(buffer.getInt())
5353
assert(!buffer.hasRemaining)
5454
}
5555

@@ -63,8 +63,8 @@ class NullableColumnBuilderSuite extends FunSuite {
6363

6464
val buffer = columnBuilder.build()
6565

66-
expectResult(columnType.typeId, "Wrong column type ID")(buffer.getInt())
67-
expectResult(0, "Wrong null count")(buffer.getInt())
66+
assertResult(columnType.typeId, "Wrong column type ID")(buffer.getInt())
67+
assertResult(0, "Wrong null count")(buffer.getInt())
6868
}
6969

7070
test(s"$typeName column builder: null values") {
@@ -79,11 +79,11 @@ class NullableColumnBuilderSuite extends FunSuite {
7979

8080
val buffer = columnBuilder.build()
8181

82-
expectResult(columnType.typeId, "Wrong column type ID")(buffer.getInt())
83-
expectResult(4, "Wrong null count")(buffer.getInt())
82+
assertResult(columnType.typeId, "Wrong column type ID")(buffer.getInt())
83+
assertResult(4, "Wrong null count")(buffer.getInt())
8484

8585
// For null positions
86-
(1 to 7 by 2).foreach(expectResult(_, "Wrong null position")(buffer.getInt()))
86+
(1 to 7 by 2).foreach(assertResult(_, "Wrong null position")(buffer.getInt()))
8787

8888
// For non-null values
8989
(0 until 4).foreach { _ =>

sql/core/src/test/scala/org/apache/spark/sql/columnar/compression/BooleanBitSetSuite.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ class BooleanBitSetSuite extends FunSuite {
4848
}
4949

5050
// 4 extra bytes for compression scheme type ID
51-
expectResult(headerSize + compressedSize, "Wrong buffer capacity")(buffer.capacity)
51+
assertResult(headerSize + compressedSize, "Wrong buffer capacity")(buffer.capacity)
5252

5353
// Skips column header
5454
buffer.position(headerSize)
55-
expectResult(BooleanBitSet.typeId, "Wrong compression scheme ID")(buffer.getInt())
56-
expectResult(count, "Wrong element count")(buffer.getInt())
55+
assertResult(BooleanBitSet.typeId, "Wrong compression scheme ID")(buffer.getInt())
56+
assertResult(count, "Wrong element count")(buffer.getInt())
5757

5858
var word = 0: Long
5959
for (i <- 0 until count) {
6060
val bit = i % BITS_PER_LONG
6161
word = if (bit == 0) buffer.getLong() else word
62-
expectResult(values(i), s"Wrong value in compressed buffer, index=$i") {
62+
assertResult(values(i), s"Wrong value in compressed buffer, index=$i") {
6363
(word & ((1: Long) << bit)) != 0
6464
}
6565
}
@@ -75,7 +75,7 @@ class BooleanBitSetSuite extends FunSuite {
7575
if (values.nonEmpty) {
7676
values.foreach {
7777
assert(decoder.hasNext)
78-
expectResult(_, "Wrong decoded value")(decoder.next())
78+
assertResult(_, "Wrong decoded value")(decoder.next())
7979
}
8080
}
8181
assert(!decoder.hasNext)

sql/core/src/test/scala/org/apache/spark/sql/columnar/compression/DictionaryEncodingSuite.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ class DictionaryEncodingSuite extends FunSuite {
7171
// 2 bytes for each `Short`
7272
val compressedSize = 4 + dictionarySize + 2 * inputSeq.length
7373
// 4 extra bytes for compression scheme type ID
74-
expectResult(headerSize + compressedSize, "Wrong buffer capacity")(buffer.capacity)
74+
assertResult(headerSize + compressedSize, "Wrong buffer capacity")(buffer.capacity)
7575

7676
// Skips column header
7777
buffer.position(headerSize)
78-
expectResult(DictionaryEncoding.typeId, "Wrong compression scheme ID")(buffer.getInt())
78+
assertResult(DictionaryEncoding.typeId, "Wrong compression scheme ID")(buffer.getInt())
7979

8080
val dictionary = buildDictionary(buffer).toMap
8181

8282
dictValues.foreach { i =>
83-
expectResult(i, "Wrong dictionary entry") {
83+
assertResult(i, "Wrong dictionary entry") {
8484
dictionary(values(i))
8585
}
8686
}
8787

8888
inputSeq.foreach { i =>
89-
expectResult(i.toShort, "Wrong column element value")(buffer.getShort())
89+
assertResult(i.toShort, "Wrong column element value")(buffer.getShort())
9090
}
9191

9292
// -------------
@@ -101,7 +101,7 @@ class DictionaryEncodingSuite extends FunSuite {
101101
if (inputSeq.nonEmpty) {
102102
inputSeq.foreach { i =>
103103
assert(decoder.hasNext)
104-
expectResult(values(i), "Wrong decoded value")(decoder.next())
104+
assertResult(values(i), "Wrong decoded value")(decoder.next())
105105
}
106106
}
107107

sql/core/src/test/scala/org/apache/spark/sql/columnar/compression/IntegralDeltaSuite.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,21 @@ class IntegralDeltaSuite extends FunSuite {
6969
})
7070

7171
// 4 extra bytes for compression scheme type ID
72-
expectResult(headerSize + compressedSize, "Wrong buffer capacity")(buffer.capacity)
72+
assertResult(headerSize + compressedSize, "Wrong buffer capacity")(buffer.capacity)
7373

7474
buffer.position(headerSize)
75-
expectResult(scheme.typeId, "Wrong compression scheme ID")(buffer.getInt())
75+
assertResult(scheme.typeId, "Wrong compression scheme ID")(buffer.getInt())
7676

7777
if (input.nonEmpty) {
78-
expectResult(Byte.MinValue, "The first byte should be an escaping mark")(buffer.get())
79-
expectResult(input.head, "The first value is wrong")(columnType.extract(buffer))
78+
assertResult(Byte.MinValue, "The first byte should be an escaping mark")(buffer.get())
79+
assertResult(input.head, "The first value is wrong")(columnType.extract(buffer))
8080

8181
(input.tail, deltas).zipped.foreach { (value, delta) =>
8282
if (math.abs(delta) <= Byte.MaxValue) {
83-
expectResult(delta, "Wrong delta")(buffer.get())
83+
assertResult(delta, "Wrong delta")(buffer.get())
8484
} else {
85-
expectResult(Byte.MinValue, "Expecting escaping mark here")(buffer.get())
86-
expectResult(value, "Wrong value")(columnType.extract(buffer))
85+
assertResult(Byte.MinValue, "Expecting escaping mark here")(buffer.get())
86+
assertResult(value, "Wrong value")(columnType.extract(buffer))
8787
}
8888
}
8989
}
@@ -99,7 +99,7 @@ class IntegralDeltaSuite extends FunSuite {
9999
if (input.nonEmpty) {
100100
input.foreach{
101101
assert(decoder.hasNext)
102-
expectResult(_, "Wrong decoded value")(decoder.next())
102+
assertResult(_, "Wrong decoded value")(decoder.next())
103103
}
104104
}
105105
assert(!decoder.hasNext)

0 commit comments

Comments
 (0)