Skip to content

Commit

Permalink
On windows, unicode only on 4.2 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jul 1, 2024
1 parent d860722 commit 51ac758
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions tests/testthat/test-reproducible-output.R
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
test_that("local_reproducible_output() respects local context", {
test_that("local_reproducible_output() respects local context", {

local_reproducible_output(width = 105)
expect_equal(getOption("width"), 105)
local_reproducible_output(width = 105)
expect_equal(getOption("width"), 105)

local({
local_reproducible_output(width = 110)
expect_equal(getOption("width"), 110)
local({
local_reproducible_output(width = 110)
expect_equal(getOption("width"), 110)
})

expect_equal(getOption("width"), 105)
})

expect_equal(getOption("width"), 105)
})
test_that("local_envvar respects local context", {
local_envvar(test = "a")
expect_equal(Sys.getenv("test"), "a")

test_that("local_envvar respects local context", {
local_envvar(test = "a")
expect_equal(Sys.getenv("test"), "a")
local({
local_envvar(test = "b")
expect_equal(Sys.getenv("test"), "b")
})

local({
local_envvar(test = "b")
expect_equal(Sys.getenv("test"), "b")
})
expect_equal(Sys.getenv("test"), "a")
local({
local_envvar(test = NA)
expect_equal(Sys.getenv("test"), "")
})

expect_equal(Sys.getenv("test"), "a")
local({
local_envvar(test = NA)
expect_equal(Sys.getenv("test"), "")
expect_equal(Sys.getenv("test"), "a")
})

expect_equal(Sys.getenv("test"), "a")
})

test_that("local_collate respects local context", {
locale <- switch(Sys.info()[["sysname"]],
Darwin = ,
Linux = "en_US.UTF-8",
Windows = "en-US"
)
skip_if(is.null(locale), "Don't know good locale to use for this platform")
local_collate("C")
expect_equal(Sys.getlocale("LC_COLLATE"), "C")

local({
local_collate(locale)
expect_equal(Sys.getlocale("LC_COLLATE"), locale)
test_that("local_collate respects local context", {
locale <- switch(Sys.info()[["sysname"]],
Darwin = ,
Linux = "en_US.UTF-8",
Windows = if (getRversion() >= "4.2") "en-US"
)
skip_if(is.null(locale), "Don't know good locale to use for this platform")

local_collate("C")
expect_equal(Sys.getlocale("LC_COLLATE"), "C")

local({
local_collate(locale)
expect_equal(Sys.getlocale("LC_COLLATE"), locale)
})

expect_equal(Sys.getlocale("LC_COLLATE"), "C")
})

expect_equal(Sys.getlocale("LC_COLLATE"), "C")
})

0 comments on commit 51ac758

Please sign in to comment.