diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-22 11:44:11 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-22 11:47:47 +0100 |
| commit | ad03761a97eb0f651e3ce4f54cbf87dbf4d6f80f (patch) | |
| tree | 03eb60b2d440ebfc6b668e359c28fe0e8e69b042 /src/libstd | |
| parent | e57b6775c3a2d9dbe7fae69c189b8ae9032315cb (diff) | |
| download | rust-ad03761a97eb0f651e3ce4f54cbf87dbf4d6f80f.tar.gz rust-ad03761a97eb0f651e3ce4f54cbf87dbf4d6f80f.zip | |
Remove preconditions from libraries
Closes #1805
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/fs.rs | 3 | ||||
| -rw-r--r-- | src/libstd/list.rs | 13 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 2 | ||||
| -rw-r--r-- | src/libstd/test.rs | 10 |
4 files changed, 5 insertions, 23 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 947942e20d8..30abbb1e70a 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -107,12 +107,11 @@ Connects a vector of path segments into a single path. Inserts path separators as needed. */ -fn connect_many(paths: [path]) : vec::is_not_empty(paths) -> path { +fn connect_many(paths: [path]) -> path { ret if vec::len(paths) == 1u { paths[0] } else { let rest = vec::slice(paths, 1u, vec::len(paths)); - check vec::is_not_empty(rest); connect(paths[0], connect_many(rest)) } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index be6ce7338a3..3c2d6988587 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -140,11 +140,8 @@ Function: head Returns the first element of a list */ -pure fn head<T: copy>(ls: list<T>) : is_not_empty(ls) -> T { - alt ls { - cons(hd, _) { ret hd; } - nil { fail "list empty" } - } +pure fn head<T: copy>(ls: list<T>) -> T { + alt check ls { cons(hd, _) { hd } } } /* @@ -205,15 +202,12 @@ mod tests { fn test_from_vec() { let l = from_vec([0, 1, 2]); - check is_not_empty(l); assert (head(l) == 0); 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); } @@ -227,15 +221,12 @@ mod tests { fn test_from_vec_mut() { let l = from_vec([mutable 0, 1, 2]); - check is_not_empty(l); assert (head(l) == 0); 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); } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 8c4ac924055..cceff6d66bb 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -252,8 +252,6 @@ mod test_qsort { let immut_names = vec::from_mut(names); - // Silly, but what else can we do? - check (vec::same_length(expected, immut_names)); let pairs = vec::zip(expected, immut_names); for (a, b) in pairs { #debug("%d %d", a, b); assert (a == b); } } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 9f25916778f..6f39ea14047 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -47,7 +47,6 @@ type test_desc = { // The default console test runner. It accepts the command line // arguments and a vector of test_descs (generated at compile time). fn test_main(args: [str], tests: [test_desc]) { - check (vec::is_not_empty(args)); let opts = alt parse_opts(args) { either::left(o) { o } @@ -61,8 +60,7 @@ type test_opts = {filter: option<str>, run_ignored: bool}; type opt_res = either::t<test_opts, str>; // Parses command line arguments into test options -fn parse_opts(args: [str]) : vec::is_not_empty(args) -> opt_res { - +fn parse_opts(args: [str]) -> opt_res { let args_ = vec::tail(args); let opts = [getopts::optflag("ignored")]; let match = @@ -407,7 +405,6 @@ mod tests { #[test] fn first_free_arg_should_be_a_filter() { let args = ["progname", "filter"]; - check (vec::is_not_empty(args)); let opts = alt parse_opts(args) { either::left(o) { o } _ { fail "Malformed arg in first_free_arg_should_be_a_filter"; } }; assert (str::eq("filter", option::get(opts.filter))); @@ -416,7 +413,6 @@ mod tests { #[test] fn parse_ignored_flag() { let args = ["progname", "filter", "--ignored"]; - check (vec::is_not_empty(args)); let opts = alt parse_opts(args) { either::left(o) { o } _ { fail "Malformed arg in parse_ignored_flag"; } }; assert (opts.run_ignored); @@ -469,12 +465,10 @@ mod tests { "test::ignored_tests_result_in_ignored", "test::parse_ignored_flag", "test::sort_tests"]; - check (vec::same_length(expected, filtered)); let pairs = vec::zip(expected, filtered); - for (a, b) in pairs { assert (a == b.name); } - } +} } |
