Skip to content

Commit 9c5bbfe

Browse files
committed
Protect a handful of NA tests from running under arm64/Darwin
1 parent c550759 commit 9c5bbfe

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* inst/tinytest/test_stats.R: Revisit change from PR #1252; we now
44
use a slightly smaller tolerance to accomodate old and new value
55

6+
* inst/tinytest/test_sugar.R: Protect a small number of tests on NA
7+
propagation from running on arm64/Darwin which requires special care
8+
69
2023-03-25 Iñaki Ucar <[email protected]>
710

811
* R/Attributes.R: Switch to system2 to be able to capture stderr on error

inst/tinytest/test_sugar.R

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
## Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
2+
## Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
33
##
44
## This file is part of Rcpp.
55
##
@@ -20,6 +20,10 @@ if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to
2020

2121
Rcpp::sourceCpp("cpp/sugar.cpp")
2222

23+
## There are some (documented, see https://blog.r-project.org/2020/11/02/will-r-work-on-apple-silicon/index.html)
24+
## issues with NA propagation on arm64 / macOS. We not (yet ?) do anything special so we just skip some tests
25+
isArmMacOs <- Sys.info()[["sysname"]] == "Darwin" && Sys.info()[["machine"]] == "arm64"
26+
2327
## Needed for a change in R 3.6.0 reducing a bias in very large samples
2428
suppressWarnings(RNGversion("3.5.0"))
2529

@@ -31,8 +35,8 @@ expect_equal( runit_abs(x,y) , list( abs(x), abs(y) ) )
3135
# test.sugar.all.one.less <- function( ){
3236
expect_true( runit_all_one_less( 1 ) )
3337
expect_true( ! runit_all_one_less( 1:10 ) )
34-
expect_true( is.na( runit_all_one_less( NA ) ) )
35-
expect_true( is.na( runit_all_one_less( c( NA, 1) ) ) )
38+
if (!isArmMacOs) expect_true( is.na( runit_all_one_less( NA ) ) )
39+
if (!isArmMacOs) expect_true( is.na( runit_all_one_less( c( NA, 1) ) ) )
3640
expect_true( ! runit_all_one_less( c( 6, NA) ) )
3741

3842

@@ -41,14 +45,14 @@ expect_true( ! runit_all_one_greater( 1 ) )
4145
expect_true( ! runit_all_one_greater( 1:10 ) )
4246
expect_true( runit_all_one_greater( 6:10 ) )
4347
expect_true( ! runit_all_one_greater( c(NA, 1) ) )
44-
expect_true( is.na( runit_all_one_greater( c(NA, 6) ) ) )
48+
if (!isArmMacOs) expect_true( is.na( runit_all_one_greater( c(NA, 6) ) ) )
4549

4650

4751
# test.sugar.all.one.less.or.equal <- function( ){
4852
expect_true( runit_all_one_less_or_equal( 1 ) )
4953
expect_true( ! runit_all_one_less_or_equal( 1:10 ) )
50-
expect_true( is.na( runit_all_one_less_or_equal( NA ) ) )
51-
expect_true( is.na( runit_all_one_less_or_equal( c( NA, 1) ) ) )
54+
if (!isArmMacOs) expect_true( is.na( runit_all_one_less_or_equal( NA ) ) )
55+
if (!isArmMacOs) expect_true( is.na( runit_all_one_less_or_equal( c( NA, 1) ) ) )
5256
expect_true( ! runit_all_one_less_or_equal( c( 6, NA) ) )
5357
expect_true( runit_all_one_less_or_equal( 5 ) )
5458

@@ -61,15 +65,15 @@ expect_true( ! fx( 1:10 ) )
6165
expect_true( fx( 6:10 ) )
6266
expect_true( fx( 5 ) )
6367
expect_true( ! fx( c(NA, 1) ) )
64-
expect_true( is.na( fx( c(NA, 6) ) ) )
68+
if (!isArmMacOs) expect_true( is.na( fx( c(NA, 6) ) ) )
6569

6670

6771
# test.sugar.all.one.equal <- function( ){
6872
fx <- runit_all_one_equal
6973
expect_true( ! fx( 1 ) )
7074
expect_true( ! fx( 1:2 ) )
7175
expect_true( fx( rep(5,4) ) )
72-
expect_true( is.na( fx( c(5,NA) ) ) )
76+
if (!isArmMacOs) expect_true( is.na( fx( c(5,NA) ) ) )
7377
expect_true(! fx( c(NA, 1) ) )
7478

7579

@@ -78,7 +82,7 @@ fx <- runit_all_not_equal_one
7882
expect_true( fx( 1 ) )
7983
expect_true( fx( 1:2 ) )
8084
expect_true( ! fx( 5 ) )
81-
expect_true( is.na( fx( c(NA, 1) ) ) )
85+
if (!isArmMacOs) expect_true( is.na( fx( c(NA, 1) ) ) )
8286
expect_true( ! fx( c(NA, 5) ) )
8387

8488

@@ -1564,7 +1568,7 @@ expect_error(strimws(x[1], "invalid"), info = "strimws -- bad `which` argument")
15641568
# test.sugar.min.max <- function() {
15651569
## min(empty) gives NA for integer, Inf for numeric (#844)
15661570
expect_true(is.na(intmin(integer(0))), "min(integer(0))")
1567-
expect_equal(doublemin(numeric(0)), Inf, info = "min(numeric(0))")
1571+
if (!isArmMacOs) expect_equal(doublemin(numeric(0)), Inf, info = "min(numeric(0))")
15681572

15691573
## max(empty_ gives NA for integer, Inf for numeric (#844)
15701574
expect_true(is.na(intmax(integer(0))), "max(integer(0))")

0 commit comments

Comments
 (0)