diff --git a/NEWS.md b/NEWS.md index f2829abf5..19860b347 100644 --- a/NEWS.md +++ b/NEWS.md @@ -46,6 +46,8 @@ * added guarantee that styled code is parsable (#892). * An error is now thrown on styling if input unicode characters can't be correctly parsed for Windows and R < 4.2 (#883). +* styling of text does not error anymore when the R option `OutDec` is set to + a non-default value (#912). * Fix argument name `filetype` in Example for `style_dir()` (#855). diff --git a/R/style-guides.R b/R/style-guides.R index fad609f39..157a2c556 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -222,7 +222,7 @@ tidyverse_style <- function(scope = "tokens", ) ) - if (getRversion() < 3.6) { + if (getRversion() < "3.6") { transformers_drop$token$force_assignment_op <- NULL } diff --git a/tests/testthat/test-indention_operators.R b/tests/testthat/test-indention_operators.R index 153e8f221..a3c111c75 100644 --- a/tests/testthat/test-indention_operators.R +++ b/tests/testthat/test-indention_operators.R @@ -8,7 +8,7 @@ test_that("pipe is indended correctly", { }) test_that("base pipe is indended correctly", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() < "4.1") expect_warning(test_collection("indention_operators", "base_pipe", transformer = style_text diff --git a/tests/testthat/test-line_breaks_and_other.R b/tests/testthat/test-line_breaks_and_other.R index 74d8579fd..b1f622a49 100644 --- a/tests/testthat/test-line_breaks_and_other.R +++ b/tests/testthat/test-line_breaks_and_other.R @@ -45,7 +45,7 @@ test_that("line break before comma is removed and placed after comma ", { }) test_that("Can handle base R pie", { - skip_if(getRversion() < 4.1) + skip_if(getRversion() < "4.1") expect_warning(test_collection("line_breaks_and_other", "base-pipe-line", transformer = style_text ), NA) diff --git a/tests/testthat/test-parsing.R b/tests/testthat/test-parsing.R index 2b4707d3b..faf188cfa 100644 --- a/tests/testthat/test-parsing.R +++ b/tests/testthat/test-parsing.R @@ -65,7 +65,7 @@ test_that("mixed CRLF / LF EOLs fail", { }) test_that("unicode can't be propprely handled on Windows for R < 4.2", { - msg <- ifelse(getRversion() < 4.2 && is_windows(), + msg <- ifelse(getRversion() < "4.2" && is_windows(), "Can't parse input due to unicode restriction in base R\\.", NA ) diff --git a/tests/testthat/test-public_api.R b/tests/testthat/test-public_api.R index e5abb00b2..cda27b549 100644 --- a/tests/testthat/test-public_api.R +++ b/tests/testthat/test-public_api.R @@ -486,6 +486,11 @@ test_that("Can display warning on unset styler cache", { ) }) +test_that("No sensitive to decimal option", { + withr::local_options(OutDec = ",") + expect_error(style_text("1"), NA) +}) + test_that("Can display warning on unset styler cache", { withr::local_options(styler.cache_root = "styler-perm") withr::local_seed(7) diff --git a/tests/testthat/test-transformers-drop.R b/tests/testthat/test-transformers-drop.R index b0fafbcae..18ce38eaf 100644 --- a/tests/testthat/test-transformers-drop.R +++ b/tests/testthat/test-transformers-drop.R @@ -96,7 +96,7 @@ test_that("tidyverse transformers are correctly dropped", { names_tokens <- c( "fix_quotes", - if (getRversion() < 3.6) "force_assignment_op" + if (getRversion() < "3.6") "force_assignment_op" ) expect_setequal(names(t_fun$token), names_tokens) })