/usr/lib/R/site-library/lambda.r/unitTests/runit.type_variable.1.R is in r-cran-lambda.r 1.1.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | test.type_variable_1 <- function() {
fib(n) %::% a : a
fib(0) %as% 1
fib(1) %as% 1
fib(n) %as% { fib(n-1) + fib(n-2) }
seal(fib)
#act <- tryCatch(f(2,3), error=function(x) 'error')
#checkEquals(act, 'error')
act <- fib(3)
checkEquals(act, 3)
}
# This is not working from the shell but works interactively
ignore.type_variable_2 <- function() {
fib(n) %::% b : a
fib(0) %as% 1
fib(1) %as% 1
fib(n) %as% { fib(n-1) + fib(n-2) }
seal(fib)
act <- tryCatch(f(2), error=function(x) 'error')
cat("\ntest.type_variable_2: act =",act,"\n")
checkEquals('error', act)
}
# This is not working from the shell but works interactively
ignore.type_variable_3 <- function() {
fib(n) %::% a : b
fib(0) %as% 1
fib(1) %as% 1
fib(n) %as% { fib(n-1) + fib(n-2) }
seal(fib)
act <- tryCatch(f(2), error=function(x) 'error')
checkEquals('error', act)
}
test.type_variable_4 <- function() {
hypotenuse(a,b) %::% a : a : a
hypotenuse(a,b) %as% { (a^2 + b^2)^.5 }
seal(hypotenuse)
#act <- tryCatch(f(2), error=function(x) 'error')
#checkEquals(act, 'error')
act <- hypotenuse(3,4)
checkEquals(act,5)
}
test.type_variable_5 <- function() {
hypotenuse(a,b) %::% a : b : a
hypotenuse(a,b) %as% { (a^2 + b^2)^.5 }
seal(hypotenuse)
act <- tryCatch(hypotenuse(5,12), error=function(x) 'error')
checkEquals(act, 'error')
}
test.type_variable_6 <- function() {
hypotenuse(a,b) %::% a : a : b
hypotenuse(a,b) %as% { (a^2 + b^2)^.5 }
seal(hypotenuse)
act <- tryCatch(hypotenuse(5,12), error=function(x) 'error')
checkEquals(act, 'error')
}
test.mixed_type_variable_1 <- function() {
Point(x,y) %as% list(x=x,y=y)
distance(a,b) %::% Point : Point : z
distance(a,b) %as% { ((a$x - b$x)^2 + (a$y - b$y)^2)^.5 }
seal(distance)
point.1 <- Point(2, 2)
point.2 <- Point(1, 1)
act <- distance(point.1, point.2)
checkEquals(act, sqrt(2))
}
|