math.parser: fix digit> bug found by Blei

db4
Joe Groff 2010-02-07 13:04:20 -08:00
parent 38ca12e9d8
commit 90ea5796f4
2 changed files with 20 additions and 5 deletions

View File

@ -5,6 +5,22 @@ IN: math.parser.tests
[ f string>number ]
unit-test
[ f ]
[ ";" string>number ]
unit-test
[ f ]
[ "<>" string>number ]
unit-test
[ f ]
[ "^" string>number ]
unit-test
[ f ]
[ "789:;<=>?@" string>number ]
unit-test
[ f ]
[ "12345abcdef" string>number ]
unit-test

View File

@ -5,11 +5,10 @@ IN: math.parser
: digit> ( ch -- n )
{
{ [ dup CHAR: 9 <= ] [ CHAR: 0 - ] }
{ [ dup CHAR: a < ] [ CHAR: A 10 - - ] }
[ CHAR: a 10 - - ]
} cond
dup 0 < [ drop 255 ] when ; inline
{ [ dup CHAR: 9 <= ] [ CHAR: 0 - dup 0 < [ drop 255 ] when ] }
{ [ dup CHAR: a < ] [ CHAR: A 10 - - dup 10 < [ drop 255 ] when ] }
[ CHAR: a 10 - - dup 10 < [ drop 255 ] when ]
} cond ; inline
<PRIVATE