Skip to content

Commit c866672

Browse files
jyasskingraydon
authored andcommitted
Add a test for std._vec.init_elt, and an XFAILed test for std._vec.init_fn.
1 parent 3e63343 commit c866672

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: src/test/run-pass/vec-lib.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std;
2+
3+
fn test_init_elt() {
4+
let vec[uint] v = std._vec.init_elt[uint](uint(5), uint(3));
5+
check (std._vec.len[uint](v) == uint(3));
6+
check (v.(0) == uint(5));
7+
check (v.(1) == uint(5));
8+
check (v.(2) == uint(5));
9+
}
10+
11+
fn id(uint x) -> uint {
12+
ret x;
13+
}
14+
fn test_init_fn() {
15+
let fn(uint)->uint op = id;
16+
let vec[uint] v = std._vec.init_fn[uint](op, uint(5));
17+
// FIXME #108: Can't call templated function twice in the same
18+
// program, at the moment.
19+
//check (std._vec.len[uint](v) == uint(5));
20+
check (v.(0) == uint(0));
21+
check (v.(1) == uint(1));
22+
check (v.(2) == uint(2));
23+
check (v.(3) == uint(3));
24+
check (v.(4) == uint(4));
25+
}
26+
27+
fn main() {
28+
test_init_elt();
29+
//XFAIL: test_init_fn(); // Segfaults.
30+
}

0 commit comments

Comments
 (0)