about summary refs log tree commit diff
path: root/src/test/stdtest
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-10-28 22:42:38 -0700
committerBrian Anderson <banderson@mozilla.com>2011-10-28 22:42:38 -0700
commita2377ccf91158ce5c9da2e5d0cc1f56fa562b2fe (patch)
tree8030b1abf93ea7d57f4e71dea05de8c3d4fe2259 /src/test/stdtest
parentd5415a39739758e6e06e476e3bcb8c3b9466d7e8 (diff)
downloadrust-a2377ccf91158ce5c9da2e5d0cc1f56fa562b2fe.tar.gz
rust-a2377ccf91158ce5c9da2e5d0cc1f56fa562b2fe.zip
stdlib: Add vec::init. Returns all but the last element.
Per haskell, to go with head/tail, and last.
Diffstat (limited to 'src/test/stdtest')
-rw-r--r--src/test/stdtest/vec.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/stdtest/vec.rs b/src/test/stdtest/vec.rs
index 453c9f8e414..5f644c450b6 100644
--- a/src/test/stdtest/vec.rs
+++ b/src/test/stdtest/vec.rs
@@ -5,6 +5,7 @@ import std::vec::*;
 import std::option;
 import std::option::none;
 import std::option::some;
+import std::task;
 
 fn square(n: uint) -> uint { ret n * n; }
 
@@ -443,6 +444,31 @@ fn reversed_mut() {
     assert (v2[1] == 10);
 }
 
+#[test]
+fn init() {
+    let v = vec::init([1, 2, 3]);
+    assert v == [1, 2];
+}
+
+#[cfg(target_os = "linux")]
+#[cfg(target_os = "mac")]
+#[test]
+fn init_empty() {
+
+    let r = task::join(
+        task::spawn_joinable((), fn (&&_i: ()) {
+            task::unsupervise();
+            vec::init::<int>([]);
+        }));
+    assert r == task::tr_failure
+}
+
+// FIXME: Windows can't undwind
+#[cfg(target_os = "win32")]
+#[test]
+#[ignore]
+fn init_empty() { }
+
 // Local Variables:
 // mode: rust;
 // fill-column: 78;