mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
runtime/mercury_float.c:
Fix a bug in MR_sprintf_float where it would convert 1.8e-10
into "1.80000000000000e-1" instead of "1.8e-10".
The problem was that it was stripping the zeros off the end of the string
produced by sprintf without considering the case where the output
was in scientific notation.
The fix is to remove the `#' from the sprintf format string and then to
append ".0" to the string if there is no "." or "e".
tests/general/float_roundtrip.m:
tests/general/float_roundtrip.exp:
Add regression test.
tests/hard_coded/deep_copy.exp:
tests/hard_coded/expand.exp:
tests/hard_coded/float_reg.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_binary.exp:
tests/hard_coded/write_reg1.exp:
tests/hard_coded/write_xml.exp:
Update the expected output of these tests as trailing zeros are now
also removed from the base part of scientific notation float strings.
203 lines
4.2 KiB
Plaintext
203 lines
4.2 KiB
Plaintext
TESTING DISCRIMINATED UNIONS
|
|
one/0
|
|
0/0
|
|
no arguments
|
|
expand: functor one arity 0 arguments []
|
|
expand: functor 0 arity 0 arguments []
|
|
|
|
two/0
|
|
2/0
|
|
no arguments
|
|
expand: functor two arity 0 arguments []
|
|
expand: functor 2 arity 0 arguments []
|
|
|
|
three/0
|
|
1/0
|
|
no arguments
|
|
expand: functor three arity 0 arguments []
|
|
expand: functor 1 arity 0 arguments []
|
|
|
|
apple/1
|
|
0/1
|
|
argument 1 of functor apple was:[9, 5, 1]
|
|
expand: functor apple arity 1 arguments [[9, 5, 1]]
|
|
expand: functor 0 arity 1 arguments [[9, 5, 1]]
|
|
|
|
banana/1
|
|
1/1
|
|
argument 1 of functor banana was:[three, one, two]
|
|
expand: functor banana arity 1 arguments [[three, one, two]]
|
|
expand: functor 1 arity 1 arguments [[three, one, two]]
|
|
|
|
zop/2
|
|
10/2
|
|
argument 2 of functor zop was:2.03
|
|
expand: functor zop arity 2 arguments [3.3, 2.03]
|
|
expand: functor 10 arity 2 arguments [3.3, 2.03]
|
|
|
|
zip/2
|
|
8/2
|
|
argument 2 of functor zip was:2
|
|
expand: functor zip arity 2 arguments [3, 2]
|
|
expand: functor 8 arity 2 arguments [3, 2]
|
|
|
|
zap/2
|
|
7/2
|
|
argument 2 of functor zap was:-2.111
|
|
expand: functor zap arity 2 arguments [3, -2.111]
|
|
expand: functor 7 arity 2 arguments [3, -2.111]
|
|
|
|
wombat/0
|
|
6/0
|
|
no arguments
|
|
expand: functor wombat arity 0 arguments []
|
|
expand: functor 6 arity 0 arguments []
|
|
|
|
foo/0
|
|
2/0
|
|
no arguments
|
|
expand: functor foo arity 0 arguments []
|
|
expand: functor 2 arity 0 arguments []
|
|
|
|
|
|
TESTING POLYMORPHISM
|
|
poly_two/1
|
|
2/1
|
|
argument 1 of functor poly_two was:3
|
|
expand: functor poly_two arity 1 arguments [3]
|
|
expand: functor 2 arity 1 arguments [3]
|
|
|
|
poly_three/3
|
|
1/3
|
|
argument 3 of functor poly_three was:poly_one(9.11)
|
|
expand: functor poly_three arity 3 arguments [3.33, 4, poly_one(9.11)]
|
|
expand: functor 1 arity 3 arguments [3.33, 4, poly_one(9.11)]
|
|
|
|
poly_one/1
|
|
0/1
|
|
argument 1 of functor poly_one was:[2399.3]
|
|
expand: functor poly_one arity 1 arguments [[2399.3]]
|
|
expand: functor 0 arity 1 arguments [[2399.3]]
|
|
|
|
|
|
TESTING BUILTINS
|
|
""/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor "" arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
"Hello, world
|
|
"/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor "Hello, world
|
|
" arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
"Foo%sFoo"/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor "Foo%sFoo" arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
"""/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor """ arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
'a'/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor 'a' arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
'&'/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor '&' arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
3.14159/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor 3.14159 arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
1.128324983e-21/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor 1.128324983e-21 arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
2.23954899e+23/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor 2.23954899e+23 arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
-65/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor -65 arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
4/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor 4 arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
univ_cons/1
|
|
0/1
|
|
argument 1 of functor univ_cons was:["hi! I\'m a univ!"]
|
|
expand: functor univ_cons arity 1 arguments [["hi! I\'m a univ!"]]
|
|
expand: functor 0 arity 1 arguments [["hi! I\'m a univ!"]]
|
|
|
|
<<predicate>>/0
|
|
functor_number_cc failed
|
|
no arguments
|
|
expand: functor <<predicate>> arity 0 arguments []
|
|
deconstruct_du failed
|
|
|
|
{}/4
|
|
0/4
|
|
argument 4 of functor {} was:{1, 2, 3, 4}
|
|
expand: functor {} arity 4 arguments [1, 'b', "third", {1, 2, 3, 4}]
|
|
expand: functor 0 arity 4 arguments [1, 'b', "third", {1, 2, 3, 4}]
|
|
|
|
|
|
TESTING OTHER TYPES
|
|
var/1
|
|
0/1
|
|
argument 1 of functor var was:1
|
|
expand: functor var arity 1 arguments [1]
|
|
expand: functor 0 arity 1 arguments [1]
|
|
|
|
var_supply/1
|
|
0/1
|
|
argument 1 of functor var_supply was:0
|
|
expand: functor var_supply arity 1 arguments [0]
|
|
expand: functor 0 arity 1 arguments [0]
|
|
|
|
var_supply/1
|
|
0/1
|
|
argument 1 of functor var_supply was:1
|
|
expand: functor var_supply arity 1 arguments [1]
|
|
expand: functor 0 arity 1 arguments [1]
|
|
|
|
empty/0
|
|
0/0
|
|
no arguments
|
|
expand: functor empty arity 0 arguments []
|
|
expand: functor 0 arity 0 arguments []
|
|
|
|
qwerty/1
|
|
0/1
|
|
argument 1 of functor qwerty was:4
|
|
expand: functor qwerty arity 1 arguments [4]
|
|
expand: functor 0 arity 1 arguments [4]
|
|
|
|
|