View source: R/expect_type_linter.R
expect_type_linter | R Documentation |
expect_type(x, type)
over expect_equal(typeof(x), type)
testthat::expect_type()
exists specifically for testing the storage type
of objects. testthat::expect_equal()
, testthat::expect_identical()
, and
testthat::expect_true()
can also be used for such tests,
but it is better to use the tailored function instead.
expect_type_linter()
best_practices, package_development, pkg_testthat
linters for a complete list of linters available in lintr.
# will produce lints
lint(
text = 'expect_equal(typeof(x), "double")',
linters = expect_type_linter()
)
lint(
text = 'expect_identical(typeof(x), "double")',
linters = expect_type_linter()
)
# okay
lint(
text = 'expect_type(x, "double")',
linters = expect_type_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.