about summary refs log tree commit diff
path: root/src/test/stdtest/float.rs
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2011-10-27 22:01:30 -0700
committerBrian Anderson <banderson@mozilla.com>2011-10-28 14:44:39 -0700
commit000b2fe9a6b18cab1deee9579e8740d7c37a67b4 (patch)
tree513f8248a6998825fa45b5c7ff6540e8d1a0a63b /src/test/stdtest/float.rs
parent7e064deacfc9eab6e79737bb1f5070a19e2e1dc1 (diff)
downloadrust-000b2fe9a6b18cab1deee9579e8740d7c37a67b4.tar.gz
rust-000b2fe9a6b18cab1deee9579e8740d7c37a67b4.zip
Use IEEE 754 semantics for NaN (Issue #1084)
Diffstat (limited to 'src/test/stdtest/float.rs')
-rw-r--r--src/test/stdtest/float.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/test/stdtest/float.rs b/src/test/stdtest/float.rs
index 086942fb8c1..302d6b1679e 100644
--- a/src/test/stdtest/float.rs
+++ b/src/test/stdtest/float.rs
@@ -10,7 +10,7 @@ fn test_from_str() {
    assert ( float::from_str("2.5e10") == 25000000000. );
    assert ( float::from_str("25000000000.E-10") == 2.5 );
    assert ( float::from_str("") == 0. );
-   assert ( float::from_str("   ") == 0. );
+   assert ( float::isNaN(float::from_str("   ")) );
    assert ( float::from_str(".") == 0. );
    assert ( float::from_str("5.") == 5. );
    assert ( float::from_str(".5") == 0.5 );
@@ -25,6 +25,7 @@ fn test_positive() {
   assert(!float::positive(-1.));
   assert(!float::positive(float::neg_infinity()));
   assert(!float::positive(1./float::neg_infinity()));
+  assert(!float::positive(float::NaN()));
 }
 
 #[test]
@@ -35,4 +36,27 @@ fn test_negative() {
   assert(float::negative(-1.));
   assert(float::negative(float::neg_infinity()));
   assert(float::negative(1./float::neg_infinity()));
+  assert(!float::negative(float::NaN()));
+}
+
+#[test]
+fn test_nonpositive() {
+  assert(!float::nonpositive(float::infinity()));
+  assert(!float::nonpositive(1.));
+  assert(!float::nonpositive(0.));
+  assert(float::nonpositive(-1.));
+  assert(float::nonpositive(float::neg_infinity()));
+  assert(float::nonpositive(1./float::neg_infinity()));
+  // TODO: assert(!float::nonpositive(float::NaN()));
+}
+
+#[test]
+fn test_nonnegative() {
+  assert(float::nonnegative(float::infinity()));
+  assert(float::nonnegative(1.));
+  assert(float::nonnegative(0.));
+  assert(!float::nonnegative(-1.));
+  assert(!float::nonnegative(float::neg_infinity()));
+  assert(!float::nonnegative(1./float::neg_infinity()));
+  // TODO: assert(!float::nonnegative(float::NaN()));
 }