aboutsummaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
authorwitgo <witgo@qq.com>2014-07-08 00:31:42 -0700
committerReynold Xin <rxin@apache.org>2014-07-08 00:31:42 -0700
commit3cd5029be709307415f911236472a685e406e763 (patch)
tree451f83c229c0fd422617117233e534077335f905 /core/src/test
parent0128905eea9f8c597ca238b14c18908995511e76 (diff)
downloadspark-3cd5029be709307415f911236472a685e406e763.tar.gz
spark-3cd5029be709307415f911236472a685e406e763.tar.bz2
spark-3cd5029be709307415f911236472a685e406e763.zip
Resolve sbt warnings during build Ⅱ
Author: witgo <witgo@qq.com> Closes #1153 from witgo/expectResult and squashes the following commits: 97541d8 [witgo] merge master ead26e7 [witgo] Resolve sbt warnings during build
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/scala/org/apache/spark/AccumulatorSuite.scala6
-rw-r--r--core/src/test/scala/org/apache/spark/util/NextIteratorSuite.scala38
-rw-r--r--core/src/test/scala/org/apache/spark/util/SizeEstimatorSuite.scala70
3 files changed, 57 insertions, 57 deletions
diff --git a/core/src/test/scala/org/apache/spark/AccumulatorSuite.scala b/core/src/test/scala/org/apache/spark/AccumulatorSuite.scala
index 3aab88e9e9..52d1d52776 100644
--- a/core/src/test/scala/org/apache/spark/AccumulatorSuite.scala
+++ b/core/src/test/scala/org/apache/spark/AccumulatorSuite.scala
@@ -61,7 +61,7 @@ class AccumulatorSuite extends FunSuite with Matchers with LocalSparkContext {
val acc : Accumulator[Int] = sc.accumulator(0)
val d = sc.parallelize(1 to 20)
- evaluating {d.foreach{x => acc.value = x}} should produce [Exception]
+ an [Exception] should be thrownBy {d.foreach{x => acc.value = x}}
}
test ("add value to collection accumulators") {
@@ -87,11 +87,11 @@ class AccumulatorSuite extends FunSuite with Matchers with LocalSparkContext {
sc = new SparkContext("local[" + nThreads + "]", "test")
val acc: Accumulable[mutable.Set[Any], Any] = sc.accumulable(new mutable.HashSet[Any]())
val d = sc.parallelize(1 to maxI)
- evaluating {
+ an [SparkException] should be thrownBy {
d.foreach {
x => acc.value += x
}
- } should produce [SparkException]
+ }
resetSparkContext()
}
}
diff --git a/core/src/test/scala/org/apache/spark/util/NextIteratorSuite.scala b/core/src/test/scala/org/apache/spark/util/NextIteratorSuite.scala
index cf438a3d72..72e81f3f1a 100644
--- a/core/src/test/scala/org/apache/spark/util/NextIteratorSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/NextIteratorSuite.scala
@@ -27,45 +27,45 @@ import org.scalatest.Matchers
class NextIteratorSuite extends FunSuite with Matchers {
test("one iteration") {
val i = new StubIterator(Buffer(1))
- i.hasNext should be === true
- i.next should be === 1
- i.hasNext should be === false
+ i.hasNext should be (true)
+ i.next should be (1)
+ i.hasNext should be (false)
intercept[NoSuchElementException] { i.next() }
}
test("two iterations") {
val i = new StubIterator(Buffer(1, 2))
- i.hasNext should be === true
- i.next should be === 1
- i.hasNext should be === true
- i.next should be === 2
- i.hasNext should be === false
+ i.hasNext should be (true)
+ i.next should be (1)
+ i.hasNext should be (true)
+ i.next should be (2)
+ i.hasNext should be (false)
intercept[NoSuchElementException] { i.next() }
}
test("empty iteration") {
val i = new StubIterator(Buffer())
- i.hasNext should be === false
+ i.hasNext should be (false)
intercept[NoSuchElementException] { i.next() }
}
test("close is called once for empty iterations") {
val i = new StubIterator(Buffer())
- i.hasNext should be === false
- i.hasNext should be === false
- i.closeCalled should be === 1
+ i.hasNext should be (false)
+ i.hasNext should be (false)
+ i.closeCalled should be (1)
}
test("close is called once for non-empty iterations") {
val i = new StubIterator(Buffer(1, 2))
- i.next should be === 1
- i.next should be === 2
+ i.next should be (1)
+ i.next should be (2)
// close isn't called until we check for the next element
- i.closeCalled should be === 0
- i.hasNext should be === false
- i.closeCalled should be === 1
- i.hasNext should be === false
- i.closeCalled should be === 1
+ i.closeCalled should be (0)
+ i.hasNext should be (false)
+ i.closeCalled should be (1)
+ i.hasNext should be (false)
+ i.closeCalled should be (1)
}
class StubIterator(ints: Buffer[Int]) extends NextIterator[Int] {
diff --git a/core/src/test/scala/org/apache/spark/util/SizeEstimatorSuite.scala b/core/src/test/scala/org/apache/spark/util/SizeEstimatorSuite.scala
index b583a8bd46..f9d1af88f3 100644
--- a/core/src/test/scala/org/apache/spark/util/SizeEstimatorSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/SizeEstimatorSuite.scala
@@ -63,53 +63,53 @@ class SizeEstimatorSuite
}
test("simple classes") {
- expectResult(16)(SizeEstimator.estimate(new DummyClass1))
- expectResult(16)(SizeEstimator.estimate(new DummyClass2))
- expectResult(24)(SizeEstimator.estimate(new DummyClass3))
- expectResult(24)(SizeEstimator.estimate(new DummyClass4(null)))
- expectResult(48)(SizeEstimator.estimate(new DummyClass4(new DummyClass3)))
+ assertResult(16)(SizeEstimator.estimate(new DummyClass1))
+ assertResult(16)(SizeEstimator.estimate(new DummyClass2))
+ assertResult(24)(SizeEstimator.estimate(new DummyClass3))
+ assertResult(24)(SizeEstimator.estimate(new DummyClass4(null)))
+ assertResult(48)(SizeEstimator.estimate(new DummyClass4(new DummyClass3)))
}
// NOTE: The String class definition varies across JDK versions (1.6 vs. 1.7) and vendors
// (Sun vs IBM). Use a DummyString class to make tests deterministic.
test("strings") {
- expectResult(40)(SizeEstimator.estimate(DummyString("")))
- expectResult(48)(SizeEstimator.estimate(DummyString("a")))
- expectResult(48)(SizeEstimator.estimate(DummyString("ab")))
- expectResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
+ assertResult(40)(SizeEstimator.estimate(DummyString("")))
+ assertResult(48)(SizeEstimator.estimate(DummyString("a")))
+ assertResult(48)(SizeEstimator.estimate(DummyString("ab")))
+ assertResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
}
test("primitive arrays") {
- expectResult(32)(SizeEstimator.estimate(new Array[Byte](10)))
- expectResult(40)(SizeEstimator.estimate(new Array[Char](10)))
- expectResult(40)(SizeEstimator.estimate(new Array[Short](10)))
- expectResult(56)(SizeEstimator.estimate(new Array[Int](10)))
- expectResult(96)(SizeEstimator.estimate(new Array[Long](10)))
- expectResult(56)(SizeEstimator.estimate(new Array[Float](10)))
- expectResult(96)(SizeEstimator.estimate(new Array[Double](10)))
- expectResult(4016)(SizeEstimator.estimate(new Array[Int](1000)))
- expectResult(8016)(SizeEstimator.estimate(new Array[Long](1000)))
+ assertResult(32)(SizeEstimator.estimate(new Array[Byte](10)))
+ assertResult(40)(SizeEstimator.estimate(new Array[Char](10)))
+ assertResult(40)(SizeEstimator.estimate(new Array[Short](10)))
+ assertResult(56)(SizeEstimator.estimate(new Array[Int](10)))
+ assertResult(96)(SizeEstimator.estimate(new Array[Long](10)))
+ assertResult(56)(SizeEstimator.estimate(new Array[Float](10)))
+ assertResult(96)(SizeEstimator.estimate(new Array[Double](10)))
+ assertResult(4016)(SizeEstimator.estimate(new Array[Int](1000)))
+ assertResult(8016)(SizeEstimator.estimate(new Array[Long](1000)))
}
test("object arrays") {
// Arrays containing nulls should just have one pointer per element
- expectResult(56)(SizeEstimator.estimate(new Array[String](10)))
- expectResult(56)(SizeEstimator.estimate(new Array[AnyRef](10)))
+ assertResult(56)(SizeEstimator.estimate(new Array[String](10)))
+ assertResult(56)(SizeEstimator.estimate(new Array[AnyRef](10)))
// For object arrays with non-null elements, each object should take one pointer plus
// however many bytes that class takes. (Note that Array.fill calls the code in its
// second parameter separately for each object, so we get distinct objects.)
- expectResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass1)))
- expectResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass2)))
- expectResult(296)(SizeEstimator.estimate(Array.fill(10)(new DummyClass3)))
- expectResult(56)(SizeEstimator.estimate(Array(new DummyClass1, new DummyClass2)))
+ assertResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass1)))
+ assertResult(216)(SizeEstimator.estimate(Array.fill(10)(new DummyClass2)))
+ assertResult(296)(SizeEstimator.estimate(Array.fill(10)(new DummyClass3)))
+ assertResult(56)(SizeEstimator.estimate(Array(new DummyClass1, new DummyClass2)))
// Past size 100, our samples 100 elements, but we should still get the right size.
- expectResult(28016)(SizeEstimator.estimate(Array.fill(1000)(new DummyClass3)))
+ assertResult(28016)(SizeEstimator.estimate(Array.fill(1000)(new DummyClass3)))
// If an array contains the *same* element many times, we should only count it once.
val d1 = new DummyClass1
- expectResult(72)(SizeEstimator.estimate(Array.fill(10)(d1))) // 10 pointers plus 8-byte object
- expectResult(432)(SizeEstimator.estimate(Array.fill(100)(d1))) // 100 pointers plus 8-byte object
+ assertResult(72)(SizeEstimator.estimate(Array.fill(10)(d1))) // 10 pointers plus 8-byte object
+ assertResult(432)(SizeEstimator.estimate(Array.fill(100)(d1))) // 100 pointers plus 8-byte object
// Same thing with huge array containing the same element many times. Note that this won't
// return exactly 4032 because it can't tell that *all* the elements will equal the first
@@ -127,10 +127,10 @@ class SizeEstimatorSuite
val initialize = PrivateMethod[Unit]('initialize)
SizeEstimator invokePrivate initialize()
- expectResult(40)(SizeEstimator.estimate(DummyString("")))
- expectResult(48)(SizeEstimator.estimate(DummyString("a")))
- expectResult(48)(SizeEstimator.estimate(DummyString("ab")))
- expectResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
+ assertResult(40)(SizeEstimator.estimate(DummyString("")))
+ assertResult(48)(SizeEstimator.estimate(DummyString("a")))
+ assertResult(48)(SizeEstimator.estimate(DummyString("ab")))
+ assertResult(56)(SizeEstimator.estimate(DummyString("abcdefgh")))
resetOrClear("os.arch", arch)
}
@@ -142,10 +142,10 @@ class SizeEstimatorSuite
val initialize = PrivateMethod[Unit]('initialize)
SizeEstimator invokePrivate initialize()
- expectResult(56)(SizeEstimator.estimate(DummyString("")))
- expectResult(64)(SizeEstimator.estimate(DummyString("a")))
- expectResult(64)(SizeEstimator.estimate(DummyString("ab")))
- expectResult(72)(SizeEstimator.estimate(DummyString("abcdefgh")))
+ assertResult(56)(SizeEstimator.estimate(DummyString("")))
+ assertResult(64)(SizeEstimator.estimate(DummyString("a")))
+ assertResult(64)(SizeEstimator.estimate(DummyString("ab")))
+ assertResult(72)(SizeEstimator.estimate(DummyString("abcdefgh")))
resetOrClear("os.arch", arch)
resetOrClear("spark.test.useCompressedOops", oops)