]> gitweb.factorcode.org Git - factor.git/commitdiff
more test suite work
authorSlava Pestov <slava@factorcode.org>
Sun, 3 Oct 2004 20:39:32 +0000 (20:39 +0000)
committerSlava Pestov <slava@factorcode.org>
Sun, 3 Oct 2004 20:39:32 +0000 (20:39 +0000)
library/test/init.factor [new file with mode: 0644]
library/test/interpreter.factor [new file with mode: 0644]
library/test/lists/namespaces.factor
library/test/math/math-combinators.factor [new file with mode: 0644]
library/test/test.factor

diff --git a/library/test/init.factor b/library/test/init.factor
new file mode 100644 (file)
index 0000000..564cb13
--- /dev/null
@@ -0,0 +1,14 @@
+IN: scratchpad
+USE: init
+USE: namespaces
+USE: test
+
+[
+    [ f ] [ "-no-user-init" cli-arg ] unit-test
+    [ f ] [ "user-init" get ] unit-test
+
+    [ f ] [ "-user-init" cli-arg ] unit-test
+    [ t ] [ "user-init" get ] unit-test
+    
+    [ "sdl.factor" ] [ "sdl.factor" cli-arg ] unit-test
+] with-scope
diff --git a/library/test/interpreter.factor b/library/test/interpreter.factor
new file mode 100644 (file)
index 0000000..2f5b9e7
--- /dev/null
@@ -0,0 +1,16 @@
+IN: scratchpad
+USE: interpreter
+USE: namespaces
+USE: stdio
+USE: test
+
+[
+    init-history
+    "2 2 +" history+
+    history.
+    [ "2 2 +" ] [ 0 get-history ] unit-test
+    [ 4 ] [ 0 redo ] unit-test
+    [ 4 ] [ "2 2 +" eval-catch ] unit-test
+    "The following will print an error; ignore it." print terpri
+    [ ] [ "clear drop" eval-catch ] unit-test
+] with-scope
index 838d23c28ba6bde3d4c5f28dfb10bb3142c3082c..40bbba01ea250761a4a46f2a46fd03dd9d060d72 100644 (file)
@@ -4,7 +4,9 @@ USE: namespaces
 USE: test
 
 [ [ 1 2 3 4 ] ] [ [ 3 4 ] [ 1 2 ] ] [ "x" set "x" append@ "x" get ] test-word
+
 [ [ 1 2 3 4 ] ] [ 4 [ 1 2 3 ] ] [ "x" set "x" add@ "x" get ] test-word
+
 [ [ 1 ] ] [ 1 f ] [ "x" set "x" cons@ "x" get ] test-word
 [ [ 1 | 2 ] ] [ 1 2 ] [ "x" set "x" cons@ "x" get ] test-word
 [ [ 1 2 ] ] [ 1 [ 2 ] ] [ "x" set "x" cons@ "x" get ] test-word
@@ -15,3 +17,30 @@ USE: test
 
 [ [ 2 | 3 ] ] [ "x" uncons@ ] unit-test
 [ [ 1 | 2 ] ] [ "x" uncons@ ] unit-test
+
+[ [ 5 4 3 1 ] ] [
+    [ 5 4 3 2 1 ] "x" set
+    2 "x" remove@
+    "x" get
+] unit-test
+
+[ [ "hello" f ] ] [
+    "x" off
+    f "x" unique@
+    "hello" "x" unique@
+    f "x" unique@
+    5 "x" unique@
+    f "x" unique@
+    5 "x" remove@
+    "hello" "x" unique@
+    "x" get
+] unit-test
+
+[ [ "xyz" #{ 3 2 } 1/5 [ { } ] ] ] [
+    [, "xyz" , "xyz" unique,
+    #{ 3 2 } , #{ 3 2 } unique,
+    1/5 , 1/5 unique,
+    [, { } unique, ,] , ,]
+] unit-test
+
+[ [ 1 2 3 4 ] ] [ [, 1 , [ 2 3 ] list, 4 , ,] ] unit-test
diff --git a/library/test/math/math-combinators.factor b/library/test/math/math-combinators.factor
new file mode 100644 (file)
index 0000000..208cf85
--- /dev/null
@@ -0,0 +1,22 @@
+IN: scratchpad
+USE: combinators
+USE: kernel
+USE: math
+USE: stack
+USE: test
+
+[ 0 1 2 3 4 ] [ 5 [ ] times* ] unit-test
+[ ] [ 0 [ ] times* ] unit-test
+
+[ #{ 1 1 } ] [ #{ 2 3 } #{ 1 0 } 2times-succ ] unit-test
+[ #{ 1 2 } ] [ #{ 2 3 } #{ 1 1 } 2times-succ ] unit-test
+[ #{ 2 0 } ] [ #{ 3 3 } #{ 1 2 } 2times-succ ] unit-test
+[ #{ 2 1 } ] [ #{ 3 3 } #{ 2 0 } 2times-succ ] unit-test
+[ #{ 2 0 } ] [ #{ 2 2 } #{ 1 1 } 2times-succ ] unit-test
+
+[ #{ 0 0 } #{ 0 1 } #{ 1 0 } #{ 1 1 } ]
+[ #{ 2 2 } [ ] 2times* ] unit-test
+
+[ #{ 0 0 } #{ 0 1 } #{ 0 2 } #{ 1 0 } #{ 1 1 } #{ 1 2 } 
+  #{ 2 0 } #{ 2 1 } #{ 2 2 } ]
+[ #{ 3 3 } [ ] 2times* ] unit-test
index c2908d4a17b14aa53b82ac12f3777f7bb5ca9a7f..20ba8a397a98d25221904ef5928c878939497250 100644 (file)
@@ -80,12 +80,15 @@ USE: unparser
         "parse-number"
         "prettyprint"
         "image"
+        "init"
         "inspector"
+        "interpreter"
         "io/io"
         "vectors"
         "words"
         "unparser"
         "random"
+        "stream"
         "math/bignum"
         "math/bitops"
         "math/gcd"