Skip to content

Commit

Permalink
better locale robustness (#6144)
Browse files Browse the repository at this point in the history
* better locale robustness

* errant ')'
  • Loading branch information
MichaelChirico authored May 21, 2024
1 parent 4c5f1e7 commit 0da9496
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions inst/tests/nafill.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ if (test_bit64) {
# coerceAs verbose
options(datatable.verbose=2L)
input = 1
# use levels= explicitly to avoid locale-related sorting of letters
xy_factor = factor(c("x", "y"), levels=c("x", "y"))
test(10.01, ans<-coerceAs(input, 1), 1, output="double[numeric] into double[numeric]")
test(10.02, address(input)!=address(ans))
test(10.03, ans<-coerceAs(input, 1, copy=FALSE), 1, output="copy=false and input already of expected type and class double[numeric]")
Expand All @@ -284,11 +286,11 @@ test(10.12, coerceAs("a", factor()), factor("a"), output="character[character] i
test(10.13, coerceAs(1, factor("x")), factor("x"), output="double[numeric] into integer[factor]")
test(10.14, coerceAs(1, factor("x", levels=c("x","y"))), factor("x", levels=c("x","y")), output="double[numeric] into integer[factor]")
test(10.15, coerceAs(2, factor("x", levels=c("x","y"))), factor("y", levels=c("x","y")), output="double[numeric] into integer[factor]")
test(10.16, coerceAs(1:2, factor(c("x","y"))), factor(c("x","y")), output="integer[integer] into integer[factor]")
test(10.17, coerceAs(1:3, factor(c("x","y"))), output="integer[integer] into integer[factor]", error="factor numbers.*3 is outside the level range")
test(10.18, coerceAs(c(1,2,3), factor(c("x","y"))), output="double[numeric] into integer[factor]", error="factor numbers.*3.000000 is outside the level range")
test(10.19, coerceAs(factor("x"), factor(c("x","y"))), factor("x", levels=c("x","y")), output="integer[factor] into integer[factor]")
test(10.20, coerceAs(factor("x"), factor(c("x","y")), copy=FALSE), factor("x", levels=c("x","y")), output="input already of expected type and class") ## copy=F has copyMostAttrib
test(10.16, coerceAs(1:2, xy_factor), xy_factor, output="integer[integer] into integer[factor]")
test(10.17, coerceAs(1:3, xy_factor), output="integer[integer] into integer[factor]", error="factor numbers.*3 is outside the level range")
test(10.18, coerceAs(c(1,2,3), xy_factor), output="double[numeric] into integer[factor]", error="factor numbers.*3.000000 is outside the level range")
test(10.19, coerceAs(factor("x"), xy_factor), factor("x", levels=c("x","y")), output="integer[factor] into integer[factor]")
test(10.20, coerceAs(factor("x"), xy_factor, copy=FALSE), factor("x", levels=c("x","y")), output="input already of expected type and class") ## copy=F has copyMostAttrib
a = structure("a", class="a")
b = structure("b", class="b")
test(10.21, coerceAs(a, b), structure("a", class="b"), output="character[a] into character[b]")
Expand Down

0 comments on commit 0da9496

Please sign in to comment.