]> gitweb.factorcode.org Git - factor.git/commitdiff
vocabs: adding 'parent-vocab?' and 'parent-vocabs'.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 26 Sep 2011 01:32:03 +0000 (18:32 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 26 Sep 2011 01:32:03 +0000 (18:32 -0700)
core/vocabs/vocabs-tests.factor
core/vocabs/vocabs.factor

index 21c36681484f8d96c1fc3c5d524fbfb03b3de41a..ec486e3a5ae02cb68a0c1eafda1d0c41c8391c3c 100644 (file)
@@ -3,3 +3,11 @@ USING: vocabs tools.test ;
 IN: vocabs.tests
 
 [ f ] [ "kernel" vocab-main ] unit-test
+
+[ t ] [ "" "" child-vocab? ] unit-test
+[ t ] [ "" "io.files" child-vocab? ] unit-test
+[ t ] [ "io" "io.files" child-vocab? ] unit-test
+[ f ] [ "io.files" "io" child-vocab? ] unit-test
+
+[ t ] [ "io.files" "io" parent-vocab? ] unit-test
+[ f ] [ "io" "io.files" parent-vocab? ] unit-test
index 38881673e9877986398c0ca50684a627bca83a78..f023472c6898e71177e76613f54f273ff88ef524 100644 (file)
@@ -111,6 +111,12 @@ ERROR: no-vocab name ;
 : child-vocabs ( vocab -- seq )
     vocab-name vocabs [ child-vocab? ] with filter ;
 
+: parent-vocab? ( suffix name -- ? )
+    swap child-vocab? ;
+
+: parent-vocabs ( vocab -- seq )
+    vocab-name vocabs [ parent-vocab? ] with filter ;
+
 GENERIC: >vocab-link ( name -- vocab )
 
 M: vocab-spec >vocab-link ;