about summary refs log tree commit diff
path: root/src/test/stdtest
diff options
context:
space:
mode:
authorLenny222 <github@kudling.de>2011-12-29 21:24:03 +0100
committerLenny222 <github@kudling.de>2011-12-29 21:24:03 +0100
commitd07c6e8a0ede3114ebfd8c3ea6cc161cf009f072 (patch)
tree986f6ce8c40d0c363a470e03349c7a23088ec811 /src/test/stdtest
parent816b0ac8ae3444a81e60e18a05430bb869ba4b3b (diff)
downloadrust-d07c6e8a0ede3114ebfd8c3ea6cc161cf009f072.tar.gz
rust-d07c6e8a0ede3114ebfd8c3ea6cc161cf009f072.zip
list: use predicate to enforce non-empty requirement
Diffstat (limited to 'src/test/stdtest')
-rw-r--r--src/test/stdtest/list.rs28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/test/stdtest/list.rs b/src/test/stdtest/list.rs
index 227e8ad299d..d88e669378a 100644
--- a/src/test/stdtest/list.rs
+++ b/src/test/stdtest/list.rs
@@ -2,17 +2,23 @@ import core::*;
 
 use std;
 import std::list;
-import std::list::head;
-import std::list::tail;
-import std::list::from_vec;
+import std::list::{from_vec, head, is_not_empty, tail};
 import option;
 
 #[test]
 fn test_from_vec() {
     let l = from_vec([0, 1, 2]);
+
+    check is_not_empty(l);
     assert (head(l) == 0);
-    assert (head(tail(l)) == 1);
-    assert (head(tail(tail(l))) == 2);
+
+    let tail_l = tail(l);
+    check is_not_empty(tail_l);
+    assert (head(tail_l) == 1);
+
+    let tail_tail_l = tail(tail_l);
+    check is_not_empty(tail_tail_l);
+    assert (head(tail_tail_l) == 2);
 }
 
 #[test]
@@ -24,9 +30,17 @@ fn test_from_vec_empty() {
 #[test]
 fn test_from_vec_mut() {
     let l = from_vec([mutable 0, 1, 2]);
+
+    check is_not_empty(l);
     assert (head(l) == 0);
-    assert (head(tail(l)) == 1);
-    assert (head(tail(tail(l))) == 2);
+
+    let tail_l = tail(l);
+    check is_not_empty(tail_l);
+    assert (head(tail_l) == 1);
+
+    let tail_tail_l = tail(tail_l);
+    check is_not_empty(tail_tail_l);
+    assert (head(tail_tail_l) == 2);
 }
 
 #[test]