test: Move two tests from run-pass into the libs
This commit is contained in:
parent
7b2026bf21
commit
c4bb8f8aaf
@ -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];
|
||||
}
|
@ -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();
|
||||
}
|
@ -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];
|
||||
}
|
@ -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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user