Skip to content

Commit

Permalink
Parse test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jun 27, 2024
1 parent 084ae00 commit 178bcea
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions tests/testthat/test-parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@ test_that("parse(allow_error = TRUE/FALSE)", {
expect_error(parse_all('x <-', allow_error = FALSE))
res <- parse_all('x <-', allow_error = TRUE)
expect_true(inherits(attr(res, 'PARSE_ERROR'), 'error'))
})

# test some multibyte characters when the locale is UTF8 based
if (isTRUE(l10n_info()[['UTF-8']])) {
# And correctly flows through to evaluate
expect_no_error(evaluate('x <-', stop_on_error = 0))
})

test_that("double quotes in Chinese characters not destroyed", {
expect_identical(parse_all(c('1+1', '"你好"'))[2, 1], '"你好"')
})
test_that("double quotes in Chinese characters not destroyed", {
skip_if_not(l10n_info()[['UTF-8']])

test_that("multibyte characters are parsed correct", {
code <- c("ϱ <- 1# g / ml", "äöüßÄÖÜπ <- 7 + 3# nonsense")
expect_identical(parse_all(code)$src, append_break(code))
})
}
expect_identical(parse_all(c('1+1', '"你好"'))[2, 1], '"你好"')
})

test_that("can ignore parse errors", {
expect_error(evaluate('x <-', stop_on_error = 0), NA)
test_that("multibyte characters are parsed correct", {
skip_if_not(l10n_info()[['UTF-8']])

code <- c("ϱ <- 1# g / ml", "äöüßÄÖÜπ <- 7 + 3# nonsense")
expect_identical(parse_all(code)$src, append_break(code))
})

# find_function_body -----------------------------------------------------------
Expand Down

0 comments on commit 178bcea

Please sign in to comment.