diff --git a/library/compiler/stack.factor b/library/compiler/stack.factor new file mode 100644 index 0000000000..ebdb3fb0b6 --- /dev/null +++ b/library/compiler/stack.factor @@ -0,0 +1,43 @@ +! :folding=indent:collapseFolds=1: + +! $Id$ +! +! Copyright (C) 2004 Slava Pestov. +! +! Redistribution and use in source and binary forms, with or without +! modification, are permitted provided that the following conditions are met: +! +! 1. Redistributions of source code must retain the above copyright notice, +! this list of conditions and the following disclaimer. +! +! 2. Redistributions in binary form must reproduce the above copyright notice, +! this list of conditions and the following disclaimer in the documentation +! and/or other materials provided with the distribution. +! +! THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +! INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +! DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +! PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +! OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +! WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +! OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +! ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +IN: compiler +USE: stack +USE: words + +: compile-drop ( -- ) + commit-literals + 4 ESI R-I ; + +: compile-dup ( -- ) + commit-literals + ESI EAX [R]>R + 4 ESI R+I + EAX ESI R>[R] ; + +\ drop [ compile-drop ] "compiling" set-word-property +\ dup [ compile-dup ] "compiling" set-word-property diff --git a/library/test/hsv.factor b/library/test/hsv.factor new file mode 100644 index 0000000000..9f404815b2 --- /dev/null +++ b/library/test/hsv.factor @@ -0,0 +1,26 @@ +IN: scratchpad +USE: sdl +USE: test + +[ 1/2 1/2 1/2 ] [ 0 0 1/2 hsv>rgb ] unit-test + +[ 1/2 1/4 1/4 ] [ 0 1/2 1/2 hsv>rgb ] unit-test +[ 1/3 2/9 2/9 ] [ 0 1/3 1/3 hsv>rgb ] unit-test + +[ 24/125 1/5 4/25 ] [ 1/5 1/5 1/5 hsv>rgb ] unit-test +[ 29/180 1/6 5/36 ] [ 1/5 1/6 1/6 hsv>rgb ] unit-test + +[ 6/25 2/5 38/125 ] [ 2/5 2/5 2/5 hsv>rgb ] unit-test +[ 8/25 4/5 64/125 ] [ 2/5 3/5 4/5 hsv>rgb ] unit-test + +[ 6/25 48/125 3/5 ] [ 3/5 3/5 3/5 hsv>rgb ] unit-test +[ 0 0 0 ] [ 3/5 1/5 0 hsv>rgb ] unit-test + +[ 84/125 4/25 4/5 ] [ 4/5 4/5 4/5 hsv>rgb ] unit-test +[ 7/15 1/3 1/2 ] [ 4/5 1/3 1/2 hsv>rgb ] unit-test + +[ 5/6 5/36 5/6 ] [ 5/6 5/6 5/6 hsv>rgb ] unit-test +[ 1/6 0 1/6 ] [ 5/6 1 1/6 hsv>rgb ] unit-test + +[ 1 0 0 ] [ 1 1 1 hsv>rgb ] unit-test +[ 1/6 1/9 1/9 ] [ 1 1/3 1/6 hsv>rgb ] unit-test diff --git a/library/test/interpreter.factor b/library/test/interpreter.factor new file mode 100644 index 0000000000..9de46bbc6b --- /dev/null +++ b/library/test/interpreter.factor @@ -0,0 +1,49 @@ +IN: scratchpad +USE: interpreter +USE: test +USE: namespaces +USE: combinators +USE: stack +USE: math +USE: lists +USE: kernel + +[ { 1 2 3 } ] [ + init-interpreter [ 1 2 3 ] run meta-d get +] unit-test + +[ { "Yo" 2 } ] [ + init-interpreter [ 2 >r "Yo" r> ] run meta-d get +] unit-test + +[ { 2 } ] [ + init-interpreter [ t [ 2 ] [ "hi" ] ifte ] run meta-d get +] unit-test + +[ { "hi" } ] [ + init-interpreter [ f [ 2 ] [ "hi" ] ifte ] run meta-d get +] unit-test + +[ { 4 } ] [ + init-interpreter [ 2 2 fixnum+ ] run meta-d get +] unit-test + +[ { "Hey" "there" } ] [ + init-interpreter [ [ "Hey" | "there" ] uncons ] run meta-d get +] unit-test + +[ { t } ] [ + init-interpreter [ "XYZ" "XYZ" = ] run meta-d get +] unit-test + +[ { f } ] [ + init-interpreter [ "XYZ" "XuZ" = ] run meta-d get +] unit-test + +[ { #{ 1 1.5 } { } #{ 1 1.5 } { } } ] [ + init-interpreter [ #{ 1 1.5 } { } 2dup ] run meta-d get +] unit-test + +[ { 4 } ] [ + init-interpreter [ 2 2 + ] run meta-d get +] unit-test diff --git a/library/test/test.factor b/library/test/test.factor index 250afaa91b..e6225442ab 100644 --- a/library/test/test.factor +++ b/library/test/test.factor @@ -119,6 +119,7 @@ USE: unparser cpu "x86" = [ [ + "hsv" test "x86-compiler/simple" "x86-compiler/stack" "x86-compiler/ifte"