-
Notifications
You must be signed in to change notification settings - Fork 316
/
Copy pathok-errors.R
25 lines (21 loc) · 853 Bytes
/
ok-errors.R
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"