Skip to content

Commit 476bb31

Browse files
authored
Merge pull request #1260 from RcppCore/bugfix/test_tweaks
Adjust two sets of tests
2 parents 54a7416 + 13b40ce commit 476bb31

File tree

5 files changed

+32
-19
lines changed

5 files changed

+32
-19
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2023-03-26 Dirk Eddelbuettel <[email protected]>
2+
3+
* DESCRIPTION (Version, Date): Roll minor version
4+
* inst/include/Rcpp/config.h (RCPP_DEV_VERSION): Idem
5+
6+
* inst/tinytest/test_stats.R: Revisit change from PR #1252; we now
7+
use a slightly smaller tolerance to accomodate old and new value
8+
9+
* inst/tinytest/test_sugar.R: Protect a small number of tests on NA
10+
propagation from running on arm64/Darwin which requires special care
11+
112
2023-03-25 Iñaki Ucar <[email protected]>
213

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

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 1.0.10.3
4-
Date: 2023-03-19
3+
Version: 1.0.10.4
4+
Date: 2023-03-26
55
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou,
66
Nathan Russell, Inaki Ucar, Douglas Bates and John Chambers
77
Maintainer: Dirk Eddelbuettel <[email protected]>

inst/include/Rcpp/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define RCPP_VERSION_STRING "1.0.10"
3131

3232
// the current source snapshot (using four components, if a fifth is used in DESCRIPTION we ignore it)
33-
#define RCPP_DEV_VERSION RcppDevVersion(1,0,10,3)
34-
#define RCPP_DEV_VERSION_STRING "1.0.10.3"
33+
#define RCPP_DEV_VERSION RcppDevVersion(1,0,10,4)
34+
#define RCPP_DEV_VERSION_STRING "1.0.10.4"
3535

3636
#endif

inst/tinytest/test_stats.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,9 @@ expect_equal(runit_qnorm_log(c(-Inf, 0, 0.1)),
243243
list(lower = c(-Inf, Inf, NaN),
244244
upper = c(Inf, -Inf, NaN)),
245245
info = "stats.qnorm" )
246-
if (getRversion() >= "4.3.0") { # newer high-precision code in R 4.3.0
247-
expect_equal(runit_qnorm_log(-1e5)$lower, -447.197893678525)
248-
} else { # older pre-R 4.3.0 value
249-
expect_equal(runit_qnorm_log(-1e5)$lower, -447.1974945)
250-
}
246+
## newer high-precision code in R 4.3.0 has slightly different value
247+
## of -447.197893678525 so lowering tolerance a little
248+
expect_equal(runit_qnorm_log(-1e5)$lower, -447.1974945, tolerance=1e-6)
251249

252250
# test.stats.qpois.prob <- function( ) {
253251
vv <- seq(0, 1, by = 0.1)

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)