]> gitweb.factorcode.org Git - factor.git/blobdiff - core/generalizations/generalizations-tests.factor
generalizations: add generalizations for tuck/over from top of stack
[factor.git] / core / generalizations / generalizations-tests.factor
index c59940026e197ee13fe81185847e673c061389fb..f1f3c2d790d25b0a67bbeb1419fcb1d52911133c 100644 (file)
@@ -1,5 +1,5 @@
 USING: arrays ascii generalizations kernel math math.parser
-sequences tools.test ;
+sequences sequences.generalizations tools.test ;
 IN: generalizations.tests
 
 { 1 2 3 4 1 } [ 1 2 3 4 4 npick ] unit-test
@@ -29,11 +29,59 @@ IN: generalizations.tests
 [ [ 1 ] 5 ndip ] must-infer
 { 1 2 3 4 } [ 2 3 4 [ 1 ] 3 ndip ] unit-test
 
-[ [ 1 2 3 ] 2 3 nrotates ] must-infer
-[ [ 1 2 3 ] 2 3 -nrotates ] must-infer
-{ 1 2 3 4 } [ 1 2 3 4  4 4 nrotates ] unit-test
-{ 1 2 3 4 } [ 1 2 3 4  4 4 -nrotates ] unit-test
-{ 4 1 2 3 } [ 1 2 3 4  1 4 -nrotates ] unit-test
+[ [ 1 2 3 ] 2 3 0 nrotated ] must-infer
+[ [ 1 2 3 ] 2 3 0 -nrotated ] must-infer
+{ 1 2 3 4 } [ 1 2 3 4  4 4 0 nrotated ] unit-test
+{ 1 2 3 4 } [ 1 2 3 4  4 4 0 -nrotated ] unit-test
+{ 3 1 2 4 } [ 1 2 3 4  1 3 1 -nrotated ] unit-test
+
+
+{ 1 2 3  1 2 }
+[ 1 2 3  2 1 0 noverd ] unit-test
+
+{ 1 2 3  4 5 6 7 8  1 2 3  9 }
+[ 1 2 3  4 5 6 7 8  9  3 5 1 noverd ] unit-test
+
+{ t }
+[
+    1 2 3 4 5 6 7   8 9    3 2  ntuckd 10 narray
+    1 2 3 4 5 6 7   8 9  1 3 2 mntuckd 10 narray =
+] unit-test
+
+{ 1  4 5  2 3  4 5  6 7 }
+[ 1 2 3 4 5 6 7  2 4 2 mntuckd ] unit-test
+
+{ 1 2 3 4 2 3 4 5 6 5 6 7 }
+[ 1 2 3 4 5 6 7  5 2 1 mntuckd ] unit-test
+
+{ 4 5 6 7  0 1 2 3 4 5 6 7 8 9 } [
+    0 1 2 3   4 5 6 7   8 9
+    4 8 2 mntuckd
+] unit-test
+
+{ 1 2 3 5 4 } [ 1 2 3 4 5  2 0 -nrotd ] unit-test
+{ 1 2 4 3 5 } [ 1 2 3 4 5  2 1 -nrotd ] unit-test
+{ 1 3 2 4 5 } [ 1 2 3 4 5  2 2 -nrotd ] unit-test
+{ 2 1 3 4 5 } [ 1 2 3 4 5  2 3 -nrotd ] unit-test
+
+{ 1 2 3 5 4 } [ 1 2 3 4 5  2 0  nrotd ] unit-test
+{ 1 2 4 3 5 } [ 1 2 3 4 5  2 1  nrotd ] unit-test
+{ 1 3 2 4 5 } [ 1 2 3 4 5  2 2  nrotd ] unit-test
+{ 2 1 3 4 5 } [ 1 2 3 4 5  2 3  nrotd ] unit-test
+
+{ 1 2 5 3 4 } [ 1 2 3 4 5  3 0 -nrotd ] unit-test
+{ 1 2 5 3 4 } [ 1 2 3 4 5  -3 0 nrotd ] unit-test
+{ 1 4 2 3 5 } [ 1 2 3 4 5  3 1 -nrotd ] unit-test
+{ 1 4 2 3 5 } [ 1 2 3 4 5  -3 1 nrotd ] unit-test
+{ 3 1 2 4 5 } [ 1 2 3 4 5  3 2 -nrotd ] unit-test
+{ 3 1 2 4 5 } [ 1 2 3 4 5  -3 2 nrotd ] unit-test
+
+{ 1 2 4 5 3 } [ 1 2 3 4 5  3 0 nrotd ] unit-test
+{ 1 2 4 5 3 } [ 1 2 3 4 5  -3 0 -nrotd ] unit-test
+{ 1 3 4 2 5 } [ 1 2 3 4 5  3 1 nrotd ] unit-test
+{ 1 3 4 2 5 } [ 1 2 3 4 5  -3 1 -nrotd ] unit-test
+{ 2 3 1 4 5 } [ 1 2 3 4 5  3 2 nrotd ] unit-test
+{ 2 3 1 4 5 } [ 1 2 3 4 5  -3 2 -nrotd ] unit-test
 
 [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer
 [ 1 2 3 4 5 2 '[ drop drop drop drop drop _ ] 5 nkeep ] must-infer