math.parser: (format-float) can only be flushable

char-rename
Björn Lindqvist 2016-10-08 12:26:57 +02:00
parent bbd71ae975
commit 88b2ed482c
2 changed files with 16 additions and 2 deletions

View File

@ -404,7 +404,7 @@ CONSTANT: all-primitives {
"(format-float)" ( n fill width precision format locale -- byte-array )
"format_float"
{ float byte-array fixnum fixnum byte-array byte-array } { byte-array }
make-foldable
make-flushable
}
}
}

View File

@ -1,4 +1,5 @@
USING: layouts literals math math.parser.private sequences tools.test ;
USING: kernel layouts literals math math.parser.private sequences
strings tools.test ;
IN: math.parser
{ f }
@ -473,3 +474,16 @@ unit-test
{ "" } [
33.4 "" 4 4 "f" "missing" format-float
] unit-test
! Literal byte arrays are mutable, so (format-float) isn't foldable.
: trouble ( -- str ba )
155000.0 B{ } -1 3 B{ 69 0 } [
B{ 67 0 } (format-float) >string
] keep ;
{
"1.55E+05"
"1.550e+05"
} [
trouble CHAR: e 0 rot set-nth trouble drop
] unit-test