diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2014-09-02 07:42:24 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2014-09-02 07:46:27 -0400 |
commit | f33fddeca8c03e72b526d822c4d7f75e6399ddf8 (patch) | |
tree | 5c01c0c3adef5e10676ab202ffe7c9738417cee1 /t | |
parent | a3d47e0d2ac20034d8d96f777e886b55ab96dd0f (diff) | |
download | perl-f33fddeca8c03e72b526d822c4d7f75e6399ddf8.tar.gz |
Basic string-to-nv should equal floating point literals.
(In my floating point adventures I managed to break this basic assumption,
guard against it happening again.)
Diffstat (limited to 't')
-rw-r--r-- | t/opbasic/arith.t | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/t/opbasic/arith.t b/t/opbasic/arith.t index a90e84c071..10efe86fb8 100644 --- a/t/opbasic/arith.t +++ b/t/opbasic/arith.t @@ -9,7 +9,7 @@ BEGIN { # functions imported from t/test.pl or Test::More, as those programs/libraries # use operators which are what is being tested in this file. -print "1..175\n"; +print "1..181\n"; sub try ($$$) { print +($_[1] ? "ok" : "not ok"), " $_[0] - $_[2]\n"; @@ -468,3 +468,11 @@ try $T++, 0.1530000e-305 != 0.0, '0.1530000e-305'; try $T++, 0.1530001e-305 != 0.0, '0.1530001e-305'; try $T++, 1.17549435100e-38 != 0.0, 'min single'; try $T++, 2.2250738585072014e-308 != 0.0, 'min double'; + +# string-to-nv should equal float literals +try $T++, "1.23" + 0 == 1.23, '1.23'; +try $T++, " 1.23" + 0 == 1.23, '1.23 with leading space'; +try $T++, "1.23 " + 0 == 1.23, '1.23 with trailing space'; +try $T++, "+1.23" + 0 == 1.23, '1.23 with unary plus'; +try $T++, "-1.23" + 0 == -1.23, '1.23 with unary minus'; +try $T++, "1.23e4" + 0 == 12300, '1.23e4'; |