File: test-parse_transforms.2.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 (24 lines) | stat: -rw-r--r-- 392 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
rm(list=ls())

Temperature(x, system, units) %as%
{
  x@system <- system
  x@units <- units
  x
}

freezing(x) %when% {
  x@system == 'metric'
  x@units == 'celsius'
} %as% {
  if (x < 0) { TRUE }
  else { FALSE }
}

assert('parse_transforms_2', {
  temp <- Temperature(20, 'metric', 'celsius')
  (attr(temp,'system') == 'metric')
  (attr(temp,'units') == 'celsius')

  (! freezing(temp))
})