Skip to content

Commit

Permalink
Skip non-ASCII tests if system does not support UTF-8 (#749)
Browse files Browse the repository at this point in the history
* fix: skip non-ASCII tests is system does not support UTF-8

* test(exercise_check_unparsable_unicode): split test into one test with a non-ASCII character string and one test with a non-ASCII variable name

* Non-ASCII character strings should work on all platforms
* Non-ASCII variable names should only work on platforms with UTF-8 support
  • Loading branch information
rossellhayes authored and gadenbuie committed Nov 8, 2022
1 parent 7949794 commit 735735e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/testthat/test-exercise.R
Original file line number Diff line number Diff line change
Expand Up @@ -1222,12 +1222,20 @@ test_that("evaluate_exercise() returns message for unparsable non-ASCII code", {

test_that("evaluate_exercise() does not return a message for parsable non-ASCII code", {
skip_if_not_pandoc("1.14")

# Non-ASCII text in character string
ex <- mock_exercise(user_code = 'x <- "What\u203d"')
result <- evaluate_exercise(ex, new.env())
expect_null(result$feedback)

skip_on_os("windows")
# Skip if OS does not support UTF-8
skip_if(!isTRUE(l10n_info()[["UTF-8"]]))

# Greek variable name and interrobang in character string
# Non-ASCII variable name
ex <- mock_exercise(
user_code =
'\u03bc\u03b5\u03c4\u03b1\u03b2\u03bb\u03b7\u03c4\u03ae <- "What\u203d"'
'\u03bc\u03b5\u03c4\u03b1\u03b2\u03bb\u03b7\u03c4\u03ae <- "What?"'
)
result <- evaluate_exercise(ex, new.env())
expect_null(result$feedback)
Expand Down

0 comments on commit 735735e

Please sign in to comment.