Skip to content

Commit

Permalink
[SPARK-7714] [SPARKR] SparkR tests should use more specific expectati…
Browse files Browse the repository at this point in the history
…ons than expect_true

1. Update the pattern 'expect_true(a == b)' to 'expect_equal(a, b)'.
2. Update the pattern 'expect_true(inherits(a, b))' to 'expect_is(a, b)'.
3. Update the pattern 'expect_true(identical(a, b))' to 'expect_identical(a, b)'.

Author: Sun Rui <rui.sun@intel.com>

Closes #7152 from sun-rui/SPARK-7714 and squashes the following commits:

8ad2440 [Sun Rui] Fix test case errors.
8fe9f0c [Sun Rui] Update the pattern 'expect_true(identical(a, b))' to 'expect_identical(a, b)'.
f1b8005 [Sun Rui] Update the pattern 'expect_true(inherits(a, b))' to 'expect_is(a, b)'.
f631e94 [Sun Rui] Update the pattern 'expect_true(a == b)' to 'expect_equal(a, b)'.
  • Loading branch information
Sun Rui authored and shivaram committed Jul 1, 2015
1 parent fdcad6e commit 69c5dee
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 194 deletions.
2 changes: 1 addition & 1 deletion R/pkg/inst/tests/test_binaryFile.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test_that("saveAsObjectFile()/objectFile() works with multiple paths", {
saveAsObjectFile(rdd2, fileName2)

rdd <- objectFile(sc, c(fileName1, fileName2))
expect_true(count(rdd) == 2)
expect_equal(count(rdd), 2)

unlink(fileName1, recursive = TRUE)
unlink(fileName2, recursive = TRUE)
Expand Down
4 changes: 2 additions & 2 deletions R/pkg/inst/tests/test_binary_function.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ test_that("union on two RDDs", {
union.rdd <- unionRDD(rdd, text.rdd)
actual <- collect(union.rdd)
expect_equal(actual, c(as.list(nums), mockFile))
expect_true(getSerializedMode(union.rdd) == "byte")
expect_equal(getSerializedMode(union.rdd), "byte")

rdd<- map(text.rdd, function(x) {x})
union.rdd <- unionRDD(rdd, text.rdd)
actual <- collect(union.rdd)
expect_equal(actual, as.list(c(mockFile, mockFile)))
expect_true(getSerializedMode(union.rdd) == "byte")
expect_equal(getSerializedMode(union.rdd), "byte")

unlink(fileName)
})
Expand Down
4 changes: 2 additions & 2 deletions R/pkg/inst/tests/test_includeJAR.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runScript <- function() {
test_that("sparkJars tag in SparkContext", {
testOutput <- runScript()
helloTest <- testOutput[1]
expect_true(helloTest == "Hello, Dave")
expect_equal(helloTest, "Hello, Dave")
basicFunction <- testOutput[2]
expect_true(basicFunction == 4L)
expect_equal(basicFunction, "4")
})
2 changes: 1 addition & 1 deletion R/pkg/inst/tests/test_parallelize_collect.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test_that("parallelize() on simple vectors and lists returns an RDD", {
strListRDD2)

for (rdd in rdds) {
expect_true(inherits(rdd, "RDD"))
expect_is(rdd, "RDD")
expect_true(.hasSlot(rdd, "jrdd")
&& inherits(rdd@jrdd, "jobj")
&& isInstanceOf(rdd@jrdd, "org.apache.spark.api.java.JavaRDD"))
Expand Down
4 changes: 2 additions & 2 deletions R/pkg/inst/tests/test_rdd.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ test_that("get number of partitions in RDD", {
})

test_that("first on RDD", {
expect_true(first(rdd) == 1)
expect_equal(first(rdd), 1)
newrdd <- lapply(rdd, function(x) x + 1)
expect_true(first(newrdd) == 2)
expect_equal(first(newrdd), 2)
})

test_that("count and length on RDD", {
Expand Down
Loading

0 comments on commit 69c5dee

Please sign in to comment.