|
1 | 1 |
|
2 | | -## Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois |
| 2 | +## Copyright (C) 2010 - 2024 Dirk Eddelbuettel and Romain Francois |
| 3 | +## Copyright (C) 2025 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar |
3 | 4 | ## |
4 | 5 | ## This file is part of Rcpp. |
5 | 6 | ## |
@@ -302,9 +303,49 @@ expect_equal( fx( c(1:10) ), fx( c(1:10) ) ) |
302 | 303 |
|
303 | 304 | # test.sugar.lapply <- function( ){ |
304 | 305 | fx <- runit_lapply |
| 306 | +expect_equal( fx( 1:10 ), as.list((1:10)^2) ) |
| 307 | + |
| 308 | + |
| 309 | +# test.sugar.lapply.rawfun <- function( ){ |
| 310 | +fx <- runit_lapply_rawfun |
| 311 | +expect_equal( fx( 1:10 ), as.list((1:10)^2) ) |
| 312 | + |
| 313 | + |
| 314 | +# test.sugar.lapply.lambda <- function( ){ |
| 315 | +fx <- runit_lapply_lambda |
| 316 | +expect_equal( fx( 1:10 ), as.list((1:10)^2) ) |
| 317 | + |
| 318 | + |
| 319 | +# test.sugar.lapply.seq <- function( ){ |
| 320 | +fx <- runit_lapply_seq |
305 | 321 | expect_equal( fx( 1:10 ), lapply( 1:10, seq_len ) ) |
306 | 322 |
|
307 | 323 |
|
| 324 | +# test.sugar.mapply2 <- function( ){ |
| 325 | +fx <- runit_mapply2 |
| 326 | +expect_equal( fx(1:10, 1:10) , 1:10+1:10 ) |
| 327 | + |
| 328 | + |
| 329 | +# test.sugar.mapply2.lambda <- function( ){ |
| 330 | +fx <- runit_mapply2_lambda |
| 331 | +expect_equal( fx(1:10, 1:10) , 1:10+1:10 ) |
| 332 | + |
| 333 | + |
| 334 | +# test.sugar.mapply3.lambda <- function( ){ |
| 335 | +fx <- runit_mapply3_lambda |
| 336 | +expect_equal( fx(1:10, 1:10, 1:10) , 1:10+1:10+1:10 ) |
| 337 | + |
| 338 | + |
| 339 | +# test.sugar.mapply2.logical <- function( ){ |
| 340 | +fx <- runit_mapply2_logical |
| 341 | +expect_true( fx(1:10, 1:10) ) |
| 342 | + |
| 343 | + |
| 344 | +# test.sugar.mapply2.list <- function( ){ |
| 345 | +fx <- runit_mapply2_list |
| 346 | +expect_equal( fx(1:10, 1:10*2) , mapply(seq, 1:10, 1:10*2) ) |
| 347 | + |
| 348 | + |
308 | 349 | # test.sugar.minus <- function( ){ |
309 | 350 | fx <- runit_minus |
310 | 351 | expect_equal(fx(1:10) , |
@@ -380,6 +421,11 @@ fx <- runit_sapply_rawfun |
380 | 421 | expect_equal( fx(1:10) , (1:10)^2 ) |
381 | 422 |
|
382 | 423 |
|
| 424 | +# test.sugar.sapply.lambda <- function( ){ |
| 425 | +fx <- runit_sapply_lambda |
| 426 | +expect_equal( fx(1:10) , (1:10)^2 ) |
| 427 | + |
| 428 | + |
383 | 429 | # test.sugar.sapply.square <- function( ){ |
384 | 430 | fx <- runit_sapply_square |
385 | 431 | expect_true( ! fx(1:10) ) |
@@ -492,6 +538,13 @@ y <- 1:5 |
492 | 538 | expect_equal( fx(x,y) , outer(x,y,"+") ) |
493 | 539 |
|
494 | 540 |
|
| 541 | +# test.sugar.matrix.outer.lambda <- function( ){ |
| 542 | +fx <- runit_outer_lambda |
| 543 | +x <- 1:2 |
| 544 | +y <- 1:5 |
| 545 | +expect_equal( fx(x,y) , outer(x,y,"+") ) |
| 546 | + |
| 547 | + |
495 | 548 | # test.sugar.matrix.row <- function( ){ |
496 | 549 | fx <- runit_row |
497 | 550 | m <- matrix( 1:16, nc = 4 ) |
|
0 commit comments