]> gitweb.factorcode.org Git - factor.git/commitdiff
unit test fix
authorSlava Pestov <slava@factorcode.org>
Fri, 18 Feb 2005 00:01:11 +0000 (00:01 +0000)
committerSlava Pestov <slava@factorcode.org>
Fri, 18 Feb 2005 00:01:11 +0000 (00:01 +0000)
TODO.FACTOR.txt
library/compiler/linearizer.factor
library/generic/tuple.factor
library/inference/branches.factor
library/io/stream-impl.factor
library/lists.factor
library/test/compiler/simple.factor
library/test/inference.factor

index f3072197a9f7e146e0181f26c7f7880b06517641..feeb8bb1d182eb570d319f5ae3a155834fc3ba1f 100644 (file)
@@ -17,7 +17,6 @@
 - code gc\r
 - ppc register decls\r
 \r
-- unit test failure\r
 - #jump-f #jump-f-label\r
 - extract word inside M:, C:, and structure browsing for these\r
 - fix checkbox alignment\r
@@ -35,6 +34,7 @@
 - UI: don't roll over if mouse button is down\r
 - more accurate types for various words\r
 - optimize out >array, >tuple, >hashtable etc\r
+- write read: write should flush\r
 \r
 + compiler/ffi:\r
 \r
index 4ab12d6d8baa67bbe4bfecc75fd41362de4c6873..b1bf1574cc9eb7242994a5f22295a1a0bf9d5439 100644 (file)
@@ -154,19 +154,12 @@ SYMBOL: #end-dispatch
 
 : dispatch-body ( end label/param -- )
     #! Output each branch, with a jump to the end label.
-    [
-        uncons label, (linearize) #jump-label swons ,
-    ] each-with ;
-
-: check-dispatch ( vtable -- )
-    length num-types = [
-        "Dispatch must have " num-types " entries" cat3 throw
-    ] unless ;
+    [ uncons label, (linearize) #jump-label swons , ] each-with ;
 
 : linearize-dispatch ( vtable -- )
     #! The parameter is a list of lists, each one is a branch to
     #! take in case the top of stack has that type.
-    dup check-dispatch dispatch-head dupd dispatch-body label, ;
+    dispatch-head dupd dispatch-body label, ;
 
 \ dispatch [
     [ node-param get ] bind linearize-dispatch
index 2df79f17bc4681f5e8af06b5c32994d287a7c9cc..f3ecadd8d364da0edf9e7e22b02c5c6983af258c 100644 (file)
@@ -49,11 +49,12 @@ kernel-internals math hashtables errors vectors ;
     >r over mutator-word tuck r> [ set-slot ] cons
     define-tuple-generic ;
 
-: define-slot ( word name n -- [[ accessor mutator ]] )
+: define-slot ( word name n -- [ n accessor mutator ] )
     over "delegate" = [
         pick over "delegate-field" set-word-property
     ] when
-    3dup define-mutator >r define-accessor r> cons ;
+    [ 3dup define-mutator >r define-accessor r> ] keep -rot
+    3list ;
 
 : tuple-predicate ( word -- )
     #! Make a foo? word for testing the tuple class at the top
@@ -91,7 +92,7 @@ kernel-internals math hashtables errors vectors ;
 : default-constructor ( tuple -- )
     dup [
         "slot-words" word-property
-        reverse [ cdr unit , \ keep , ] each
+        reverse [ last unit , \ keep , ] each
     ] make-list define-constructor ;
 
 : define-tuple ( tuple slots -- )
index 00d53ac459bc62c3e2e5e24a1946dc98201957d9..e2bbf879912478a038b3139ad2374ee052249d39 100644 (file)
@@ -215,8 +215,7 @@ USE: kernel-internals
     [ object vector ] ensure-d
     dataflow-drop, pop-d vtable>list
     >r 1 meta-d get vector-tail* \ dispatch r>
-    pop-d ( n ) num-types [ dupd cons ] project nip zip
-    infer-branches ;
+    pop-d drop [ unit ] map infer-branches ;
 
 \ dispatch [ infer-dispatch ] "infer" set-word-property
 \ dispatch [ [ fixnum vector ] [ ] ]
index 26984a81fa90d43928cb979e88808f4067853bd5..35f09c2750235543b8bbc26578831854c3af07c8 100644 (file)
@@ -53,7 +53,11 @@ M: fd-stream stream-close ( stream -- )
 : fcopy ( from to -- )
     #! Copy the contents of the fd-stream 'from' to the
     #! fd-stream 'to'.
-    [ 2dup (fcopy) ] [ -rot stream-close stream-close rethrow ] catch ;
+    [
+        2dup (fcopy)
+    ] [
+        -rot stream-close stream-close rethrow
+    ] catch ;
 
 : resource-path ( -- path )
     "resource-path" get [ "." ] unless* ;
index e3b313d6c20dbb35a3180503407549afc8cd0866..3a1ba30677db9271d4ae6b9fb1ce721c4cdfec5b 100644 (file)
@@ -154,6 +154,9 @@ M: cons hashcode ( cons -- hash ) car hashcode ;
 : project ( n quot -- list )
     >r count r> map ; inline
 
+: project-with ( elt n quot -- list )
+    swap [ with rot ] project 2nip ; inline
+
 : head ( list n -- list )
     #! Return the first n elements of the list.
     dup 0 > [ >r uncons r> 1 - head cons ] [ 2drop f ] ifte ;
index e24b3f09d4ddb49533a9e854c18c9beb2a6f5c37..764061a04e55f7020751c9cbf002dd06b19f5291 100644 (file)
@@ -6,6 +6,7 @@ USE: kernel
 USE: words
 USE: kernel
 USE: math-internals
+USE: memory
 
 : no-op ; compiled
 
index bb53417af0fcb0db200eeda41c2e5f1ff13a9ca9..24c4741313bf2d22dc4943952c7d3c3b70768f93 100644 (file)
@@ -213,14 +213,14 @@ SYMBOL: sym-test
 
 ! Type inference
 
-[ [ [ object ] [ ] ] ] [ [ drop ] infer ] unit-test
-[ [ [ object ] [ object object ] ] ] [ [ dup ] infer ] unit-test
-[ [ [ object object ] [ cons ] ] ] [ [ cons ] infer ] unit-test
-[ [ [ cons ] [ cons ] ] ] [ [ uncons cons ] infer ] unit-test
-[ [ [ general-list ] [ object ] ] ] [ [ dup [ car ] when ] infer ] unit-test
+[ [ [ object ] [ ] ] ] [ [ drop ] infer ] unit-test
+[ [ [ object ] [ object object ] ] ] [ [ dup ] infer ] unit-test
+[ [ [ object object ] [ cons ] ] ] [ [ cons ] infer ] unit-test
+[ [ [ cons ] [ cons ] ] ] [ [ uncons cons ] infer ] unit-test
+[ [ [ general-list ] [ object ] ] ] [ [ dup [ car ] when ] infer ] unit-test
 ! [ [ [ number ] [ number ] ] ] [ [ dup + ] infer ] unit-test
 ! [ [ [ number number number ] [ number ] ] ] [ [ digit+ ] infer ] unit-test
-[ [ [ number ] [ real real ] ] ] [ [ >rect ] infer ] unit-test
+[ [ [ number ] [ real real ] ] ] [ [ >rect ] infer ] unit-test
 
 ! [ [ [ ] [ POSTPONE: t ] ] ] [ [ f not ] infer ] unit-test
 ! [ [ [ ] [ POSTPONE: f ] ] ] [ [ t not ] infer ] unit-test