aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJeffrey Yasskin <[email protected]>2010-07-12 05:51:02 +0800
committerGraydon Hoare <[email protected]>2010-07-16 08:13:08 +0800
commit765a2b3ecffb68a18849de6db54a680a1fd6eee4 (patch)
tree98f7e50eb0645feba63432e0ea584f876e212b73 /src/test
parentAdd a test for std._vec.init_elt, and an XFAILed test for std._vec.init_fn. (diff)
downloadrust-765a2b3ecffb68a18849de6db54a680a1fd6eee4.tar.xz
rust-765a2b3ecffb68a18849de6db54a680a1fd6eee4.zip
Add a _vec.slice function that'll hold us over until .(a,b) syntax is
implemented. This could actually replace .(a,b) syntax if the language grows optional function parameters.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/vec-lib.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/run-pass/vec-lib.rs b/src/test/run-pass/vec-lib.rs
index 32e01b96..11dd2ffd 100644
--- a/src/test/run-pass/vec-lib.rs
+++ b/src/test/run-pass/vec-lib.rs
@@ -24,7 +24,18 @@ fn test_init_fn() {
check (v.(4) == uint(4));
}
+fn test_slice() {
+ let vec[int] v = vec(1,2,3,4,5);
+ auto v2 = std._vec.slice[int](v, 2, 4);
+ // FIXME #108: Can't call templated function twice in the same
+ // program, at the moment.
+ //check (std._vec.len[int](v2) == uint(2));
+ check (v2.(0) == 3);
+ check (v2.(1) == 4);
+}
+
fn main() {
test_init_elt();
//XFAIL: test_init_fn(); // Segfaults.
-} \ No newline at end of file
+ test_slice();
+}