diff options
author | witgo <witgo@qq.com> | 2014-07-08 00:31:42 -0700 |
---|---|---|
committer | Reynold Xin <rxin@apache.org> | 2014-07-08 00:31:58 -0700 |
commit | 23b01a3033294fa4d0c3bbdaafa21a1e5c6e4022 (patch) | |
tree | 02abeba8739e71b30108f60ac045739a47e41697 /core/src/test | |
parent | 9dce7beffb668e42ee05d961ae47f33047d579cc (diff) | |
download | spark-23b01a3033294fa4d0c3bbdaafa21a1e5c6e4022.tar.gz spark-23b01a3033294fa4d0c3bbdaafa21a1e5c6e4022.tar.bz2 spark-23b01a3033294fa4d0c3bbdaafa21a1e5c6e4022.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
(cherry picked from commit 3cd5029be709307415f911236472a685e406e763)
Signed-off-by: Reynold Xin <rxin@apache.org>
Diffstat (limited to 'core/src/test')
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 4e7c34e6d1..f5d06257db 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 ShouldMatchers with LocalSparkConte 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 ShouldMatchers with LocalSparkConte 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 32d74d0500..6fc593c0ab 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.ShouldMatchers class NextIteratorSuite extends FunSuite with ShouldMatchers { 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) |