Skip to content

Commit 69c5dee

Browse files
Sun Ruishivaram
authored andcommitted
[SPARK-7714] [SPARKR] SparkR tests should use more specific expectations 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 <[email protected]> Closes apache#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)'.
1 parent fdcad6e commit 69c5dee

File tree

9 files changed

+194
-194
lines changed

9 files changed

+194
-194
lines changed

R/pkg/inst/tests/test_binaryFile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test_that("saveAsObjectFile()/objectFile() works with multiple paths", {
8282
saveAsObjectFile(rdd2, fileName2)
8383

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

8787
unlink(fileName1, recursive = TRUE)
8888
unlink(fileName2, recursive = TRUE)

R/pkg/inst/tests/test_binary_function.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ test_that("union on two RDDs", {
3838
union.rdd <- unionRDD(rdd, text.rdd)
3939
actual <- collect(union.rdd)
4040
expect_equal(actual, c(as.list(nums), mockFile))
41-
expect_true(getSerializedMode(union.rdd) == "byte")
41+
expect_equal(getSerializedMode(union.rdd), "byte")
4242

4343
rdd<- map(text.rdd, function(x) {x})
4444
union.rdd <- unionRDD(rdd, text.rdd)
4545
actual <- collect(union.rdd)
4646
expect_equal(actual, as.list(c(mockFile, mockFile)))
47-
expect_true(getSerializedMode(union.rdd) == "byte")
47+
expect_equal(getSerializedMode(union.rdd), "byte")
4848

4949
unlink(fileName)
5050
})

R/pkg/inst/tests/test_includeJAR.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ runScript <- function() {
3131
test_that("sparkJars tag in SparkContext", {
3232
testOutput <- runScript()
3333
helloTest <- testOutput[1]
34-
expect_true(helloTest == "Hello, Dave")
34+
expect_equal(helloTest, "Hello, Dave")
3535
basicFunction <- testOutput[2]
36-
expect_true(basicFunction == 4L)
36+
expect_equal(basicFunction, "4")
3737
})

R/pkg/inst/tests/test_parallelize_collect.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ test_that("parallelize() on simple vectors and lists returns an RDD", {
5757
strListRDD2)
5858

5959
for (rdd in rdds) {
60-
expect_true(inherits(rdd, "RDD"))
60+
expect_is(rdd, "RDD")
6161
expect_true(.hasSlot(rdd, "jrdd")
6262
&& inherits(rdd@jrdd, "jobj")
6363
&& isInstanceOf(rdd@jrdd, "org.apache.spark.api.java.JavaRDD"))

R/pkg/inst/tests/test_rdd.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ test_that("get number of partitions in RDD", {
3333
})
3434

3535
test_that("first on RDD", {
36-
expect_true(first(rdd) == 1)
36+
expect_equal(first(rdd), 1)
3737
newrdd <- lapply(rdd, function(x) x + 1)
38-
expect_true(first(newrdd) == 2)
38+
expect_equal(first(newrdd), 2)
3939
})
4040

4141
test_that("count and length on RDD", {

0 commit comments

Comments
 (0)