[pure-lang-svn] SF.net SVN: pure-lang:[582] pure/trunk/test
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-23 12:56:38
|
Revision: 582 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=582&view=rev Author: agraef Date: 2008-08-23 12:56:48 +0000 (Sat, 23 Aug 2008) Log Message: ----------- Define double format as a variable, so that it can be changed more easily. Modified Paths: -------------- pure/trunk/test/test020.log pure/trunk/test/test020.pure Modified: pure/trunk/test/test020.log =================================================================== --- pure/trunk/test/test020.log 2008-08-23 12:49:38 UTC (rev 581) +++ pure/trunk/test/test020.log 2008-08-23 12:56:48 UTC (rev 582) @@ -36,6 +36,7 @@ <var> state 1 state 1: #0 }) x; +let double_format = "%#0.3g"; test f/*0:01*/ (x/*0:101*/,y/*0:11*/) = puts$format (f/*0:01*/,x/*0:101*/,y/*0:11*/,check f/*0:01*/ (x/*0:101*/,y/*0:11*/) (catch __error__ (f/*1:01*/ x/*1:101*/ y/*1:11*/))); test f/*0:01*/ x/*0:1*/ = puts$format (f/*0:01*/,x/*0:1*/,check f/*0:01*/ x/*0:1*/ (catch __error__ (f/*1:01*/ x/*1:1*/))); check f/*0:001*/ _/*0:01*/ (g@_/*0:100*/ _/*0:101*/ _/*0:11*/) = __failed__ if f/*0:001*/===g/*0:100*/; @@ -43,7 +44,7 @@ check _/*0:001*/ _/*0:01*/ z/*0:1*/ = z/*0:1*/; format (f/*0:101*/,x/*0:1101*/,y/*0:11101*/,z/*0:1111*/) = str f/*0:101*/+","+show x/*0:1101*/+","+show y/*0:11101*/+","+show z/*0:1111*/; format (f/*0:101*/,x/*0:1101*/,z/*0:111*/) = str f/*0:101*/+","+show x/*0:1101*/+","+show z/*0:111*/; -show x/*0:1*/::double = sprintf "%#0.3g" x/*0:1*/; +show x/*0:1*/::double = sprintf double_format x/*0:1*/; show (x/*0:101*/+:y/*0:11*/) = show x/*0:101*/+"+:"+show y/*0:11*/; show (x/*0:101*/<:y/*0:11*/) = show x/*0:101*/+"<:"+show y/*0:11*/; show x/*0:1*/ = str x/*0:1*/; @@ -146,7 +147,7 @@ state 12: #0 #1 } { - rule #0: show x::double = sprintf "%#0.3g" x + rule #0: show x::double = sprintf double_format x rule #1: show (x+:y) = show x+"+:"+show y rule #2: show (x<:y) = show x+"<:"+show y rule #3: show x = str x Modified: pure/trunk/test/test020.pure =================================================================== --- pure/trunk/test/test020.pure 2008-08-23 12:49:38 UTC (rev 581) +++ pure/trunk/test/test020.pure 2008-08-23 12:56:48 UTC (rev 582) @@ -24,9 +24,11 @@ /* This will print out each operation, arguments and result as a single line. Exceptions are flagged with '__error__', evaluation failures with '__failed__'. Floating point values are rounded in the output to 3 - significant digits, to prevent 'make check' from failing due to small + significant digits by default, to prevent 'make check' from failing due to rounding discrepancies. */ +let double_format = "%#0.3g"; // modify as needed, to get more accuracy + test f (x,y) = puts $ format (f,x,y,check f (x,y) (catch __error__ (f x y))); test f x = puts $ format (f,x,check f x (catch __error__ (f x))); @@ -36,7 +38,7 @@ format (f,x,y,z) = str f+","+show x+","+show y+","+show z; format (f,x,z) = str f+","+show x+","+show z; -show x::double = sprintf "%#0.3g" x; +show x::double = sprintf double_format x; show (x+:y) = show x+"+:"+show y; show (x<:y) = show x+"<:"+show y; show x = str x otherwise; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |