From 4daa1943d89d649ffbcbb7ee8d6d98cc411dadda Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 11 Feb 2008 14:19:47 -0600 Subject: [PATCH] Fixing unit tests --- core/optimizer/def-use/def-use-tests.factor | 2 +- core/optimizer/optimizer-tests.factor | 4 ++-- core/parser/parser.factor | 1 + core/prettyprint/backend/backend.factor | 1 + core/quotations/quotations-tests.factor | 2 +- core/vocabs/vocabs.factor | 7 +++---- extra/combinators/lib/lib-tests.factor | 11 ----------- extra/sequences/lib/lib-tests.factor | 15 ++++++++++++++- extra/tools/browser/browser-tests.factor | 2 -- 9 files changed, 23 insertions(+), 22 deletions(-) mode change 100644 => 100755 core/optimizer/def-use/def-use-tests.factor mode change 100644 => 100755 core/quotations/quotations-tests.factor mode change 100644 => 100755 extra/sequences/lib/lib-tests.factor mode change 100644 => 100755 extra/tools/browser/browser-tests.factor diff --git a/core/optimizer/def-use/def-use-tests.factor b/core/optimizer/def-use/def-use-tests.factor old mode 100644 new mode 100755 index afe0857463..815c564109 --- a/core/optimizer/def-use/def-use-tests.factor +++ b/core/optimizer/def-use/def-use-tests.factor @@ -8,7 +8,7 @@ namespaces assocs kernel sequences math tools.test words ; ] unit-test : kill-set ( quot -- seq ) - dataflow compute-def-use dead-literals keys + dataflow compute-def-use compute-dead-literals keys [ value-literal ] map ; : subset? [ member? ] curry all? ; diff --git a/core/optimizer/optimizer-tests.factor b/core/optimizer/optimizer-tests.factor index 232eb5a83a..8f30abd09f 100755 --- a/core/optimizer/optimizer-tests.factor +++ b/core/optimizer/optimizer-tests.factor @@ -288,10 +288,10 @@ TUPLE: silly-tuple a b ; [ t ] [ \ node-successor-f-bug compiled? ] unit-test -: construct-empty-bug construct-empty ; - [ ] [ [ construct-empty ] dataflow optimize drop ] unit-test +[ ] [ [ ] dataflow optimize drop ] unit-test + ! Make sure we have sane heuristics : should-inline? method method-word flat-length 10 <= ; diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 7dee5e2212..1bd7979a0c 100755 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -107,6 +107,7 @@ M: bad-escape summary drop "Bad escape code" ; : escape ( escape -- ch ) H{ + { CHAR: a CHAR: \a } { CHAR: e CHAR: \e } { CHAR: n CHAR: \n } { CHAR: r CHAR: \r } diff --git a/core/prettyprint/backend/backend.factor b/core/prettyprint/backend/backend.factor index 3c8df2c19a..d1364a5986 100755 --- a/core/prettyprint/backend/backend.factor +++ b/core/prettyprint/backend/backend.factor @@ -58,6 +58,7 @@ M: f pprint* drop \ f pprint-word ; ! Strings : ch>ascii-escape ( ch -- str ) H{ + { CHAR: \a CHAR: a } { CHAR: \e CHAR: e } { CHAR: \n CHAR: n } { CHAR: \r CHAR: r } diff --git a/core/quotations/quotations-tests.factor b/core/quotations/quotations-tests.factor old mode 100644 new mode 100755 index d357fb70ff..90ba150a41 --- a/core/quotations/quotations-tests.factor +++ b/core/quotations/quotations-tests.factor @@ -15,4 +15,4 @@ IN: temporary [ [ "hi" ] ] [ "hi" 1quotation ] unit-test -[ 1 \ + curry ] must-fail +! [ 1 \ + curry ] must-fail diff --git a/core/vocabs/vocabs.factor b/core/vocabs/vocabs.factor index 0717a6729c..1158d60951 100755 --- a/core/vocabs/vocabs.factor +++ b/core/vocabs/vocabs.factor @@ -85,7 +85,8 @@ SYMBOL: load-vocab-hook TUPLE: vocab-link name root ; -C: vocab-link +: ( name root -- vocab-link ) + [ dup vocab-root ] unless* vocab-link construct-boa ; M: vocab-link equal? over vocab-link? @@ -103,9 +104,7 @@ M: vocab >vocab-link drop ; M: vocab-link >vocab-link drop ; M: string >vocab-link - over vocab dup [ 2nip ] [ - drop [ dup vocab-root ] unless* - ] if ; + over vocab dup [ 2nip ] [ drop ] if ; UNION: vocab-spec vocab vocab-link ; diff --git a/extra/combinators/lib/lib-tests.factor b/extra/combinators/lib/lib-tests.factor index 24d70a86c6..5012d9280b 100755 --- a/extra/combinators/lib/lib-tests.factor +++ b/extra/combinators/lib/lib-tests.factor @@ -4,11 +4,7 @@ IN: temporary [ 5 ] [ [ 10 random ] [ 5 = ] generate ] unit-test [ t ] [ [ 10 random ] [ even? ] generate even? ] unit-test -[ 50 ] [ 100 [1,b] [ even? ] count ] unit-test -[ 50 ] [ 100 [1,b] [ odd? ] count ] unit-test -[ 328350 ] [ 100 [ sq ] sigma ] unit-test -[ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test { 6 2 } [ 1 2 [ 5 + ] dip ] unit-test { 6 2 1 } [ 1 2 1 [ 5 + ] dipd ] unit-test @@ -17,11 +13,6 @@ IN: temporary [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] must-infer { 2 1 2 3 4 5 } [ 1 2 3 4 5 [ drop drop drop drop drop 2 ] 5 nkeep ] unit-test [ [ 1 2 3 + ] ] [ 1 2 3 [ + ] 3 ncurry ] unit-test -[ 1 2 { 3 4 } [ + + ] 2 map-withn ] must-infer -{ { 6 7 } } [ 1 2 { 3 4 } [ + + ] 2 map-withn ] unit-test -{ { 16 17 18 19 20 } } [ 1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn ] unit-test -[ 1 2 { 3 4 } [ + + drop ] 2 each-withn ] must-infer -{ 13 } [ 1 2 { 3 4 } [ + + ] 2 each-withn + ] unit-test [ 1 1 2 2 3 3 ] [ 1 2 3 [ dup ] 3apply ] unit-test [ 1 4 9 ] [ 1 2 3 [ sq ] 3apply ] unit-test [ [ sq ] 3apply ] must-infer @@ -55,5 +46,3 @@ IN: temporary [ dup array? ] [ dup vector? ] [ dup float? ] } || nip ] unit-test - -[ 1 2 3 4 ] [ { 1 2 3 4 } 4 nfirst ] unit-test diff --git a/extra/sequences/lib/lib-tests.factor b/extra/sequences/lib/lib-tests.factor old mode 100644 new mode 100755 index d0bc0a9e52..13e2919fd2 --- a/extra/sequences/lib/lib-tests.factor +++ b/extra/sequences/lib/lib-tests.factor @@ -1,5 +1,5 @@ USING: arrays kernel sequences sequences.lib math -math.functions tools.test strings ; +math.functions tools.test strings math.ranges ; [ 4 ] [ { 1 2 } [ sq ] [ * ] map-reduce ] unit-test [ 36 ] [ { 2 3 } [ sq ] [ * ] map-reduce ] unit-test @@ -53,3 +53,16 @@ math.functions tools.test strings ; [ 2 ] [ { 1 2 3 } ?second ] unit-test [ 3 ] [ { 1 2 3 } ?third ] unit-test [ f ] [ { 1 2 3 } ?fourth ] unit-test + +[ 50 ] [ 100 [1,b] [ even? ] count ] unit-test +[ 50 ] [ 100 [1,b] [ odd? ] count ] unit-test +[ 328350 ] [ 100 [ sq ] sigma ] unit-test + +[ 1 2 { 3 4 } [ + + ] 2 map-withn ] must-infer +{ { 6 7 } } [ 1 2 { 3 4 } [ + + ] 2 map-withn ] unit-test +{ { 16 17 18 19 20 } } [ 1 2 3 4 { 6 7 8 9 10 } [ + + + + ] 4 map-withn ] unit-test +[ 1 2 { 3 4 } [ + + drop ] 2 each-withn ] must-infer +{ 13 } [ 1 2 { 3 4 } [ + + ] 2 each-withn + ] unit-test +[ { 910 911 912 } ] [ 10 900 3 [ + + ] map-with2 ] unit-test + +[ 1 2 3 4 ] [ { 1 2 3 4 } 4 nfirst ] unit-test diff --git a/extra/tools/browser/browser-tests.factor b/extra/tools/browser/browser-tests.factor old mode 100644 new mode 100755 index 4b3f1d5a6d..fc7960e475 --- a/extra/tools/browser/browser-tests.factor +++ b/extra/tools/browser/browser-tests.factor @@ -1,6 +1,4 @@ IN: temporary USING: tools.browser tools.test help.markup ; -[ t ] [ "resource:core" "kernel" vocab-dir? ] unit-test - [ ] [ { $describe-vocab "scratchpad" } print-content ] unit-test