|
| 1 | +#!/usr/bin/r -t |
| 2 | +# -*- mode: R; ess-indent-level: 4; indent-tabs-mode: nil; -*- |
| 3 | +# |
| 4 | +# Copyright (C) 2015 Wush Wu |
| 5 | +# |
| 6 | +# This file is part of Rcpp. |
| 7 | +# |
| 8 | +# Rcpp is free software: you can redistribute it and/or modify it |
| 9 | +# under the terms of the GNU General Public License as published by |
| 10 | +# the Free Software Foundation, either version 2 of the License, or |
| 11 | +# (at your option) any later version. |
| 12 | +# |
| 13 | +# Rcpp is distributed in the hope that it will be useful, but |
| 14 | +# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | +# GNU General Public License for more details. |
| 17 | +# |
| 18 | +# You should have received a copy of the GNU General Public License |
| 19 | +# along with Rcpp. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + |
| 21 | +.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes" |
| 22 | + |
| 23 | +if (.runThisTest) { |
| 24 | + |
| 25 | + test.Sugar.var <- function() { |
| 26 | + f1 <- Rcpp::cppFunction('double myVar(NumericVector x) { return(var(x)); }') |
| 27 | + f2 <- Rcpp::cppFunction('double myVar(IntegerVector x) { return(var(x)); }') |
| 28 | + f3 <- Rcpp::cppFunction('double myVar(ComplexVector x) { return(var(x)); }') |
| 29 | + f4 <- Rcpp::cppFunction('double myVar(LogicalVector x) { return(var(x)); }') |
| 30 | + checkEquals(f1(1:10), var(1:10)) |
| 31 | + checkEquals(f2(1:10), var(1:10)) |
| 32 | + checkEquals(f3(1:10 + (1 + 1i)), var(1:10)) |
| 33 | + checkEquals(f4(c(T, F, T, F, T)), var(c(T, F, T, F, T))) |
| 34 | + } |
| 35 | + |
| 36 | +} |
0 commit comments