From c03c22d3d92ddfa7c663aaecc0b30cd80cb21d53 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 17 Aug 2004 01:11:27 +0000 Subject: [PATCH] 0.62 ready for release --- TODO.FACTOR.txt | 2 - factor/jedit/FactorPlugin.props | 2 +- library/test/errors.factor | 16 ++++++ library/test/stack.factor | 40 ++++++++++++++ library/test/strings.factor | 97 +++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 library/test/errors.factor create mode 100644 library/test/stack.factor create mode 100644 library/test/strings.factor diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 9183dad358..14f277f42e 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -9,8 +9,6 @@ - sbuf-hashcode - vector-hashcode - listener backspace overzealous -- SIGBUS handler -- handle division by zero - log-client: fix for native - multitasking diff --git a/factor/jedit/FactorPlugin.props b/factor/jedit/FactorPlugin.props index 2146bfc80f..47bade2f6d 100644 --- a/factor/jedit/FactorPlugin.props +++ b/factor/jedit/FactorPlugin.props @@ -3,7 +3,7 @@ plugin.factor.jedit.FactorPlugin.activate=defer plugin.factor.jedit.FactorPlugin.name=Factor -plugin.factor.jedit.FactorPlugin.version=0.61 +plugin.factor.jedit.FactorPlugin.version=0.62 plugin.factor.jedit.FactorPlugin.author=Slava Pestov plugin.factor.jedit.FactorPlugin.docs=/doc/plugin.html diff --git a/library/test/errors.factor b/library/test/errors.factor new file mode 100644 index 0000000000..3f999d88c1 --- /dev/null +++ b/library/test/errors.factor @@ -0,0 +1,16 @@ +IN: scratchpad +USE: errors +USE: kernel +USE: namespaces +USE: stack +USE: test + +[ f ] [ [ ] [ ] catch ] unit-test + +[ 5 ] [ [ 5 throw ] [ ] catch ] unit-test + +[ t ] [ + [ "Hello" throw ] [ drop ] catch + global [ "error" get ] bind + "Hello" = +] unit-test diff --git a/library/test/stack.factor b/library/test/stack.factor new file mode 100644 index 0000000000..4a8da80a63 --- /dev/null +++ b/library/test/stack.factor @@ -0,0 +1,40 @@ +IN: scratchpad +USE: compiler +USE: stack +USE: stdio +USE: test + +! Test the built-in stack words. + +"Checking stack words." print + +! OUTPUT INPUT WORD +[ ] [ 1 ] [ drop ] test-word +[ ] [ 1 2 ] [ 2drop ] test-word +[ 1 1 ] [ 1 ] [ dup ] test-word +[ 1 2 1 2 ] [ 1 2 ] [ 2dup ] test-word +[ 1 1 2 ] [ 1 2 ] [ dupd ] test-word +[ 1 2 1 2 3 4 ] [ 1 2 3 4 ] [ 2dupd ] test-word +[ 2 ] [ 1 2 ] [ nip ] test-word +[ 3 4 ] [ 1 2 3 4 ] [ 2nip ] test-word +[ ] [ ] [ nop ] test-word +[ 1 2 1 ] [ 1 2 ] [ over ] test-word +[ 1 2 3 4 1 2 ] [ 1 2 3 4 ] [ 2over ] test-word +[ 1 2 3 1 ] [ 1 2 3 ] [ pick ] test-word +[ 2 3 1 ] [ 1 2 3 ] [ rot ] test-word +[ 3 4 5 6 1 2 ] [ 1 2 3 4 5 6 ] [ 2rot ] test-word +[ 3 1 2 ] [ 1 2 3 ] [ -rot ] test-word +[ 5 6 1 2 3 4 ] [ 1 2 3 4 5 6 ] [ 2-rot ] test-word +[ 2 1 ] [ 1 2 ] [ swap ] test-word +[ 3 4 1 2 ] [ 1 2 3 4 ] [ 2swap ] test-word +[ 2 1 3 ] [ 1 2 3 ] [ swapd ] test-word +[ 3 4 1 2 5 6 ] [ 1 2 3 4 5 6 ] [ 2swapd ] test-word +[ 3 2 1 ] [ 1 2 3 ] [ transp ] test-word +[ 5 6 3 4 1 2 ] [ 1 2 3 4 5 6 ] [ 2transp ] test-word +[ 2 1 2 ] [ 1 2 ] [ tuck ] test-word +[ 3 4 1 2 3 4 ] [ 1 2 3 4 ] [ 2tuck ] test-word + +[ ] [ 1 ] [ >r r> drop ] test-word +[ 1 2 ] [ 1 2 ] [ >r >r r> r> ] test-word + +"Stack checks passed." print diff --git a/library/test/strings.factor b/library/test/strings.factor new file mode 100644 index 0000000000..75a312c470 --- /dev/null +++ b/library/test/strings.factor @@ -0,0 +1,97 @@ +IN: scratchpad +USE: arithmetic +USE: combinators +USE: kernel +USE: namespaces +USE: strings +USE: test + +[ f ] [ "A string." f-or-"" ] unit-test +[ t ] [ "" f-or-"" ] unit-test +[ t ] [ f f-or-"" ] unit-test + +[ "abc" ] [ [ "a" "b" "c" ] cat ] unit-test + +[ "abc" ] [ "ab" "c" cat2 ] unit-test +[ "abc" ] [ "a" "b" "c" cat3 ] unit-test +[ "abcd" ] [ "a" "b" "c" "d" cat4 ] unit-test +[ "abcde" ] [ "a" "b" "c" "d" "e" cat5 ] unit-test + +[ 3 ] [ "hola" "a" index-of ] unit-test +[ -1 ] [ "hola" "x" index-of ] unit-test +[ 0 ] [ "a" "" index-of ] unit-test +[ 0 ] [ "" "" index-of ] unit-test +[ 0 ] [ "hola" "hola" index-of ] unit-test +[ 1 ] [ "hola" "ol" index-of ] unit-test +[ -1 ] [ "hola" "amigo" index-of ] unit-test +[ -1 ] [ "hola" "holaa" index-of ] unit-test + +[ "Beginning" ] [ "Beginning and end" 9 str-head ] unit-test + +[ f ] [ "I" "team" str-contains? ] unit-test +[ t ] [ "ea" "team" str-contains? ] unit-test +[ f ] [ "actore" "Factor" str-contains? ] unit-test + +[ "end" ] [ "Beginning and end" 14 str-tail ] unit-test + +[ "Beginning" " and end" ] [ "Beginning and end" 9 str/ ] unit-test + +[ "Beginning" "and end" ] [ "Beginning and end" 9 str// ] unit-test + +[ "hello" "world" ] [ "hello world" " " split1 ] unit-test +[ "goodbye" f ] [ "goodbye" " " split1 ] unit-test +[ "" "" ] [ "great" "great" split1 ] unit-test + +[ "and end" ] [ "Beginning and end" "Beginning " str-head? ] unit-test +[ f ] [ "Beginning and end" "Beginning x" str-head? ] unit-test +[ f ] [ "Beginning and end" "eginning " str-head? ] unit-test + +[ "Beginning" ] [ "Beginning and end" " and end" str-tail? ] unit-test +[ f ] [ "Beginning and end" "Beginning x" str-tail? ] unit-test +[ f ] [ "Beginning and end" "eginning " str-tail? ] unit-test + +[ [ "This" "is" "a" "split" "sentence" ] ] +[ "This is a split sentence" " " split ] +unit-test + +[ [ "OneWord" ] ] +[ "OneWord" " " split ] +unit-test + +[ [ "a" "b" "c" "d" "e" "f" ] ] +[ "aXXbXXcXXdXXeXXf" "XX" split ] unit-test + +[ 6 ] +[ + [ "One" "Two" "Little" "Piggy" "Went" "To" "The" "Market" ] + max-str-length +] unit-test + +[ "Hello world" ] [ "Hello world\n" ends-with-newline? ] unit-test +[ f ] [ "Hello world" ends-with-newline? ] unit-test +[ "" ] [ "\n" ends-with-newline? ] unit-test +[ f ] [ "" ends-with-newline? ] unit-test + +[ t ] [ CHAR: a letter? ] unit-test +[ f ] [ CHAR: A letter? ] unit-test +[ f ] [ CHAR: a LETTER? ] unit-test +[ t ] [ CHAR: A LETTER? ] unit-test +[ t ] [ CHAR: 0 digit? ] unit-test +[ f ] [ CHAR: x digit? ] unit-test + +[ t ] [ "abc" "abd" str-compare 0 < ] unit-test +[ t ] [ "z" "abd" str-compare 0 > ] unit-test + +native? [ + [ t ] [ "Foo" str>sbuf "Foo" str>sbuf = ] unit-test + [ f ] [ "Foo" str>sbuf "Foob" str>sbuf = ] unit-test + [ f ] [ 34 "Foo" str>sbuf = ] unit-test + + [ "Hello" ] [ + 100 "buf" set + "Hello" "buf" get sbuf-append + "buf" get clone "buf-clone" set + "World" "buf-clone" get sbuf-append + "buf" get sbuf>str + ] unit-test +] when