test_that("NA, Inf, and empty values with has_discretes.", { # arithmetic x <- arithmetic(5.5, 1.2, n_left = 3, n_right = 4) expect_identical( has_discretes(x, c(NA, 6.7, 6, Inf, -Inf)), c(NA, TRUE, FALSE, FALSE, FALSE) ) expect_identical(has_discretes(x, numeric()), logical()) # numeric y <- c(1.2, 3.4, 5.6, 3.4) expect_equal( has_discretes(y, c(NA, 3.4, 4.5, Inf, -Inf)), c(NA, TRUE, FALSE, FALSE, FALSE) ) }) test_that("edge cases - numeric", { y <- c(1.2, -4.4, NA) expect_equal(has_discretes(y, NA), NA) expect_equal(has_discretes(y, c(NA, -4.4, Inf)), c(NA, TRUE, NA)) y <- numeric(0) expect_equal(has_discretes(y, NA), FALSE) expect_equal(has_discretes(y, c(NA, 4.4, Inf)), c(FALSE, FALSE, FALSE)) expect_equal(has_discretes(y, 1:3), c(FALSE, FALSE, FALSE)) }) test_that("Discrete-testing works for numeric discretes.", { x <- c(4.2, 6.5, -4.4, -4.4, 4.2, 10) expect_equal( has_discretes(x, c(NA, 6.5, 6, Inf, -Inf)), c(NA, TRUE, FALSE, FALSE, FALSE) ) expect_equal(has_discretes(x, numeric()), logical(0)) })