]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/assocs/extras/extras-tests.factor
assocs.extras: deep-at -> deep-of
[factor.git] / extra / assocs / extras / extras-tests.factor
index 25ded3f642d82048654a67c6bd4e249fb5fba32e..c8233c6d251588d0f133cd7bbf8b7646b99b6e29 100644 (file)
@@ -6,12 +6,12 @@ USING: arrays assocs.extras kernel math math.order sequences tools.test ;
     H{ } clone 10 { 1 2 3 4 5 } pick push-at-each
 ] unit-test
 
-{ f } [ f { } deep-at ] unit-test
-{ f } [ f { "foo" } deep-at ] unit-test
-{ f } [ H{ } { 1 2 3 } deep-at ] unit-test
-{ f } [ H{ { "a" H{ { "b" 1 } } } } { "a" "c" } deep-at ] unit-test
-{ 1 } [ H{ { "a" H{ { "b" 1 } } } } { "a" "b" } deep-at ] unit-test
-{ 4 } [ H{ { 1 H{ { 2 H{ { 3 4 } } } } } } { 1 2 3 } deep-at ] unit-test
+{ f } [ f { } deep-of ] unit-test
+{ f } [ f { "foo" } deep-of ] unit-test
+{ f } [ H{ } { 1 2 3 } deep-of ] unit-test
+{ f } [ H{ { "a" H{ { "b" 1 } } } } { "a" "c" } deep-of ] unit-test
+{ 1 } [ H{ { "a" H{ { "b" 1 } } } } { "a" "b" } deep-of ] unit-test
+{ 4 } [ H{ { 1 H{ { 2 H{ { 3 4 } } } } } } { 1 2 3 } deep-of ] unit-test
 
 { H{ { 2 1 } { 4 3 } } } [ H{ { 1 2 } { 3 4 } } assoc-invert ] unit-test
 
@@ -201,20 +201,35 @@ USING: arrays assocs.extras kernel math math.order sequences tools.test ;
     [ [ drop even? ] [ 2array ] 2bi ] collect-assoc-by
 ] unit-test
 
+
 {
-    H{ { t V{ 10 20 30 } } { f V{ 41 } } }
+    H{ { t V{ 10 21 } } { f V{ 30 41 } } }
 } [
-    { { 10 100 } { 20 200 } { 30 300 } { 41 401 } }
-    [ even? ] collect-key-by
-] unit-test
+    { { 10 100 } { 21 200 } { 30 301 } { 41 401 } }
+    [ nip even? ] collect-key-by
+ ] unit-test
 
 {
-    H{ { t V{ 100 200 300 } } { f V{ 401 } } }
+    H{ { t V{ 10 30 } } { f V{ 21 41 } } }
 } [
-    { { 10 100 } { 20 200 } { 30 300 } { 41 401 } }
-    [ even? ] collect-value-by
-] unit-test
+    { { 10 100 } { 21 200 } { 30 301 } { 41 401 } }
+    [ drop even? ] collect-key-by
+ ] unit-test
+
 
+{
+    H{ { t V{ 100 200 } } { f V{ 301 401 } } }
+} [
+    { { 10 100 } { 21 200 } { 30 301 } { 41 401 } }
+    [ nip even? ] collect-value-by
+ ] unit-test
+
+{
+    H{ { t V{ 100 301 } } { f V{ 200 401 } } }
+} [
+    { { 10 100 } { 21 200 } { 30 301 } { 41 401 } }
+    [ drop even? ] collect-value-by
+ ] unit-test
 
 {
     H{
@@ -244,7 +259,7 @@ USING: arrays assocs.extras kernel math math.order sequences tools.test ;
     }
 } [
     { { 10 100 } { 20 200 } { 30 300 } { 41 401 } }
-    [ dup 1 + 2array ] collect-key-by-multi
+    [ drop dup 1 + 2array ] collect-key-by-multi
 ] unit-test
 
 
@@ -261,7 +276,7 @@ USING: arrays assocs.extras kernel math math.order sequences tools.test ;
     }
 } [
     { { 10 100 } { 20 200 } { 30 300 } { 41 401 } }
-    [ dup 1 + 2array ] collect-value-by-multi
+    [ nip dup 1 + 2array ] collect-value-by-multi
 ] unit-test
 
 
@@ -279,4 +294,5 @@ USING: arrays assocs.extras kernel math math.order sequences tools.test ;
 } [
     { { 10 100 } { 20 200 } { 30 300 } { 41 401 } }
     [ [ dup 1 + 2array ] dip ] collect-assoc-by-multi
-] unit-test
\ No newline at end of file
+] unit-test
+