aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJeffrey Yasskin <[email protected]>2010-07-12 05:08:46 +0800
committerGraydon Hoare <[email protected]>2010-07-16 08:13:08 +0800
commitc866672a994267c165bef960d90b0fa8f9677b22 (patch)
treefd7604cc081b48e566d13d314728d2a0d9c1da09 /src/test
parentLet the compiler find libraries that aren't in the current directory. (diff)
downloadrust-c866672a994267c165bef960d90b0fa8f9677b22.tar.xz
rust-c866672a994267c165bef960d90b0fa8f9677b22.zip
Add a test for std._vec.init_elt, and an XFAILed test for std._vec.init_fn.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/vec-lib.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/run-pass/vec-lib.rs b/src/test/run-pass/vec-lib.rs
new file mode 100644
index 00000000..32e01b96
--- /dev/null
+++ b/src/test/run-pass/vec-lib.rs
@@ -0,0 +1,30 @@
+use std;
+
+fn test_init_elt() {
+ let vec[uint] v = std._vec.init_elt[uint](uint(5), uint(3));
+ check (std._vec.len[uint](v) == uint(3));
+ check (v.(0) == uint(5));
+ check (v.(1) == uint(5));
+ check (v.(2) == uint(5));
+}
+
+fn id(uint x) -> uint {
+ ret x;
+}
+fn test_init_fn() {
+ let fn(uint)->uint op = id;
+ let vec[uint] v = std._vec.init_fn[uint](op, uint(5));
+ // FIXME #108: Can't call templated function twice in the same
+ // program, at the moment.
+ //check (std._vec.len[uint](v) == uint(5));
+ check (v.(0) == uint(0));
+ check (v.(1) == uint(1));
+ check (v.(2) == uint(2));
+ check (v.(3) == uint(3));
+ check (v.(4) == uint(4));
+}
+
+fn main() {
+ test_init_elt();
+ //XFAIL: test_init_fn(); // Segfaults.
+} \ No newline at end of file