@@ -10,6 +10,18 @@ def test_int_to_int():
1010 start , end = end , start
1111 assert list (start / to / end ) == list (range (start , end - 1 , - 1 ))
1212
13+ def test_int_to_int_with_step ():
14+ for i in range (100 ):
15+ start , end = random .randint (1 , 1e3 ), random .randint (1 , 1e3 )
16+ step = random .randint (1 , 10 )
17+ end += start
18+ assert list (start / to / end / by / step ) == list (range (start , end + 1 , step ))
19+ assert list (start / to / end / by / - step ) == list (range (start , end + 1 , step ))
20+
21+ start , end = end , start
22+ assert list (start / to / end / by / - step ) == list (range (start , end - 1 , - step ))
23+ assert list (start / to / end / by / step ) == list (range (start , end - 1 , - step ))
24+
1325def test_str_to_str ():
1426 assert str ('A' / to / 'Z' ) == 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1527 assert str ('Z' / to / 'A' ) == 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
@@ -19,6 +31,22 @@ def test_str_to_str():
1931 assert str ('V' / to / 'D' ) == 'VUTSRQPONMLKJIHGFED'
2032 assert str ('v' / to / 'd' ) == 'vutsrqponmlkjihgfed'
2133
34+ def test_str_to_str_with_step ():
35+ assert str ('A' / to / 'Z' / by / 3 ) == 'ADGJMPSVY'
36+ assert str ('A' / to / 'Z' / by / - 3 ) == 'ADGJMPSVY'
37+ assert str ('Z' / to / 'A' / by / - 3 ) == 'ZWTQNKHEB'
38+ assert str ('Z' / to / 'A' / by / 3 ) == 'ZWTQNKHEB'
39+ assert str ('a' / to / 'z' / by / 4 ) == 'aeimquy'
40+ assert str ('a' / to / 'z' / by / - 4 ) == 'aeimquy'
41+ assert str ('z' / to / 'a' / by / - 4 ) == 'zvrnjfb'
42+ assert str ('z' / to / 'a' / by / 4 ) == 'zvrnjfb'
43+ assert str ('D' / to / 'V' / by / 5 ) == 'DINS'
44+ assert str ('D' / to / 'V' / by / - 5 ) == 'DINS'
45+ assert str ('V' / to / 'D' / by / - 5 ) == 'VQLG'
46+ assert str ('V' / to / 'D' / by / 5 ) == 'VQLG'
47+ assert str ('v' / to / 'd' / by / - 3 ) == 'vspmjgd'
48+ assert str ('v' / to / 'd' / by / 3 ) == 'vspmjgd'
49+
2250def test_take ():
2351 assert 1 / to / INF / take / 5 == [1 ,2 ,3 ,4 ,5 ]
2452
0 commit comments