@@ -19,8 +19,8 @@ test_that("indexing by numeric vector works", {
1919 cobj <- nCompile(nC )$ new()
2020 x <- matrix (1 : 20 , nrow = 4 )
2121 iv <- c(2 ,3 ,2 ,1 ,5 )
22- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
23- test_i <- paste0( ' test ' , i )
22+ method_names <- ls(nC $ public_methods )
23+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
2424 outC <- cobj [[test_i ]](x , iv )
2525 outR <- nC $ public_methods [[test_i ]](x , iv )
2626 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -91,8 +91,8 @@ test_that("drop arg variations give correct results, 3D input", {
9191# cobj <- nCompile_nClass(nC)$new()
9292 cobj <- nCompile(nC )$ new()
9393 x <- array (1 : 105 , c(3 , 5 , 7 ))
94- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
95- test_i <- paste0( ' test ' , i )
94+ method_names <- ls(nC $ public_methods )
95+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
9696 outC <- cobj [[test_i ]](x )
9797 outR <- nC $ public_methods [[test_i ]](x )
9898 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -142,8 +142,8 @@ test_that("indexing arg variations give correct results, 3D input", {
142142 # cobj <- nCompile_nClass(nC)$new()
143143 cobj <- nCompile(nC )$ new()
144144 x <- array (1 : 105 , c(3 , 5 , 7 ))
145- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
146- test_i <- paste0( ' test ' , i )
145+ method_names <- ls(nC $ public_methods )
146+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
147147 outC <- cobj [[test_i ]](x )
148148 outR <- nC $ public_methods [[test_i ]](x )
149149 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -176,8 +176,8 @@ test_that("assignment involving indexing give correct results, 3D input", {
176176 # cobj <- nCompile_nClass(nC)$new()
177177 cobj <- nCompile(nC )$ new()
178178 x <- array (1 : 105 , c(3 , 5 , 7 ))
179- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
180- test_i <- paste0( ' test ' , i )
179+ method_names <- ls(nC $ public_methods )
180+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
181181 outC <- cobj [[test_i ]](x )
182182 outR <- nC $ public_methods [[test_i ]](x )
183183 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -209,8 +209,8 @@ test_that("expressions involving indexing give correct results, 3D input", {
209209 # cobj <- nCompile_nClass(nC)$new()
210210 cobj <- nCompile(nC )$ new()
211211 x <- array (1 : 105 , c(3 , 8 , 7 ))
212- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
213- test_i <- paste0( ' test ' , i )
212+ method_names <- ls(nC $ public_methods )
213+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
214214 outC <- cobj [[test_i ]](x )
215215 outR <- nC $ public_methods [[test_i ]](x )
216216 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -234,8 +234,8 @@ test_that("scalar input gives correct results", {
234234 # cobj <- nCompile_nClass(nC)$new()
235235 cobj <- nCompile(nC )$ new()
236236 x <- 3
237- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
238- test_i <- paste0( ' test ' , i )
237+ method_names <- ls(nC $ public_methods )
238+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
239239 expect_equal(
240240 nC $ public_methods [[test_i ]](x ), # # R
241241 cobj [[test_i ]](x ) # # C++
@@ -265,8 +265,8 @@ test_that("vector input gives correct results", {
265265 # cobj <- nCompile_nClass(nC)$new()
266266 cobj <- nCompile(nC )$ new()
267267 x <- 1 : 11
268- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
269- test_i <- paste0( ' test ' , i )
268+ method_names <- ls(nC $ public_methods )
269+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
270270 outC <- cobj [[test_i ]](x )
271271 outR <- nC $ public_methods [[test_i ]](x )
272272 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -304,8 +304,8 @@ test_that("matrix input gives correct results", {
304304 # cobj <- nCompile_nClass(nC)$new()
305305 cobj <- nCompile(nC )$ new()
306306 x <- matrix (1 : 21 , c(7 , 3 ))
307- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
308- test_i <- paste0( ' test ' , i )
307+ method_names <- ls(nC $ public_methods )
308+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
309309 outC <- cobj [[test_i ]](x )
310310 outR <- nC $ public_methods [[test_i ]](x )
311311 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -343,8 +343,8 @@ test_that("3-dimensional input array gives correct results", {
343343 # cobj <- nCompile_nClass(nC)$new()
344344 cobj <- nCompile(nC )$ new()
345345 x <- array (1 : 84 , c(3 , 4 , 7 ))
346- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
347- test_i <- paste0( ' test ' , i )
346+ method_names <- ls(nC $ public_methods )
347+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
348348 outC <- cobj [[test_i ]](x )
349349 outR <- nC $ public_methods [[test_i ]](x )
350350 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -396,8 +396,8 @@ test_that("4-dimensional input array gives correct results", {
396396 # cobj <- nCompile_nClass(nC)$new()
397397 cobj <- nCompile(nC )$ new()
398398 x <- array (1 : 924 , c(3 , 7 , 4 , 11 ))
399- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
400- test_i <- paste0( ' test ' , i )
399+ method_names <- ls(nC $ public_methods )
400+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
401401 outC <- cobj [[test_i ]](x )
402402 outR <- nC $ public_methods [[test_i ]](x )
403403 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
@@ -421,8 +421,8 @@ test_that("5-dimensional input array gives correct results", {
421421 # cobj <- nCompile_nClass(nC)$new()
422422 cobj <- nCompile(nC )$ new()
423423 x <- array (1 : 2310 , c(2 , 3 , 7 , 5 , 11 ))
424- for ( i in seq_along( ls(nC $ public_methods )[ - 1 ])) {
425- test_i <- paste0( ' test ' , i )
424+ method_names <- ls(nC $ public_methods )
425+ for ( test_i in method_names [startsWith( method_names , " test " )]) {
426426 outC <- cobj [[test_i ]](x )
427427 outR <- nC $ public_methods [[test_i ]](x )
428428 if (is.array(outC ) && length(attributes(outC )$ dim ) == 1 )
0 commit comments