diff --git a/examples/factoroids.factor b/examples/factoroids.factor index bb4384eb84..b2ca0ee43d 100644 --- a/examples/factoroids.factor +++ b/examples/factoroids.factor @@ -205,6 +205,7 @@ SYMBOL: stars ] extend ; : init-stars ( -- ) + #! Generate random background of scrolling stars. [ ] star-count [ random-star swons ] times stars set ; : draw-stars ( -- ) diff --git a/library/prettyprint.factor b/library/prettyprint.factor index f916bce409..b5aba002da 100644 --- a/library/prettyprint.factor +++ b/library/prettyprint.factor @@ -161,19 +161,21 @@ DEFER: prettyprint* ] ; : word-attrs ( word -- attrs ) - dup defined? [ - dup >r - word-link dup >r "object-link" swons r> + #! Words without a vocabulary do not get a link or an action + #! popup. + dup word-vocabulary [ + word-link [ "object-link" swons ] keep word-actions "actions" swons t "underline" swons 3list - r> ] [ - [ ] swap - ] ifte word-style append ; + drop [ ] + ] ifte ; : prettyprint-word ( word -- ) - dup word-name swap word-attrs write-attr ; + dup word-name + swap dup word-attrs swap word-style append + write-attr ; : prettyprint-object ( indent obj -- indent ) unparse write ; diff --git a/library/test/math/namespaces.factor b/library/test/math/namespaces.factor index 5bfebc4a3c..64b56ba1a2 100644 --- a/library/test/math/namespaces.factor +++ b/library/test/math/namespaces.factor @@ -11,5 +11,5 @@ USE: math [ 2 ] [ 5 "x" /@ "x" get ] unit-test [ 1 ] [ "x" pred@ "x" get ] unit-test [ 2 ] [ "x" succ@ "x" get ] unit-test -[ 7 ] [ -3 "x" set 10 "x" rem@ ] unit-test -[ -3 ] [ -3 "x" set 10 "x" rem@ ] unit-test +[ 7 ] [ -3 "x" set 10 "x" rem@ "x" get ] unit-test +[ -3 ] [ -3 "x" set 10 "x" mod@ "x" get ] unit-test diff --git a/library/test/prettyprint.factor b/library/test/prettyprint.factor index 0fa8751ba9..edd03f1a41 100644 --- a/library/test/prettyprint.factor +++ b/library/test/prettyprint.factor @@ -3,5 +3,7 @@ USE: lists USE: prettyprint USE: test USE: words +USE: stack +[ ] [ gensym dup [ ] define-compound . ] unit-test [ ] [ vocabs [ words [ see ] each ] each ] unit-test diff --git a/library/test/test.factor b/library/test/test.factor index 80790e3a7a..250afaa91b 100644 --- a/library/test/test.factor +++ b/library/test/test.factor @@ -120,6 +120,7 @@ USE: unparser cpu "x86" = [ [ "x86-compiler/simple" + "x86-compiler/stack" "x86-compiler/ifte" "x86-compiler/generic" "x86-compiler/bail-out" diff --git a/library/test/x86-compiler/stack.factor b/library/test/x86-compiler/stack.factor new file mode 100644 index 0000000000..d40625c2cf --- /dev/null +++ b/library/test/x86-compiler/stack.factor @@ -0,0 +1,19 @@ +IN: scratchpad +USE: compiler +USE: test +USE: stack +USE: words +USE: combinators +USE: lists + +! Make sure that stack ops compile to correct code. +: compile-call ( quot -- word ) + gensym [ swap define-compound ] keep dup compile execute ; + +[ ] [ 1 [ drop ] compile-call ] unit-test +[ ] [ [ 1 drop ] compile-call ] unit-test +[ ] [ [ 1 2 2drop ] compile-call ] unit-test +[ ] [ 1 [ 2 2drop ] compile-call ] unit-test +[ ] [ 1 2 [ 2drop ] compile-call ] unit-test +[ 1 1 ] [ 1 [ dup ] compile-call ] unit-test +[ 1 1 ] [ [ 1 dup ] compile-call ] unit-test