From a47d52c2f64de064d03dda853b44b116b284635e Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 18 Mar 2014 21:31:40 -0700 Subject: collections: remove List It was decided in a meeting that this module wasn't needed, and more thought should be put into a persistent collections library. --- src/test/bench/task-perf-alloc-unwind.rs | 6 +++++- .../log-knows-the-names-of-variants-in-std.rs | 21 +++++++++++++++------ src/test/run-pass/non-boolean-pure-fns.rs | 16 ++++++++-------- 3 files changed, 28 insertions(+), 15 deletions(-) (limited to 'src/test') diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 4a53b3cbfe4..fc7e6a03bcf 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -13,12 +13,16 @@ extern crate collections; extern crate time; -use collections::list::{List, Cons, Nil}; use time::precise_time_s; use std::os; use std::task; use std::vec; +#[deriving(Clone)] +enum List { + Nil, Cons(T, @List) +} + enum UniqueList { ULNil, ULCons(~UniqueList) } diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index 0129740252c..7e120658aae 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -10,9 +10,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate collections; -use collections::list::List; - #[deriving(Clone)] enum foo { a(uint), @@ -24,9 +21,21 @@ fn check_log(exp: ~str, v: T) { } pub fn main() { - let x = List::from_vec([a(22u), b(~"hi")]); - let exp = ~"Cons(a(22u), @Cons(b(~\"hi\"), @Nil))"; + let mut x = Some(a(22u)); + let exp = ~"Some(a(22u))"; + let act = format!("{:?}", x); + assert_eq!(act, exp); + check_log(exp, x); + + x = Some(b(~"hi")); + let exp = ~"Some(b(~\"hi\"))"; + let act = format!("{:?}", x); + assert_eq!(act, exp); + check_log(exp, x); + + x = None; + let exp = ~"None"; let act = format!("{:?}", x); - assert!(act == exp); + assert_eq!(act, exp); check_log(exp, x); } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index 66bb2e702be..70654da8932 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -16,21 +16,21 @@ extern crate collections; use collections::list::{List, Cons, Nil}; -fn pure_length_go(ls: @List, acc: uint) -> uint { - match *ls { Nil => { acc } Cons(_, tl) => { pure_length_go(tl, acc + 1u) } } +fn pure_length_go(ls: &List, acc: uint) -> uint { + match *ls { Nil => { acc } Cons(_, ref tl) => { pure_length_go(&**tl, acc + 1u) } } } -fn pure_length(ls: @List) -> uint { pure_length_go(ls, 0u) } +fn pure_length(ls: &List) -> uint { pure_length_go(ls, 0u) } -fn nonempty_list(ls: @List) -> bool { pure_length(ls) > 0u } +fn nonempty_list(ls: &List) -> bool { pure_length(ls) > 0u } -fn safe_head(ls: @List) -> T { +fn safe_head(ls: &List) -> T { assert!(!ls.is_empty()); return ls.head().unwrap().clone(); } pub fn main() { - let mylist = @Cons(@1u, @Nil); - assert!((nonempty_list(mylist))); - assert_eq!(*safe_head(mylist), 1u); + let mylist = Cons(1u, ~Nil); + assert!((nonempty_list(&mylist))); + assert_eq!(safe_head(&mylist), 1u); } -- cgit 1.4.1-3-g733a5 From e0e8e957ea3edce7104af9e972ce3a3542aeeb80 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 18 Mar 2014 21:32:02 -0700 Subject: test: remove pure test, which is now redundant with inline tests --- src/test/run-pass/non-boolean-pure-fns.rs | 36 ------------------------------- 1 file changed, 36 deletions(-) delete mode 100644 src/test/run-pass/non-boolean-pure-fns.rs (limited to 'src/test') diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs deleted file mode 100644 index 70654da8932..00000000000 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ /dev/null @@ -1,36 +0,0 @@ -// ignore-fast - -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[feature(managed_boxes)]; - -extern crate collections; - -use collections::list::{List, Cons, Nil}; - -fn pure_length_go(ls: &List, acc: uint) -> uint { - match *ls { Nil => { acc } Cons(_, ref tl) => { pure_length_go(&**tl, acc + 1u) } } -} - -fn pure_length(ls: &List) -> uint { pure_length_go(ls, 0u) } - -fn nonempty_list(ls: &List) -> bool { pure_length(ls) > 0u } - -fn safe_head(ls: &List) -> T { - assert!(!ls.is_empty()); - return ls.head().unwrap().clone(); -} - -pub fn main() { - let mylist = Cons(1u, ~Nil); - assert!((nonempty_list(&mylist))); - assert_eq!(safe_head(&mylist), 1u); -} -- cgit 1.4.1-3-g733a5