| 1 |
context("aux") |
| 2 |
test_that("aux:",{ |
| 3 |
|
| 4 |
ll <- list(arg1=c(1,2,3), arg2=c(4,5,6)) |
| 5 |
expect_equal(.farg(ll, arg3=c(7,8,9)), |
| 6 |
list(arg1=c(1,2,3), arg2=c(4,5,6), arg3=c(7,8,9))) |
| 7 |
expect_equal(.farg(ll, arg1=c(1,4,3)), |
| 8 |
list(arg1=c(1,2,3), arg2=c(4,5,6))) |
| 9 |
|
| 10 |
ll <- list(arg1=list(1,2,3), arg2=list(4,5,6)) |
| 11 |
expect_equal(.garg(ll, 'arg1'), 1) |
| 12 |
expect_equal(.garg(ll, 'arg1',2), 2) |
| 13 |
expect_equal(.garg(ll, 'arg2',3), 6) |
| 14 |
expect_equal(.garg(ll, 'arg3'), ll$arg3) |
| 15 |
|
| 16 |
ll <- list(arg1=list(c(1,2,3), c(2,3,4), c(3,4,5)), |
| 17 |
arg2=list('a', 'b', 'c')) |
| 18 |
expect_equal(.slice.run(ll, 1), list(arg1=c(1,2,3), arg2='a')) |
| 19 |
expect_equal(.slice.run(ll, 2), list(arg1=c(2,3,4), arg2='b')) |
| 20 |
expect_equal(.slice.run(ll, 3), list(arg1=c(3,4,5), arg2='c')) |
| 21 |
|
| 22 |
ll <- list(arg1=list(c(1,2,3), c(2,3,4), c(3,4,5)), |
| 23 |
arg2=c('a', 'b', 'c')) |
| 24 |
expect_equal(.slice.run(ll, 1), list(arg1=c(1,2,3), arg2=c('a', 'b', 'c'))) |
| 25 |
expect_equal(.slice.run(ll, 2), list(arg1=c(2,3,4), arg2=c('a', 'b', 'c'))) |
| 26 |
expect_equal(.slice.run(ll, 3), list(arg1=c(3,4,5), arg2=c('a', 'b', 'c'))) |
| 27 |
|
| 28 |
actual <- ROCR:::.select.args(ll, "arg1") |
| 29 |
expect_equal(actual,ll["arg1"]) |
| 30 |
actual <- ROCR:::.select.args(ll, "arg1", complement = TRUE) |
| 31 |
expect_equal(actual,ll["arg2"]) |
| 32 |
|
| 33 |
actual <- ROCR:::.construct.linefunct(1,2,3,4) |
| 34 |
expect_type(actual, "closure") |
| 35 |
expect_error(ROCR:::.construct.linefunct(1,2,1,4), |
| 36 |
"Cannot construct a function from data.") |
| 37 |
|
| 38 |
f <- ROCR:::.construct.linefunct(1,2,3,4) |
| 39 |
g <- ROCR:::.construct.linefunct(2,3,4,5) |
| 40 |
actual <- ROCR:::.intersection.point(f,g) |
| 41 |
expect_equal(actual, c(Inf,Inf)) |
| 42 |
g <- ROCR:::.construct.linefunct(2,3,1,5) |
| 43 |
actual <- ROCR:::.intersection.point(f,g) |
| 44 |
expect_equal(actual, c(2,3)) |
| 45 |
}) |