File: test-type_variable.1.R

package info (click to toggle)
r-cran-lambda.r 1.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 284 kB
  • sloc: sh: 9; makefile: 2
file content (84 lines) | stat: -rw-r--r-- 1,820 bytes parent folder | download | duplicates (2)
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
80
81
82
83
84
rm(list=ls())
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)
  (act == 3)
}

rm(list=ls())
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")
  ('error' == act)
}

rm(list=ls())
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')
  ('error' == act)
}

rm(list=ls())
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)
  (act ==5)
}

rm(list=ls())
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')
  (act == 'error')
}

rm(list=ls())
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')
  (act == 'error')
}

rm(list=ls())
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)
  (act == sqrt(2))
}