Debian Codegraph @

tests/test-ci/test-yaml.R

raw
1 library(testit)
2
3 # test yaml_load() error handler (requires the yaml package)
4 if (loadable('yaml')) assert('yaml_load() shows helpful error message on invalid YAML', {
5 invalid_yaml = 'a: [\nunclosed bracket'
6 msgs = c()
7 tryCatch(
8 withCallingHandlers(
9 yaml_load(invalid_yaml),
10 message = function(m) {
11 msgs <<- c(msgs, conditionMessage(m)); invokeRestart('muffleMessage')
12 }
13 ),
14 error = function(e) NULL
15 )
16 (gsub('^Failed to parse YAML:.*', '', msgs) %==% '')
17 })