File: ok-errors.R

package info (click to toggle)
r-base 4.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112,924 kB
  • sloc: ansic: 291,338; fortran: 111,889; javascript: 14,798; yacc: 6,154; sh: 5,689; makefile: 5,239; tcl: 4,562; perl: 963; objc: 791; f90: 758; asm: 258; java: 31; sed: 1
file content (25 lines) | stat: -rw-r--r-- 853 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
#### STRICT test suite in the spirit of no-segfaults,
#### but with explicit statements.

tools::assertError(options(catch.script.errors = NA)) # TRUE or FALSE
options(catch.script.errors = TRUE)
stop("test of 'options(catch.script.errors = TRUE)'")

if(FALSE) {
## these ought to work on machines with enough memory
## These segfaulted in 1.3.x ,  give "could not allocate" errors now
  integer(2^30+1)
   double(2^30+1)
  complex(2^30+1)
character(2^30+1)
vector("list", 2^30+2)
}

## bad infinite recursion / on.exit / ... interactions
##   catch the error to permit different error messages emitted
##   (handling of infinite recursion is different in the AST interpreter
##   and the byte-code interpreter)

bar <- function() 1+1
foo <- function() { on.exit(bar()); foo() }
tryCatch(foo(), error=function(x) TRUE) # now simple "infinite recursion"