diff --git a/extra/db/db-tests.factor b/extra/db/db-tests.factor new file mode 100755 index 0000000000..9c32f9e326 --- /dev/null +++ b/extra/db/db-tests.factor @@ -0,0 +1,5 @@ +IN: db.tests +USING: tools.test db kernel ; + +{ 1 0 } [ [ drop ] query-each ] must-infer-as +{ 1 1 } [ [ ] query-map ] must-infer-as diff --git a/extra/db/postgresql/postgresql.factor b/extra/db/postgresql/postgresql.factor index 26b6cbe75c..b2042c98bd 100755 --- a/extra/db/postgresql/postgresql.factor +++ b/extra/db/postgresql/postgresql.factor @@ -119,8 +119,8 @@ M: postgresql-db bind% ( spec -- ) : postgresql-make ( class quot -- ) >r sql-props r> - [ postgresql-counter off ] swap compose - { "" { } { } } nmake ; + [ postgresql-counter off call ] { "" { } { } } nmake + ; inline : create-table-sql ( class -- statement ) [ diff --git a/extra/db/sqlite/sqlite.factor b/extra/db/sqlite/sqlite.factor index 9a9db74401..3466301390 100755 --- a/extra/db/sqlite/sqlite.factor +++ b/extra/db/sqlite/sqlite.factor @@ -98,7 +98,7 @@ M: sqlite-db rollback-transaction ( -- ) "ROLLBACK" sql-command ; : sqlite-make ( class quot -- ) >r sql-props r> - { "" { } { } } nmake ; + { "" { } { } } nmake ; inline M: sqlite-db create-sql-statement ( class -- statement ) [ diff --git a/extra/db/tuples/tuples-tests.factor b/extra/db/tuples/tuples-tests.factor index 4c47066d35..ba6441bc53 100755 --- a/extra/db/tuples/tuples-tests.factor +++ b/extra/db/tuples/tuples-tests.factor @@ -239,3 +239,9 @@ TUPLE: exam id name score ; ; ! [ test-ranges ] test-sqlite + +\ insert-tuple must-infer +\ update-tuple must-infer +\ delete-tuple must-infer +\ select-tuple must-infer +\ define-persistent must-infer diff --git a/extra/db/tuples/tuples.factor b/extra/db/tuples/tuples.factor index 82147a2efa..d50e42c0fb 100755 --- a/extra/db/tuples/tuples.factor +++ b/extra/db/tuples/tuples.factor @@ -36,7 +36,7 @@ HOOK: db ( class -- obj ) HOOK: db ( class -- obj ) HOOK: db ( class -- obj ) -HOOK: db ( tuple -- tuple ) +HOOK: db ( tuple class -- tuple ) HOOK: insert-tuple* db ( tuple statement -- ) diff --git a/extra/namespaces/lib/lib-tests.factor b/extra/namespaces/lib/lib-tests.factor new file mode 100755 index 0000000000..20769e161c --- /dev/null +++ b/extra/namespaces/lib/lib-tests.factor @@ -0,0 +1,6 @@ +IN: namespaces.lib.tests +USING: namespaces.lib tools.test ; + +[ ] [ [ ] { } nmake ] unit-test + +[ { 1 } { 2 } ] [ [ 1 0, 2 1, ] { { } { } } nmake ] unit-test diff --git a/extra/namespaces/lib/lib.factor b/extra/namespaces/lib/lib.factor old mode 100644 new mode 100755 index 76ba0ac63e..47b6b33a9a --- a/extra/namespaces/lib/lib.factor +++ b/extra/namespaces/lib/lib.factor @@ -2,7 +2,7 @@ ! USING: kernel quotations namespaces sequences assocs.lib ; USING: kernel namespaces namespaces.private quotations sequences - assocs.lib math.parser math sequences.lib ; + assocs.lib math.parser math sequences.lib locals ; IN: namespaces.lib @@ -42,11 +42,19 @@ SYMBOL: building-seq : 4% 4 n% ; : 4# 4 n# ; -: nmake ( quot exemplars -- seqs ) - dup length dup zero? [ 1+ ] when - [ +MACRO:: nmake ( quot exemplars -- ) + [let | n [ exemplars length ] | [ - [ drop 1024 swap new-resizable ] 2map - [ building-seq set call ] keep - ] 2keep >r [ like ] 2map r> firstn - ] with-scope ; + [ + exemplars + [ 0 swap new-resizable ] map + building-seq set + + quot call + + building-seq get + exemplars [ like ] 2map + n firstn + ] with-scope + ] + ] ; diff --git a/extra/sequences/lib/lib-tests.factor b/extra/sequences/lib/lib-tests.factor index b19c2f39c9..6e6a924382 100755 --- a/extra/sequences/lib/lib-tests.factor +++ b/extra/sequences/lib/lib-tests.factor @@ -79,3 +79,6 @@ IN: sequences.lib.tests [ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test [ 1 2 3 4 ] [ { 1 2 3 4 } 4 firstn ] unit-test + +[ ] [ { } 0 firstn ] unit-test +[ "a" ] [ { "a" } 1 firstn ] unit-test diff --git a/extra/sequences/lib/lib.factor b/extra/sequences/lib/lib.factor index 13e8eb949f..a6b6b73148 100755 --- a/extra/sequences/lib/lib.factor +++ b/extra/sequences/lib/lib.factor @@ -4,7 +4,7 @@ USING: combinators.lib kernel sequences math namespaces assocs random sequences.private shuffle math.functions mirrors arrays math.parser math.private sorting strings ascii macros -assocs.lib ; +assocs.lib quotations ; IN: sequences.lib : each-withn ( seq quot n -- ) nwith each ; inline @@ -20,8 +20,9 @@ IN: sequences.lib : map-with2 ( obj obj list quot -- newseq ) 2 map-withn ; inline MACRO: firstn ( n -- ) - [ [ swap nth ] curry - [ keep ] curry ] map concat [ drop ] compose ; + [ [ swap nth ] curry [ keep ] curry ] map + concat >quotation + [ drop ] compose ; : prepare-index ( seq quot -- seq n quot ) >r dup length r> ; inline @@ -193,7 +194,7 @@ USE: continuations : ?tail* ( seq n -- seq/f ) (tail) ?subseq ; : accumulator ( quot -- quot vec ) - V{ } clone [ [ push ] curry compose ] keep ; + V{ } clone [ [ push ] curry compose ] keep ; inline ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!