tinytest (version 1.2.4)

expect_equal_to_reference: Compare object with object stored in a file

Description

Compares the current value with a value stored to file with saveRDS. If the file does not exist, the current value is stored into file, and the test returns expect_null(NULL).

Usage

expect_equal_to_reference(current, file, ...)

expect_equivalent_to_reference(current, file, ...)

Arguments

current

[R object or expression] Outcome or expression under scrutiny.

file

[character] File where the target is stored. If file does not exist, current will be stored there.

...

passed to expect_equal, respectively expect_equivalent.

See Also

Other test-functions: expect_equal(), ignore()

Examples

Run this code
# NOT RUN {
filename <- tempfile()
# this gives TRUE: the file does not exist, but is created now.
expect_equal_to_reference(1, file=filename)
# this gives TRUE: the file now exists, and its contents is equal
# to the current value
expect_equal_to_reference(1, file=filename)
# this gives FALSE: the file exists, but is contents is not equal
# to the current value
expect_equal_to_reference(2, file=filename)

# }

Run the code above in your browser using DataLab