Skip to content

Commit 9548bbd

Browse files
rm_all() kills c_sortable_letters though it's needed later in the test suite
1 parent 89099e3 commit 9548bbd

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

inst/tests/tests.Rraw

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,26 @@ ForderObj = function(x, starts=NULL, maxgrpn=NULL, anyna=0L, anyinfnan=0L, anyno
233233
x
234234
}
235235

236+
c_sortable_letters = letters
237+
# For some tests of forder() compatibility with base sorting methods.
238+
# Subset the letters until the collation order matches C. This way we don't totally ignore
239+
# any possible issues with sorting strings in unusual locales (even though this _should_
240+
# be impossible given we _always_ use C-collated order, such a regression test is still
241+
# beneficial as a sanity check).
242+
if (!identical(order(letters, method='shell'), order(letters, method='radix'))) {
243+
repeat {
244+
sorted_c = c_sortable_letters[order(c_sortable_letters, method='radix')]
245+
sorted_r = c_sortable_letters[order(c_sortable_letters, method='shell')]
246+
247+
mismatch = which(sorted_c != sorted_r)
248+
if (!length(mismatch)) break
249+
c_sortable_letters = c_sortable_letters[-mismatch[1L]]
250+
}
251+
}
252+
if (length(c_sortable_letters) < 5L) {
253+
stop("This locale collates too differently from C; please report.")
254+
}
255+
236256
##########################
237257
.do_not_rm = ls() # objects that exist at this point should not be removed by rm_all(); e.g. test_*, base_messages, Ctest_dt_win_snprintf, prevtest, etc
238258
##########################
@@ -4454,24 +4474,6 @@ test(1221, DT[.(1),b], c("a","c","e"))
44544474
seed = as.integer(Sys.time()) # sample(9999L, 1L) temporary fix, because all the set.seed(.) used above makes this sample() step deterministic (always seed=9107)
44554475
# no NaN (because it's hard to match with base::order); tested below in 1988.4-8
44564476
set.seed(seed)
4457-
c_sortable_letters = letters
4458-
# Subset the letters until the collation order matches C. This way we don't totally ignore
4459-
# any possible issues with sorting strings in unusual locales (even though this _should_
4460-
# be impossible given we _always_ use C-collated order, such a regression test is still
4461-
# beneficial as a sanity check).
4462-
if (!identical(order(letters, method='shell'), order(letters, method='radix'))) {
4463-
repeat {
4464-
sorted_c = c_sortable_letters[order(c_sortable_letters, method='radix')]
4465-
sorted_r = c_sortable_letters[order(c_sortable_letters, method='shell')]
4466-
4467-
mismatch = which(sorted_c != sorted_r)
4468-
if (!length(mismatch)) break
4469-
c_sortable_letters = c_sortable_letters[-mismatch[1L]]
4470-
}
4471-
}
4472-
if (length(c_sortable_letters) < 5L) {
4473-
stop("This locale collates too differently from C; please report.")
4474-
}
44754477
foo <- function(n) apply(matrix(sample(c_sortable_letters, n*8L, TRUE), ncol=8L), 1, paste, collapse="")
44764478
i1 = as.integer(sample(c(-100:100), 1e3, TRUE))
44774479
i2 = as.integer(sample(c(-100:100, -1e6, 1e6), 1e3, TRUE))

0 commit comments

Comments
 (0)