-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow feedback on unparsable unicode characters to render without i18next
#765
Changes from all commits
6ed3dc3
d4de8dc
acac97a
9eafb78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1171,52 +1171,42 @@ test_that("Errors with global setup code result in an internal error", { | |
test_that("evaluate_exercise() returns message for unparsable non-ASCII code", { | ||
skip_if_not_pandoc("1.14") | ||
|
||
expect_unparsable_message <- function(user_code, problem, key) { | ||
ex <- mock_exercise(user_code = user_code) | ||
feedback <- evaluate_exercise(ex, new.env())$feedback | ||
expect_equal(feedback, exercise_check_code_is_parsable(ex)$feedback) | ||
expect_match(feedback$message, regexp = key, fixed = TRUE) | ||
for (character in problem) { | ||
expect_match(feedback$message, regexp = character, fixed = TRUE) | ||
} | ||
} | ||
Comment on lines
+1174
to
+1182
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! This cleans up the code quite a bit |
||
|
||
# Curly double quotes | ||
ex <- mock_exercise( | ||
user_code = "str_detect(\u201ctest\u201d, \u201ct.+t\u201d)" | ||
) | ||
result <- evaluate_exercise(ex, new.env()) | ||
expect_equal(result$feedback, exercise_check_code_is_parsable(ex)$feedback) | ||
expect_match(result$feedback$message, "text.unparsablequotes") | ||
expect_match( | ||
result$feedback$message, | ||
i18n_translations()$en$translation$text$unparsablequotes, | ||
fixed = TRUE | ||
expect_unparsable_message( | ||
"str_detect(\u201ctest\u201d, \u201ct.+t\u201d)", | ||
problem = c("\u201c", "\u201d"), | ||
key = "text.unparsablequotes" | ||
) | ||
|
||
# Curly single quotes | ||
ex <- mock_exercise( | ||
user_code = "str_detect(\u2018test\u2019, \u2018t.+t\u2019)" | ||
) | ||
result <- evaluate_exercise(ex, new.env()) | ||
expect_equal(result$feedback, exercise_check_code_is_parsable(ex)$feedback) | ||
expect_match(result$feedback$message, "text.unparsablequotes") | ||
expect_match( | ||
result$feedback$message, | ||
i18n_translations()$en$translation$text$unparsablequotes, | ||
fixed = TRUE | ||
expect_unparsable_message( | ||
"str_detect(\u2018test\u2019, \u2018t.+t\u2019)", | ||
problem = c("\u2018", "\u2019"), | ||
key = "text.unparsablequotes" | ||
) | ||
|
||
# En dash | ||
ex <- mock_exercise(user_code = "63 \u2013 21") | ||
result <- evaluate_exercise(ex, new.env()) | ||
expect_equal(result$feedback, exercise_check_code_is_parsable(ex)$feedback) | ||
expect_match(result$feedback$message, "text.unparsableunicodesuggestion") | ||
expect_match( | ||
result$feedback$message, | ||
i18n_translations()$en$translation$text$unparsableunicodesuggestion, | ||
fixed = TRUE | ||
expect_unparsable_message( | ||
"63 \u2013 21", | ||
problem = "\u2013", | ||
key = "text.unparsableunicodesuggestion" | ||
) | ||
|
||
# Plus-minus sign | ||
ex <- mock_exercise(user_code = "63 \u00b1 21") | ||
result <- evaluate_exercise(ex, new.env()) | ||
expect_equal(result$feedback, exercise_check_code_is_parsable(ex)$feedback) | ||
expect_match(result$feedback$message, "text.unparsableunicode") | ||
expect_match( | ||
result$feedback$message, | ||
i18n_translations()$en$translation$text$unparsableunicode, | ||
fixed = TRUE | ||
expect_unparsable_message( | ||
"63 \u00b1 21", | ||
problem = "\u00b1", | ||
key = "text.unparsableunicode" | ||
) | ||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can trim this down a little bit