@@ -14,6 +14,56 @@ test_that("seq", {
1414 expect_quick_identical(fn , list (- 1L , 10L ), list (10L , - 5L ))
1515})
1616
17+ test_that(" seq supports literal bounds and steps" , {
18+ seq_range <- function () {
19+ out <- seq(2L , 5L )
20+ out
21+ }
22+
23+ seq_step <- function () {
24+ out <- seq(1L , 5L , by = 2L )
25+ out
26+ }
27+
28+ expect_quick_identical(seq_range , list ())
29+ expect_quick_identical(seq_step , list ())
30+ })
31+
32+ test_that(" seq_along returns linear indices for arrays" , {
33+ seq_along_matrix <- function (x ) {
34+ declare(type(x = double(m , n )))
35+ out <- seq_along(x )
36+ out
37+ }
38+
39+ expect_quick_identical(
40+ seq_along_matrix ,
41+ list (matrix (as.double(1 : 6 ), nrow = 2 ))
42+ )
43+ })
44+
45+ test_that(" seq rejects length.out and along.with" , {
46+ bad_length_out <- function () {
47+ out <- seq(1L , 5L , length.out = 3L )
48+ out
49+ }
50+
51+ bad_along_with <- function (x ) {
52+ declare(type(x = double(NA )))
53+ out <- seq(along.with = x )
54+ out
55+ }
56+
57+ expect_error(
58+ quick(bad_length_out ),
59+ regexp = " seq\\ (length.out=, along.with=\\ ) not implemented yet"
60+ )
61+ expect_error(
62+ quick(bad_along_with ),
63+ regexp = " seq\\ (length.out=, along.with=\\ ) not implemented yet"
64+ )
65+ })
66+
1767test_that(" seq-like iterables work in subset indexing" , {
1868 seq_index <- function (x , start , end ) {
1969 declare(
0 commit comments