--- gforth/test/gforth.fs 2009/09/25 18:52:29 1.16 +++ gforth/test/gforth.fs 2011/08/10 13:55:03 1.18 @@ -1,6 +1,6 @@ \ test some gforth extension words -\ Copyright (C) 2003,2004,2005,2006,2007 Free Software Foundation, Inc. +\ Copyright (C) 2003,2004,2005,2006,2007,2009 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -95,3 +95,16 @@ t{ -5e 1e fcopysign -> 5e }t t{ 5e -1e fcopysign -> -5e }t t{ -5e -1e fcopysign -> -5e }t \ tests involving -0e? + +\ ?of + +: sgn ( n1 -- n2 ) + case + dup 0< ?of drop -1 endof + dup 0> ?of drop 1 endof + dup + endcase ; + +t{ 5 sgn -> 1 } +t{ -3 sgn -> -1 } +t{ 0 sgn -> 0 }