Yesterday I changed the method by which my system populates the
environment query. I was wanting to test the system and came to the
conclusion that the standard actually places a number of restrictions on
the content of these queries. Consequently, I have developed the
following set of tests, that not only test the ENVIRONMENT? word but also
the values returned by the core environment quires.
I present them here for comment and criticism.
TESTING ENVIRONMENT?
DECIMAL
: tnv PARSE-NAME ENVIRONMENT? 0= ?DUP DROP ;
T{ tnv Unknown -> <TRUE> }T \ tnv inverts the flag
\ 3.1.2: Character types
\ Characters shall have the following properties:
\ at least one address unit wide;
\ contain at least eight bits;
\ have a size less than or equal to cell size;
T{ tnv ADDRESS-UNIT-BITS tnv MAX-CHAR BITS > -> <FALSE> }T
T{ 8 tnv MAX-CHAR BITS > -> <FALSE> }T
T{ tnv MAX-CHAR 1S U> -> <FALSE> }T
\ 3.1.3: Single-cell types
\ Cells shall be at least one address unit wide and contain at least
\ sixteen bits.
T{ tnv ADDRESS-UNIT-BITS 1S BITS U> -> <FALSE> }T
T{ 16 MAX-UINT BITS U> -> <FALSE> }T
\ The size of a cell shall be an integral multiple of the size of a
\ character.
T{ 1S BITS tnv MAX-CHAR BITS MOD -> 0 }T
\
3.1.3.4: Counted strings
\ The maximum length of a counted string shall be at least 255.
T{ 255 tnv /COUNTED-STRING > -> <FALSE> }T
\ 3.2.6: Environmental queries
T{ tnv MAX-N -> MAX-INT }T \ Largest usable signed integer
T{ tnv MAX-U -> MAX-UINT }T \ Largest usable unsigned integer
T{ tnv MAX-D -> -1 MAX-INT }T \ Largest usable signed double number
T{ tnv MAX-UD -> -1 MAX-UINT }T \ Largest usable unsigned double number
T{ tnv FLOORED -> -3 2 / -2 = }T \ True if floored division is the default
\ The standard does not specify a minimum number of cells for either
\ the Data or Return stacks, but a system should provide this
\ information, and it is safe to assume at least 1 cell.
T{ 1 tnv STACK-CELLS > -> <FALSE> }T
T{ 1 tnv RETURN-STACK-CELLS > -> <FALSE> }T
\
3.3.3.6: Other transient regions
\ The size of the scratch area whose address is returned by PAD shall
\ be at least 84 characters.
T{ 84 tnv /PAD > -> <FALSE> }T
\ The size of the pictured numeric output string buffer shall be at
\ least (2n)+2 characters, where n is the number of bits in a cell.
T{ 1S BITS 2* 2 + tnv /HOLD > -> <FALSE> }T
--
Peter Knaggs