about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-07-31 17:30:38 -0700
committerBrian Anderson <banderson@mozilla.com>2012-07-31 17:30:54 -0700
commitc4bb8f8aafd25b9d5e68481af7088ab9e47c1e29 (patch)
treefb6de5fde377801844eb01cf15cd815a6c93d503
parent7b2026bf218c416c653faf8bb8cca770d0bb2c0d (diff)
downloadrust-c4bb8f8aafd25b9d5e68481af7088ab9e47c1e29.tar.gz
rust-c4bb8f8aafd25b9d5e68481af7088ab9e47c1e29.zip
test: Move two tests from run-pass into the libs
-rw-r--r--src/libcore/at_vec.rs16
-rw-r--r--src/libcore/ptr.rs11
-rw-r--r--src/test/run-pass/at_vec_building.rs16
-rw-r--r--src/test/run-pass/ptr-is-null.rs9
4 files changed, 27 insertions, 25 deletions
diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs
index 66c0de07a76..95b7c1c830e 100644
--- a/src/libcore/at_vec.rs
+++ b/src/libcore/at_vec.rs
@@ -198,3 +198,19 @@ mod unsafe {
     }
 
 }
+
+#[test]
+fn test() {
+    // Some code that could use that, then:
+    fn seq_range(lo: uint, hi: uint) -> @[uint] {
+        do build |push| {
+            for uint::range(lo, hi) |i| {
+                push(i);
+            }
+        }
+    }
+
+    assert seq_range(10, 15) == @[10, 11, 12, 13, 14];
+    assert from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5];
+    assert from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14];
+}
\ No newline at end of file
diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs
index e1d21b826a5..cc60d18af21 100644
--- a/src/libcore/ptr.rs
+++ b/src/libcore/ptr.rs
@@ -200,3 +200,14 @@ fn test_buf_len() {
         }
     }
 }
+
+#[test]
+fn test_is_null() {
+   let p: *int = ptr::null();
+   assert p.is_null();
+   assert !p.is_not_null();
+
+   let q = ptr::offset(p, 1u);
+   assert !q.is_null();
+   assert q.is_not_null();
+}
\ No newline at end of file
diff --git a/src/test/run-pass/at_vec_building.rs b/src/test/run-pass/at_vec_building.rs
deleted file mode 100644
index 3202dfe221a..00000000000
--- a/src/test/run-pass/at_vec_building.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-import at_vec::{build, from_fn, from_elem};
-
-// Some code that could use that, then:
-fn seq_range(lo: uint, hi: uint) -> @[uint] {
-    do build |push| {
-        for uint::range(lo, hi) |i| {
-            push(i);
-        }
-    }
-}
-
-fn main() {
-    assert seq_range(10, 15) == @[10, 11, 12, 13, 14];
-    assert from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5];
-    assert from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14];
-}
diff --git a/src/test/run-pass/ptr-is-null.rs b/src/test/run-pass/ptr-is-null.rs
deleted file mode 100644
index a08c6cbccaa..00000000000
--- a/src/test/run-pass/ptr-is-null.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-fn main() {
-   let p: *int = ptr::null();
-   assert p.is_null();
-   assert !p.is_not_null();
-
-   let q = ptr::offset(p, 1u);
-   assert !q.is_null();
-   assert q.is_not_null();
-}