Skip to content

Commit b1ea5d4

Browse files
committed
streamlined initial test and sourceCpp
1 parent ab25ba0 commit b1ea5d4

15 files changed

+28
-78
lines changed

inst/tinytest/test_s4.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2020

21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/S4.cpp")
21+
Rcpp::sourceCpp("cpp/S4.cpp")
2522

2623
# test.RObject.S4methods <- function(){
2724
setClass("track", representation(x="numeric", y="numeric"))

inst/tinytest/test_stack.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20-
21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/stack.cpp")
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2520

21+
Rcpp::sourceCpp("cpp/stack.cpp")
2622

2723
## On old versions of R, Rcpp_fast_eval() falls back to Rcpp_eval() and
2824
## leaks on longjumps

inst/tinytest/test_stats.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2020

21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/stats.cpp")
21+
Rcpp::sourceCpp("cpp/stats.cpp")
2522

2623
# test.stats.dbeta <- function() {
2724
vv <- seq(0, 1, by = 0.1)

inst/tinytest/test_string.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2020

21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/String.cpp")
21+
Rcpp::sourceCpp("cpp/String.cpp")
2522

2623
# test.replace_all <- function(){
2724
expect_equal( String_replace_all("abcdbacdab", "ab", "AB"), "ABcdbacdAB")

inst/tinytest/test_subset.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20-
21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/Subset.cpp")
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2520

21+
Rcpp::sourceCpp("cpp/Subset.cpp")
2622

2723
# test.subset <- function() {
2824

inst/tinytest/test_sugar.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2020

21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/sugar.cpp")
21+
Rcpp::sourceCpp("cpp/sugar.cpp")
2522

2623
## Needed for a change in R 3.6.0 reducing a bias in very large samples
2724
suppressWarnings(RNGversion("3.5.0"))

inst/tinytest/test_sugar_var.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20-
21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2420

2521
# test.Sugar.var <- function() {
2622
fNumeric <- Rcpp::cppFunction('double myVar(NumericVector x) { return(var(x)); }')

inst/tinytest/test_support.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2020

21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/support.cpp")
21+
Rcpp::sourceCpp("cpp/support.cpp")
2522

2623
# test.plus.REALSXP <- function(){
2724
expect_equal(plus_REALSXP(), list(NA_real_,NA_real_,NA_real_) , info = " REALSXP + REALSXP" )

inst/tinytest/test_system.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20-
21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2420

2521
# test.Rcpp.system.file <- function() {
2622
inc_rcpp <- Rcpp:::Rcpp.system.file("include")

inst/tinytest/test_table.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@
1616
## You should have received a copy of the GNU General Public License
1717
## along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
1818

19-
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
20-
21-
if (!.runThisTest) exit_file("Skipping, set 'RunAllRcppTests=yes' to run.")
22-
23-
library(Rcpp)
24-
sourceCpp("cpp/table.cpp")
19+
if (Sys.getenv("RunAllRcppTests") != "yes") exit_file("Set 'RunAllRcppTests' to 'yes' to run.")
2520

21+
Rcpp::sourceCpp("cpp/table.cpp")
2622

2723
table_ <- function(x) c(base::table(x, useNA="ifany"))
2824

0 commit comments

Comments
 (0)