Skip to content

Commit b53b80f

Browse files
committed
add tests
1 parent 8745425 commit b53b80f

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/testthat/test-as-double.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
test_that("as.double casts integer and logical values", {
2+
fn_int <- function(x) {
3+
declare(type(x = integer(n)))
4+
as.double(x)
5+
}
6+
expect_quick_identical(fn_int, list(1:3))
7+
8+
fn_lgl <- function(x) {
9+
declare(type(x = logical(n)))
10+
as.double(x)
11+
}
12+
expect_quick_identical(fn_lgl, list(c(TRUE, FALSE, TRUE)))
13+
})
14+
15+
test_that("/ performs real division for integer and logical inputs", {
16+
div_int <- function(a, b) {
17+
declare(type(a = integer(n)), type(b = integer(n)))
18+
a / b
19+
}
20+
expect_quick_equal(div_int, list(1:3, c(2L, 2L, 2L)))
21+
22+
div_lgl <- function(a, b) {
23+
declare(type(a = logical(n)), type(b = logical(n)))
24+
a / b
25+
}
26+
expect_quick_equal(div_lgl, list(c(TRUE, FALSE, TRUE), c(TRUE, TRUE, TRUE)))
27+
})

0 commit comments

Comments
 (0)