From 88b2ed482c982c1e1e837c3409ef2d369ac70515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sat, 8 Oct 2016 12:26:57 +0200 Subject: [PATCH] math.parser: (format-float) can only be flushable --- .../bootstrap/image/primitives/primitives.factor | 2 +- core/math/parser/parser-tests.factor | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/basis/bootstrap/image/primitives/primitives.factor b/basis/bootstrap/image/primitives/primitives.factor index 7c149b9db9..5ffd047ad6 100644 --- a/basis/bootstrap/image/primitives/primitives.factor +++ b/basis/bootstrap/image/primitives/primitives.factor @@ -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 } } } diff --git a/core/math/parser/parser-tests.factor b/core/math/parser/parser-tests.factor index 4b8bbd1e35..24ccd1aab8 100644 --- a/core/math/parser/parser-tests.factor +++ b/core/math/parser/parser-tests.factor @@ -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