diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-09-02 15:34:58 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-09-02 22:11:42 -0700 |
| commit | 5c49e4f4e92997869de1f75f9089c9db7e7a6ebe (patch) | |
| tree | 947f6d58da06e589a0ab0627319917a9d2352a8c /src/test | |
| parent | b5f905342337a3dc12bdc5dc6d98d3ecdf60439d (diff) | |
| download | rust-5c49e4f4e92997869de1f75f9089c9db7e7a6ebe.tar.gz rust-5c49e4f4e92997869de1f75f9089c9db7e7a6ebe.zip | |
Reformat. Issue #855
Diffstat (limited to 'src/test')
99 files changed, 1102 insertions, 1299 deletions
diff --git a/src/test/bench/99bob-iter.rs b/src/test/bench/99bob-iter.rs index fea1420f8bb..a1a3e1b984a 100644 --- a/src/test/bench/99bob-iter.rs +++ b/src/test/bench/99bob-iter.rs @@ -8,28 +8,28 @@ use std; import std::int; import std::str; -fn b1() -> istr { ret ~"# of beer on the wall, # of beer."; } +fn b1() -> str { ret "# of beer on the wall, # of beer."; } -fn b2() -> istr { - ret ~"Take one down and pass it around, # of beer on the wall."; +fn b2() -> str { + ret "Take one down and pass it around, # of beer on the wall."; } -fn b7() -> istr { - ret ~"No more bottles of beer on the wall, no more bottles of beer."; +fn b7() -> str { + ret "No more bottles of beer on the wall, no more bottles of beer."; } -fn b8() -> istr { - ret ~"Go to the store and buy some more, # of beer on the wall."; +fn b8() -> str { + ret "Go to the store and buy some more, # of beer on the wall."; } -fn sub(t: &istr, n: int) -> istr { - let b: istr = ~""; +fn sub(t: &str, n: int) -> str { + let b: str = ""; let i: uint = 0u; - let ns: istr; + let ns: str; alt n { - 0 { ns = ~"no more bottles"; } - 1 { ns = ~"1 bottle"; } - _ { ns = int::to_str(n, 10u) + ~" bottles"; } + 0 { ns = "no more bottles"; } + 1 { ns = "1 bottle"; } + _ { ns = int::to_str(n, 10u) + " bottles"; } } while i < str::byte_len(t) { if t[i] == '#' as u8 { b += ns; } else { str::push_byte(b, t[i]); } diff --git a/src/test/bench/99bob-pattern.rs b/src/test/bench/99bob-pattern.rs index a13015fb4f7..fdfce9dfae5 100644 --- a/src/test/bench/99bob-pattern.rs +++ b/src/test/bench/99bob-pattern.rs @@ -29,12 +29,11 @@ fn show(b: bottle) { "1 bottle of beer on the wall."; } multiple(n) { - let nb: istr = int::to_str(n, 10u); - let mb: istr = int::to_str(n - 1, 10u); - log nb + ~" bottles of beer on the wall, " + nb + - ~" bottles of beer,"; - log ~"Take one down and pass it around, " + mb + - ~" bottles of beer on the wall."; + let nb: str = int::to_str(n, 10u); + let mb: str = int::to_str(n - 1, 10u); + log nb + " bottles of beer on the wall, " + nb + " bottles of beer,"; + log "Take one down and pass it around, " + mb + + " bottles of beer on the wall."; } } } diff --git a/src/test/bench/99bob-simple.rs b/src/test/bench/99bob-simple.rs index 30518c63e2d..ae1c30fb9ec 100644 --- a/src/test/bench/99bob-simple.rs +++ b/src/test/bench/99bob-simple.rs @@ -8,28 +8,28 @@ use std; import std::int; import std::str; -fn b1() -> istr { ret ~"# of beer on the wall, # of beer."; } +fn b1() -> str { ret "# of beer on the wall, # of beer."; } -fn b2() -> istr { - ret ~"Take one down and pass it around, # of beer on the wall."; +fn b2() -> str { + ret "Take one down and pass it around, # of beer on the wall."; } -fn b7() -> istr { - ret ~"No more bottles of beer on the wall, no more bottles of beer."; +fn b7() -> str { + ret "No more bottles of beer on the wall, no more bottles of beer."; } -fn b8() -> istr { - ret ~"Go to the store and buy some more, # of beer on the wall."; +fn b8() -> str { + ret "Go to the store and buy some more, # of beer on the wall."; } -fn sub(t: &istr, n: int) -> istr { - let b: istr = ~""; +fn sub(t: &str, n: int) -> str { + let b: str = ""; let i: uint = 0u; - let ns: istr; + let ns: str; alt n { - 0 { ns = ~"no more bottles"; } - 1 { ns = ~"1 bottle"; } - _ { ns = int::to_str(n, 10u) + ~" bottles"; } + 0 { ns = "no more bottles"; } + 1 { ns = "1 bottle"; } + _ { ns = int::to_str(n, 10u) + " bottles"; } } while i < str::byte_len(t) { if t[i] == '#' as u8 { b += ns; } else { str::push_byte(b, t[i]); } diff --git a/src/test/bench/99bob-tail.rs b/src/test/bench/99bob-tail.rs index 9ab8973cbce..af5e22f48ea 100644 --- a/src/test/bench/99bob-tail.rs +++ b/src/test/bench/99bob-tail.rs @@ -8,12 +8,11 @@ import std::str; fn main() { fn multiple(n: int) { - let nb: istr = int::to_str(n, 10u); - let mb: istr = int::to_str(n - 1, 10u); - log nb + ~" bottles of beer on the wall, " + nb + - ~" bottles of beer,"; - log ~"Take one down and pass it around, " + mb + - ~" bottles of beer on the wall."; + let nb: str = int::to_str(n, 10u); + let mb: str = int::to_str(n - 1, 10u); + log nb + " bottles of beer on the wall, " + nb + " bottles of beer,"; + log "Take one down and pass it around, " + mb + + " bottles of beer on the wall."; log ""; if n > 3 { be multiple(n - 1); } else { be dual(); } } diff --git a/src/test/bench/shootout-fannkuchredux.rs b/src/test/bench/shootout-fannkuchredux.rs index fa4a17180ae..8e7b2cbe269 100644 --- a/src/test/bench/shootout-fannkuchredux.rs +++ b/src/test/bench/shootout-fannkuchredux.rs @@ -56,7 +56,7 @@ fn fannkuch(n: int) -> int { ret flips; } -fn main(args: [istr]) { +fn main(args: [str]) { let n = 7; log #fmt["Pfannkuchen(%d) = %d", n, fannkuch(n)]; } diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index cd29838b378..99b06a98416 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -43,32 +43,31 @@ fn select_random(r: u32, genelist: &[aminoacids]) -> char { ret bisect(genelist, 0u, vec::len::<aminoacids>(genelist) - 1u, r); } -fn make_random_fasta(id: &istr, desc: &istr, - genelist: &[aminoacids], n: int) { - log ~">" + id + ~" " + desc; +fn make_random_fasta(id: &str, desc: &str, genelist: &[aminoacids], n: int) { + log ">" + id + " " + desc; let rng = myrandom(std::rand::mk_rng().next()); - let op: istr = ~""; + let op: str = ""; for each i: uint in uint::range(0u, n as uint) { str::push_byte(op, select_random(rng.next(100u32), genelist) as u8); - if str::byte_len(op) >= LINE_LENGTH() { log op; op = ~""; } + if str::byte_len(op) >= LINE_LENGTH() { log op; op = ""; } } if str::byte_len(op) > 0u { log op; } } -fn make_repeat_fasta(id: &istr, desc: &istr, s: &istr, n: int) { - log ~">" + id + ~" " + desc; - let op: istr = ~""; +fn make_repeat_fasta(id: &str, desc: &str, s: &str, n: int) { + log ">" + id + " " + desc; + let op: str = ""; let sl: uint = str::byte_len(s); for each i: uint in uint::range(0u, n as uint) { str::push_byte(op, s[i % sl]); - if str::byte_len(op) >= LINE_LENGTH() { log op; op = ~""; } + if str::byte_len(op) >= LINE_LENGTH() { log op; op = ""; } } if str::byte_len(op) > 0u { log op; } } fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; } -fn main(args: [istr]) { +fn main(args: [str]) { let iub: [aminoacids] = make_cumulative([acid('a', 27u32), acid('c', 12u32), acid('g', 12u32), acid('t', 27u32), acid('B', 2u32), acid('D', 2u32), @@ -78,17 +77,16 @@ fn main(args: [istr]) { let homosapiens: [aminoacids] = make_cumulative([acid('a', 30u32), acid('c', 20u32), acid('g', 20u32), acid('t', 30u32)]); - let alu: istr = - ~"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" + - ~"GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" + - ~"CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" + - ~"ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" + - ~"GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" + - ~"AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" + - ~"AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; + let alu: str = + "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" + + "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" + + "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" + + "ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA" + + "GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG" + + "AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC" + + "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; let n: int = 512; - make_repeat_fasta(~"ONE", ~"Homo sapiens alu", alu, n * 2); - make_random_fasta(~"TWO", ~"IUB ambiguity codes", iub, n * 3); - make_random_fasta(~"THREE", ~"Homo sapiens frequency", - homosapiens, n * 5); + make_repeat_fasta("ONE", "Homo sapiens alu", alu, n * 2); + make_random_fasta("TWO", "IUB ambiguity codes", iub, n * 3); + make_random_fasta("THREE", "Homo sapiens frequency", homosapiens, n * 5); } diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 6a9a5348c2e..9551aa6b982 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -49,14 +49,14 @@ fn fib(n: int) -> int { type config = {stress: bool}; -fn parse_opts(argv: &[istr]) -> config { - let opts = [getopts::optflag(~"stress")]; +fn parse_opts(argv: &[str]) -> config { + let opts = [getopts::optflag("stress")]; let opt_args = vec::slice(argv, 1u, vec::len(argv)); alt getopts::getopts(opt_args, opts) { - getopts::success(m) { ret {stress: getopts::opt_present(m, ~"stress")} } + getopts::success(m) { ret {stress: getopts::opt_present(m, "stress")} } getopts::failure(_) { fail; } } } @@ -79,7 +79,7 @@ fn stress(num_tasks: int) { for t in tasks { task::join(t); } } -fn main(argv: [istr]) { +fn main(argv: [str]) { if vec::len(argv) == 1u { assert (fib(8) == 21); log fib(8); @@ -105,9 +105,8 @@ fn main(argv: [istr]) { let elapsed = stop - start; - out.write_line( - #fmt["%d\t%d\t%s", n, fibn, - u64::str(elapsed)]); + out.write_line(#fmt["%d\t%d\t%s", n, fibn, + u64::str(elapsed)]); } } } diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index 941f0183031..ebe1abc493b 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -8,12 +8,14 @@ fn f(n: uint) { let i = 0u; while i < n { let thunk = g; - task::join(task::spawn_joinable(thunk)); i += 1u; } + task::join(task::spawn_joinable(thunk)); + i += 1u; + } } fn g() { } -fn main(args: [istr]) { +fn main(args: [str]) { let n = if vec::len(args) < 2u { 10u diff --git a/src/test/bench/task-perf-vector-party.rs b/src/test/bench/task-perf-vector-party.rs index fd650df660b..b70bd24828a 100644 --- a/src/test/bench/task-perf-vector-party.rs +++ b/src/test/bench/task-perf-vector-party.rs @@ -16,13 +16,10 @@ fn f(n: uint) { } } -fn main(args: [istr]) { - let n = if vec::len(args) < 2u { - 100u - } else { - uint::parse_buf(str::bytes(args[1]), 10u) - }; - for each i in uint::range(0u, 100u) { - task::spawn(bind f(n)); - } -} \ No newline at end of file +fn main(args: [str]) { + let n = + if vec::len(args) < 2u { + 100u + } else { uint::parse_buf(str::bytes(args[1]), 10u) }; + for each i in uint::range(0u, 100u) { task::spawn(bind f(n)); } +} diff --git a/src/test/bench/task-perf-word-count-generic.rs b/src/test/bench/task-perf-word-count-generic.rs index 3a8f643bc37..adb5040fa25 100644 --- a/src/test/bench/task-perf-word-count-generic.rs +++ b/src/test/bench/task-perf-word-count-generic.rs @@ -70,9 +70,10 @@ mod map_reduce { tag reduce_proto<~V> { emit_val(V); done; ref; release; } - fn start_mappers<~K1, ~K2, ~V>(map : mapper<K1, K2, V>, - ctrl: chan<ctrl_proto<K2, V>>, inputs: &[K1]) - -> [joinable_task] { + fn start_mappers<~K1, ~K2, + ~V>(map: mapper<K1, K2, V>, + ctrl: chan<ctrl_proto<K2, V>>, inputs: &[K1]) -> + [joinable_task] { let tasks = []; for i in inputs { let m = map, c = ctrl, ii = i; @@ -81,18 +82,18 @@ mod map_reduce { ret tasks; } - fn map_task<~K1, ~K2, ~V>(map : -mapper<K1,K2,V>, - ctrl: -chan<ctrl_proto<K2,V>>, input: -K1) { + fn map_task<~K1, ~K2, + ~V>(map: -mapper<K1, K2, V>, ctrl: -chan<ctrl_proto<K2, V>>, + input: -K1) { // log_err "map_task " + input; let intermediates = treemap::init(); - fn emit<~K2, ~V>(im: &treemap::treemap<K2, chan<reduce_proto<V>>>, - ctrl: &chan<ctrl_proto<K2,V>>, key: &K2, val: &V) { + fn emit<~K2, + ~V>(im: &treemap::treemap<K2, chan<reduce_proto<V>>>, + ctrl: &chan<ctrl_proto<K2, V>>, key: &K2, val: &V) { let c; alt treemap::find(im, key) { - some(_c) { - c = _c - } + some(_c) { c = _c } none. { let p = port(); send(ctrl, find_reducer(key, chan(p))); @@ -106,15 +107,16 @@ mod map_reduce { map(input, bind emit(intermediates, ctrl, _, _)); - fn finish<~K, ~V>(k : &K, v : &chan<reduce_proto<V>>) { + fn finish<~K, ~V>(k: &K, v: &chan<reduce_proto<V>>) { send(v, release); } treemap::traverse(intermediates, finish); send(ctrl, mapper_done); } - fn reduce_task<~K, ~V>(reduce : -reducer<K,V>, - key: -K, out: -chan<chan<reduce_proto<V>>>) { + fn reduce_task<~K, + ~V>(reduce: -reducer<K, V>, key: -K, + out: -chan<chan<reduce_proto<V>>>) { let p = port(); send(out, chan(p)); @@ -123,7 +125,7 @@ mod map_reduce { let is_done = false; fn get<~V>(p: &port<reduce_proto<V>>, ref_count: &mutable int, - is_done: &mutable bool) -> option<V> { + is_done: &mutable bool) -> option<V> { while !is_done || ref_count > 0 { alt recv(p) { emit_val(v) { @@ -144,9 +146,9 @@ mod map_reduce { reduce(key, bind get(p, ref_count, is_done)); } - fn map_reduce<~K1, ~K2, ~V>(map : mapper<K1,K2,V>, - reduce : reducer<K2, V>, - inputs: &[K1]) { + fn map_reduce<~K1, ~K2, + ~V>(map: mapper<K1, K2, V>, reduce: reducer<K2, V>, + inputs: &[K1]) { let ctrl = port(); // This task becomes the master control task. It task::_spawns @@ -177,8 +179,8 @@ mod map_reduce { let p = port(); let r = reduce, kk = k; tasks += - [task::spawn_joinable(bind reduce_task(r, - kk, chan(p)))]; + [task::spawn_joinable(bind reduce_task(r, kk, + chan(p)))]; c = recv(p); treemap::insert(reducers, k, c); } @@ -188,21 +190,18 @@ mod map_reduce { } } - fn finish<~K, ~V>(k : &K, v : &chan<reduce_proto<V>>) { - send(v, done); - } + fn finish<~K, ~V>(k: &K, v: &chan<reduce_proto<V>>) { send(v, done); } treemap::traverse(reducers, finish); for t in tasks { task::join(t); } } } -fn main(argv: [istr]) { +fn main(argv: [str]) { if vec::len(argv) < 2u { let out = io::stdout(); - out.write_line( - #fmt["Usage: %s <filename> ...", argv[0]]); + out.write_line(#fmt["Usage: %s <filename> ...", argv[0]]); // TODO: run something just to make sure the code hasn't // broken yet. This is the unit test mode of this program. @@ -227,12 +226,11 @@ fn main(argv: [istr]) { let elapsed = stop - start; elapsed /= 1000000u64; - log_err ~"MapReduce completed in " + - u64::str(elapsed) + ~"ms"; + log_err "MapReduce completed in " + u64::str(elapsed) + "ms"; } -fn read_word(r: io::reader) -> option<istr> { - let w = ~""; +fn read_word(r: io::reader) -> option<str> { + let w = ""; while !r.eof() { let c = r.read_char(); @@ -240,7 +238,7 @@ fn read_word(r: io::reader) -> option<istr> { if is_word_char(c) { w += str::from_char(c); - } else { if w != ~"" { ret some(w); } } + } else { if w != "" { ret some(w); } } } ret none; } diff --git a/src/test/bench/task-perf-word-count.rs b/src/test/bench/task-perf-word-count.rs index c62ebc73b5d..a90abd9e526 100644 --- a/src/test/bench/task-perf-word-count.rs +++ b/src/test/bench/task-perf-word-count.rs @@ -29,7 +29,7 @@ import std::comm::port; import std::comm::recv; import std::comm::send; -fn map(filename: &istr, emit: map_reduce::putter) { +fn map(filename: &str, emit: map_reduce::putter) { let f = io::file_reader(filename); @@ -38,7 +38,7 @@ fn map(filename: &istr, emit: map_reduce::putter) { } } -fn reduce(word: &istr, get: map_reduce::getter) { +fn reduce(word: &str, get: map_reduce::getter) { let count = 0; @@ -52,36 +52,36 @@ mod map_reduce { export reducer; export map_reduce; - type putter = fn(&istr, int); + type putter = fn(&str, int); - type mapper = fn(&istr, putter); + type mapper = fn(&str, putter); type getter = fn() -> option<int>; - type reducer = fn(&istr, getter); + type reducer = fn(&str, getter); tag ctrl_proto { - find_reducer(istr, chan<chan<reduce_proto>>); + find_reducer(str, chan<chan<reduce_proto>>); mapper_done; } tag reduce_proto { emit_val(int); done; ref; release; } - fn start_mappers(ctrl: chan<ctrl_proto>, inputs: &[istr]) - -> [joinable_task] { + fn start_mappers(ctrl: chan<ctrl_proto>, inputs: &[str]) -> + [joinable_task] { let tasks = []; - for i: istr in inputs { + for i: str in inputs { tasks += [task::spawn_joinable(bind map_task(ctrl, i))]; } ret tasks; } - fn map_task(ctrl: chan<ctrl_proto>, input: &istr) { + fn map_task(ctrl: chan<ctrl_proto>, input: &str) { // log_err "map_task " + input; let intermediates = map::new_str_hash(); - fn emit(im: &map::hashmap<istr, chan<reduce_proto>>, - ctrl: chan<ctrl_proto>, key: &istr, val: int) { + fn emit(im: &map::hashmap<str, chan<reduce_proto>>, + ctrl: chan<ctrl_proto>, key: &str, val: int) { let c; alt im.find(key) { some(_c) { @@ -101,7 +101,7 @@ mod map_reduce { map(input, bind emit(intermediates, ctrl, _, _)); - for each kv: @{key: istr, val: chan<reduce_proto>} in + for each kv: @{key: str, val: chan<reduce_proto>} in intermediates.items() { send(kv.val, release); } @@ -109,7 +109,7 @@ mod map_reduce { send(ctrl, mapper_done); } - fn reduce_task(key: &istr, out: chan<chan<reduce_proto>>) { + fn reduce_task(key: &str, out: chan<chan<reduce_proto>>) { let p = port(); send(out, chan(p)); @@ -139,13 +139,13 @@ mod map_reduce { reduce(key, bind get(p, ref_count, is_done)); } - fn map_reduce(inputs: &[istr]) { + fn map_reduce(inputs: &[str]) { let ctrl = port::<ctrl_proto>(); // This task becomes the master control task. It task::_spawns // to do the rest. - let reducers: map::hashmap<istr, chan<reduce_proto>>; + let reducers: map::hashmap<str, chan<reduce_proto>>; reducers = map::new_str_hash(); @@ -171,8 +171,7 @@ mod map_reduce { // log_err "creating new reducer for " + k; let p = port(); tasks += - [task::spawn_joinable( - bind reduce_task(k, chan(p)))]; + [task::spawn_joinable(bind reduce_task(k, chan(p)))]; c = recv(p); reducers.insert(k, c); } @@ -182,7 +181,7 @@ mod map_reduce { } } - for each kv: @{key: istr, val: chan<reduce_proto>} in reducers.items() + for each kv: @{key: str, val: chan<reduce_proto>} in reducers.items() { send(kv.val, done); } @@ -191,12 +190,11 @@ mod map_reduce { } } -fn main(argv: [istr]) { +fn main(argv: [str]) { if vec::len(argv) < 2u { let out = io::stdout(); - out.write_line( - #fmt["Usage: %s <filename> ...", argv[0]]); + out.write_line(#fmt["Usage: %s <filename> ...", argv[0]]); // TODO: run something just to make sure the code hasn't // broken yet. This is the unit test mode of this program. @@ -216,11 +214,11 @@ fn main(argv: [istr]) { let elapsed = stop - start; elapsed /= 1000000u64; - log_err ~"MapReduce completed in " + u64::str(elapsed) + ~"ms"; + log_err "MapReduce completed in " + u64::str(elapsed) + "ms"; } -fn read_word(r: io::reader) -> option<istr> { - let w = ~""; +fn read_word(r: io::reader) -> option<str> { + let w = ""; while !r.eof() { let c = r.read_char(); @@ -228,7 +226,7 @@ fn read_word(r: io::reader) -> option<istr> { if is_word_char(c) { w += str::from_char(c); - } else { if w != ~"" { ret some(w); } } + } else { if w != "" { ret some(w); } } } ret none; } diff --git a/src/test/compile-fail/bad-expr-path.rs b/src/test/compile-fail/bad-expr-path.rs index e3cb4873ebc..7c97308c538 100644 --- a/src/test/compile-fail/bad-expr-path.rs +++ b/src/test/compile-fail/bad-expr-path.rs @@ -2,4 +2,4 @@ mod m1 { } -fn main(args: [istr]) { log m1::a; } +fn main(args: [str]) { log m1::a; } diff --git a/src/test/compile-fail/bad-expr-path2.rs b/src/test/compile-fail/bad-expr-path2.rs index b779b459bf1..e6596f17b6e 100644 --- a/src/test/compile-fail/bad-expr-path2.rs +++ b/src/test/compile-fail/bad-expr-path2.rs @@ -4,4 +4,4 @@ mod m1 { mod a { } } -fn main(args: [istr]) { log m1::a; } +fn main(args: [str]) { log m1::a; } diff --git a/src/test/compile-fail/block-require-return.rs b/src/test/compile-fail/block-require-return.rs index 6a64bd44daa..f2796296da4 100644 --- a/src/test/compile-fail/block-require-return.rs +++ b/src/test/compile-fail/block-require-return.rs @@ -1,5 +1,3 @@ // error-pattern: not all control paths return fn force(f: &block() -> int) -> int { f() } -fn main() { - log_err force({| | }); -} +fn main() { log_err force({ | | }); } diff --git a/src/test/compile-fail/extenv-too-many-args.rs b/src/test/compile-fail/extenv-too-many-args.rs index f6fb13cbc33..945546fd6cb 100644 --- a/src/test/compile-fail/extenv-too-many-args.rs +++ b/src/test/compile-fail/extenv-too-many-args.rs @@ -1,3 +1,3 @@ // error-pattern:malformed #env call -fn main() { #env[~"one", ~"two"]; } +fn main() { #env["one", "two"]; } diff --git a/src/test/compile-fail/fn-constraint.rs b/src/test/compile-fail/fn-constraint.rs index dec1df5d458..bd6cd7b8ff1 100644 --- a/src/test/compile-fail/fn-constraint.rs +++ b/src/test/compile-fail/fn-constraint.rs @@ -5,5 +5,5 @@ import std::str::*; fn main() { let a: uint = 4u; let b: uint = 1u; - log_err safe_slice(~"kitties", a, b); + log_err safe_slice("kitties", a, b); } diff --git a/src/test/compile-fail/import.rs b/src/test/compile-fail/import.rs index 68147568cd9..f4375eaade3 100644 --- a/src/test/compile-fail/import.rs +++ b/src/test/compile-fail/import.rs @@ -4,4 +4,4 @@ import zed::baz; mod zed { fn bar() { log "bar"; } } -fn main(args: [istr]) { bar(); } +fn main(args: [str]) { bar(); } diff --git a/src/test/compile-fail/import2.rs b/src/test/compile-fail/import2.rs index 4d1043af563..89532f61fb1 100644 --- a/src/test/compile-fail/import2.rs +++ b/src/test/compile-fail/import2.rs @@ -4,4 +4,4 @@ mod baz { } mod zed { fn bar() { log "bar3"; } } -fn main(args: [istr]) { bar(); } +fn main(args: [str]) { bar(); } diff --git a/src/test/compile-fail/import3.rs b/src/test/compile-fail/import3.rs index 13b193162a3..680804c97b0 100644 --- a/src/test/compile-fail/import3.rs +++ b/src/test/compile-fail/import3.rs @@ -1,4 +1,4 @@ // error-pattern: unresolved modulename import main::bar; -fn main(args: [istr]) { log "foo"; } +fn main(args: [str]) { log "foo"; } diff --git a/src/test/compile-fail/import4.rs b/src/test/compile-fail/import4.rs index 80a540e165f..6daed215ddb 100644 --- a/src/test/compile-fail/import4.rs +++ b/src/test/compile-fail/import4.rs @@ -3,4 +3,4 @@ import zed::bar; import bar::zed; -fn main(args: [istr]) { log "loop"; } +fn main(args: [str]) { log "loop"; } diff --git a/src/test/compile-fail/no-constraint-prop.rs b/src/test/compile-fail/no-constraint-prop.rs index c01b20042fa..65e21baf78b 100644 --- a/src/test/compile-fail/no-constraint-prop.rs +++ b/src/test/compile-fail/no-constraint-prop.rs @@ -16,5 +16,5 @@ fn main() { // the next statement, since it's not true in the // prestate. let d <- a; - log safe_slice(~"kitties", b, d); + log safe_slice("kitties", b, d); } diff --git a/src/test/compile-fail/nonsense-constraints.rs b/src/test/compile-fail/nonsense-constraints.rs index 9ed12810ab5..47809cdcaf2 100644 --- a/src/test/compile-fail/nonsense-constraints.rs +++ b/src/test/compile-fail/nonsense-constraints.rs @@ -3,16 +3,11 @@ use std; import std::uint; -fn enum_chars(start:u8, end:u8) : uint::le(start, end) -> [char] { +fn enum_chars(start: u8, end: u8) : uint::le(start, end) -> [char] { let i = start; let r = []; - while (i <= end) { - r += [i as char]; - i += (1u as u8); - } + while i <= end { r += [i as char]; i += 1u as u8; } ret r; } -fn main() { - log (enum_chars('a' as u8, 'z' as u8)); -} \ No newline at end of file +fn main() { log enum_chars('a' as u8, 'z' as u8); } diff --git a/src/test/compile-fail/not-a-pred-2.rs b/src/test/compile-fail/not-a-pred-2.rs index 852db46e9df..2226c5cbf32 100644 --- a/src/test/compile-fail/not-a-pred-2.rs +++ b/src/test/compile-fail/not-a-pred-2.rs @@ -8,4 +8,5 @@ fn main() { // is not a manifest call + } diff --git a/src/test/compile-fail/zip-missing-check.rs b/src/test/compile-fail/zip-missing-check.rs index 554a670fab4..51028a03623 100644 --- a/src/test/compile-fail/zip-missing-check.rs +++ b/src/test/compile-fail/zip-missing-check.rs @@ -7,11 +7,11 @@ import std::vec::*; fn main() { let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u; // Silly, but necessary - check u8::le(a, j); - check uint::le(k, l); + check (u8::le(a, j)); + check (uint::le(k, l)); let chars = enum_chars(a, j); - let ints = enum_uints(k, l); + let ints = enum_uints(k, l); let ps = zip(chars, ints); fail "the impossible happened"; -} \ No newline at end of file +} diff --git a/src/test/compiletest/common.rs b/src/test/compiletest/common.rs index c43db38247d..ab0415fd7c1 100644 --- a/src/test/compiletest/common.rs +++ b/src/test/compiletest/common.rs @@ -16,17 +16,17 @@ type config = // for running under valgrind // Flags to pass to the compiler // Explain what's going on - {compile_lib_path: istr, - run_lib_path: istr, - rustc_path: istr, - src_base: istr, - build_base: istr, - stage_id: istr, + {compile_lib_path: str, + run_lib_path: str, + rustc_path: str, + src_base: str, + build_base: str, + stage_id: str, mode: mode, run_ignored: bool, - filter: option::t<istr>, - runtool: option::t<istr>, - rustcflags: option::t<istr>, + filter: option::t<str>, + runtool: option::t<str>, + rustcflags: option::t<str>, verbose: bool}; type cx = {config: config, procsrv: procsrv::handle}; diff --git a/src/test/compiletest/compiletest.rs b/src/test/compiletest/compiletest.rs index 5f3fd1944dd..c931369cfc7 100644 --- a/src/test/compiletest/compiletest.rs +++ b/src/test/compiletest/compiletest.rs @@ -21,58 +21,50 @@ import common::mode_pretty; import common::mode; import util::logv; -fn main(args: [istr]) { +fn main(args: [str]) { let config = parse_config(args); log_config(config); run_tests(config); } -fn parse_config(args: &[istr]) -> config { +fn parse_config(args: &[str]) -> config { let opts = - [getopts::reqopt(~"compile-lib-path"), - getopts::reqopt(~"run-lib-path"), - getopts::reqopt(~"rustc-path"), - getopts::reqopt(~"src-base"), - getopts::reqopt(~"build-base"), - getopts::reqopt(~"stage-id"), - getopts::reqopt(~"mode"), - getopts::optflag(~"ignored"), - getopts::optopt(~"runtool"), - getopts::optopt(~"rustcflags"), - getopts::optflag(~"verbose")]; + [getopts::reqopt("compile-lib-path"), getopts::reqopt("run-lib-path"), + getopts::reqopt("rustc-path"), getopts::reqopt("src-base"), + getopts::reqopt("build-base"), getopts::reqopt("stage-id"), + getopts::reqopt("mode"), getopts::optflag("ignored"), + getopts::optopt("runtool"), getopts::optopt("rustcflags"), + getopts::optflag("verbose")]; check (vec::is_not_empty(args)); let args_ = vec::tail(args); let match = alt getopts::getopts(args_, opts) { getopts::success(m) { m } - getopts::failure(f) { - fail getopts::fail_str(f) - } + getopts::failure(f) { fail getopts::fail_str(f) } }; - ret {compile_lib_path: getopts::opt_str(match, ~"compile-lib-path"), - run_lib_path: getopts::opt_str(match, ~"run-lib-path"), - rustc_path: getopts::opt_str(match, ~"rustc-path"), - src_base: getopts::opt_str(match, ~"src-base"), - build_base: getopts::opt_str(match, ~"build-base"), - stage_id: getopts::opt_str(match, ~"stage-id"), - mode: str_mode(getopts::opt_str(match, ~"mode")), - run_ignored: getopts::opt_present(match, ~"ignored"), + ret {compile_lib_path: getopts::opt_str(match, "compile-lib-path"), + run_lib_path: getopts::opt_str(match, "run-lib-path"), + rustc_path: getopts::opt_str(match, "rustc-path"), + src_base: getopts::opt_str(match, "src-base"), + build_base: getopts::opt_str(match, "build-base"), + stage_id: getopts::opt_str(match, "stage-id"), + mode: str_mode(getopts::opt_str(match, "mode")), + run_ignored: getopts::opt_present(match, "ignored"), filter: if vec::len(match.free) > 0u { option::some(match.free[0]) } else { option::none }, - runtool: getopts::opt_maybe_str(match, ~"runtool"), - rustcflags: getopts::opt_maybe_str(match, ~"rustcflags"), - verbose: getopts::opt_present(match, ~"verbose")}; + runtool: getopts::opt_maybe_str(match, "runtool"), + rustcflags: getopts::opt_maybe_str(match, "rustcflags"), + verbose: getopts::opt_present(match, "verbose")}; } fn log_config(config: &config) { let c = config; logv(c, #fmt["configuration:"]); - logv(c, #fmt["compile_lib_path: %s", - config.compile_lib_path]); + logv(c, #fmt["compile_lib_path: %s", config.compile_lib_path]); logv(c, #fmt["run_lib_path: %s", config.run_lib_path]); logv(c, #fmt["rustc_path: %s", config.rustc_path]); logv(c, #fmt["src_base: %s", config.src_base]); @@ -87,33 +79,30 @@ fn log_config(config: &config) { logv(c, #fmt["\n"]); } -fn opt_str(maybestr: option::t<istr>) -> istr { - alt maybestr { - option::some(s) { s } - option::none. { ~"(none)" } - } +fn opt_str(maybestr: option::t<str>) -> str { + alt maybestr { option::some(s) { s } option::none. { "(none)" } } } -fn str_opt(maybestr: &istr) -> option::t<istr> { - if maybestr != ~"(none)" { option::some(maybestr) } else { option::none } +fn str_opt(maybestr: &str) -> option::t<str> { + if maybestr != "(none)" { option::some(maybestr) } else { option::none } } -fn str_mode(s: &istr) -> mode { +fn str_mode(s: &str) -> mode { alt s { - ~"compile-fail" { mode_compile_fail } - ~"run-fail" { mode_run_fail } - ~"run-pass" { mode_run_pass } - ~"pretty" { mode_pretty } + "compile-fail" { mode_compile_fail } + "run-fail" { mode_run_fail } + "run-pass" { mode_run_pass } + "pretty" { mode_pretty } _ { fail "invalid mode" } } } -fn mode_str(mode: mode) -> istr { +fn mode_str(mode: mode) -> str { alt mode { - mode_compile_fail. { ~"compile-fail" } - mode_run_fail. { ~"run-fail" } - mode_run_pass. { ~"run-pass" } - mode_pretty. { ~"pretty" } + mode_compile_fail. { "compile-fail" } + mode_run_fail. { "run-fail" } + mode_run_pass. { "run-pass" } + mode_pretty. { "pretty" } } } @@ -126,13 +115,12 @@ fn run_tests(config: &config) { } fn test_opts(config: &config) -> test::test_opts { - { - filter: alt config.filter { - option::some(s) { option::some(s) } - option::none. { option::none } - }, - run_ignored: config.run_ignored - } + {filter: + alt config.filter { + option::some(s) { option::some(s) } + option::none. { option::none } + }, + run_ignored: config.run_ignored} } type tests_and_conv_fn = @@ -142,7 +130,7 @@ fn make_tests(cx: &cx) -> tests_and_conv_fn { log #fmt["making tests from %s", cx.config.src_base]; let configport = port::<[u8]>(); let tests = []; - for file: istr in fs::list_dir(cx.config.src_base) { + for file: str in fs::list_dir(cx.config.src_base) { let file = file; log #fmt["inspecting file %s", file]; if is_test(cx.config, file) { @@ -152,13 +140,11 @@ fn make_tests(cx: &cx) -> tests_and_conv_fn { ret {tests: tests, to_task: bind closure_to_task(cx, configport, _)}; } -fn is_test(config: &config, testfile: &istr) -> bool { +fn is_test(config: &config, testfile: &str) -> bool { // Pretty-printer does not work with .rc files yet - let valid_extensions = alt config.mode { - mode_pretty. { [~".rs"] } - _ { [~".rc", ~".rs"] } - }; - let invalid_prefixes = [~".", ~"#", ~"~"]; + let valid_extensions = + alt config.mode { mode_pretty. { [".rs"] } _ { [".rc", ".rs"] } }; + let invalid_prefixes = [".", "#", "~"]; let name = fs::basename(testfile); let valid = false; @@ -174,14 +160,14 @@ fn is_test(config: &config, testfile: &istr) -> bool { ret valid; } -fn make_test(cx: &cx, testfile: &istr, configport: &port<[u8]>) -> +fn make_test(cx: &cx, testfile: &str, configport: &port<[u8]>) -> test::test_desc { {name: make_test_name(cx.config, testfile), fn: make_test_closure(testfile, chan(configport)), ignore: header::is_test_ignored(cx.config, testfile)} } -fn make_test_name(config: &config, testfile: &istr) -> istr { +fn make_test_name(config: &config, testfile: &str) -> str { #fmt["[%s] %s", mode_str(config.mode), testfile] } @@ -204,12 +190,12 @@ up. Then we'll spawn that data into another task and return the task. Really convoluted. Need to think up of a better definition for tests. */ -fn make_test_closure(testfile: &istr, configchan: chan<[u8]>) -> +fn make_test_closure(testfile: &str, configchan: chan<[u8]>) -> test::test_fn { bind send_config(testfile, configchan) } -fn send_config(testfile: istr, configchan: chan<[u8]>) { +fn send_config(testfile: str, configchan: chan<[u8]>) { send(configchan, str::bytes(testfile)); } @@ -243,26 +229,17 @@ fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: &fn()) -> let chan = cx.procsrv.chan; let testthunk = - bind run_test_task(compile_lib_path, run_lib_path, - rustc_path, src_base, - build_base, stage_id, - mode, - run_ignored, - filter, - runtool, - rustcflags, - verbose, - chan, + bind run_test_task(compile_lib_path, run_lib_path, rustc_path, + src_base, build_base, stage_id, mode, run_ignored, + filter, runtool, rustcflags, verbose, chan, testfile); ret task::spawn_joinable(testthunk); } -fn run_test_task(compile_lib_path: -istr, run_lib_path: -istr, - rustc_path: -istr, - src_base: -istr, build_base: -istr, stage_id: -istr, - mode: -istr, - run_ignored: -bool, opt_filter: -istr, opt_runtool: -istr, - opt_rustcflags: -istr, verbose: -bool, +fn run_test_task(compile_lib_path: -str, run_lib_path: -str, rustc_path: -str, + src_base: -str, build_base: -str, stage_id: -str, mode: -str, + run_ignored: -bool, opt_filter: -str, opt_runtool: -str, + opt_rustcflags: -str, verbose: -bool, procsrv_chan: -procsrv::reqchan, testfile: -[u8]) { test::configure_test_task(); diff --git a/src/test/compiletest/header.rs b/src/test/compiletest/header.rs index d891e87f5dd..8a03378742b 100644 --- a/src/test/compiletest/header.rs +++ b/src/test/compiletest/header.rs @@ -11,24 +11,24 @@ export is_test_ignored; type test_props = { // Lines that should be expected, in order, on standard out - error_patterns: [istr], + error_patterns: [str], // Extra flags to pass to the compiler - compile_flags: option::t<istr>, + compile_flags: option::t<str>, // If present, the name of a file that this test should match when // pretty-printed - pp_exact: option::t<istr>, + pp_exact: option::t<str>, // FIXME: no-valgrind is a temporary directive until all of run-fail // is valgrind-clean no_valgrind: bool }; // Load any test directives embedded in the file -fn load_props(testfile: &istr) -> test_props { +fn load_props(testfile: &str) -> test_props { let error_patterns = []; let compile_flags = option::none; let pp_exact = option::none; let no_valgrind = false; - for each ln: istr in iter_header(testfile) { + for each ln: str in iter_header(testfile) { alt parse_error_pattern(ln) { option::some(ep) { error_patterns += [ep]; } option::none. { } @@ -43,7 +43,7 @@ fn load_props(testfile: &istr) -> test_props { } if no_valgrind == false { - no_valgrind = parse_name_directive(ln, ~"no-valgrind"); + no_valgrind = parse_name_directive(ln, "no-valgrind"); } } ret { @@ -54,19 +54,19 @@ fn load_props(testfile: &istr) -> test_props { }; } -fn is_test_ignored(config: &config, testfile: &istr) -> bool { +fn is_test_ignored(config: &config, testfile: &str) -> bool { let found = false; - for each ln: istr in iter_header(testfile) { + for each ln: str in iter_header(testfile) { // FIXME: Can't return or break from iterator - found = found || parse_name_directive(ln, ~"xfail-test"); + found = found || parse_name_directive(ln, "xfail-test"); if (config.mode == common::mode_pretty) { - found = found || parse_name_directive(ln, ~"xfail-pretty"); + found = found || parse_name_directive(ln, "xfail-pretty"); } } ret found; } -iter iter_header(testfile: &istr) -> istr { +iter iter_header(testfile: &str) -> str { let rdr = io::file_reader(testfile); while !rdr.eof() { let ln = rdr.read_line(); @@ -74,26 +74,26 @@ iter iter_header(testfile: &istr) -> istr { // Assume that any directives will be found before the first // module or function. This doesn't seem to be an optimization // with a warm page cache. Maybe with a cold one. - if str::starts_with(ln, ~"fn") - || str::starts_with(ln, ~"mod") { + if str::starts_with(ln, "fn") + || str::starts_with(ln, "mod") { break; } else { put ln; } } } -fn parse_error_pattern(line: &istr) -> option::t<istr> { - parse_name_value_directive(line, ~"error-pattern") +fn parse_error_pattern(line: &str) -> option::t<str> { + parse_name_value_directive(line, "error-pattern") } -fn parse_compile_flags(line: &istr) -> option::t<istr> { - parse_name_value_directive(line, ~"compile-flags") +fn parse_compile_flags(line: &str) -> option::t<str> { + parse_name_value_directive(line, "compile-flags") } -fn parse_pp_exact(line: &istr, testfile: &istr) -> option::t<istr> { - alt parse_name_value_directive(line, ~"pp-exact") { +fn parse_pp_exact(line: &str, testfile: &str) -> option::t<str> { + alt parse_name_value_directive(line, "pp-exact") { option::some(s) { option::some(s) } option::none. { - if parse_name_directive(line, ~"pp-exact") { + if parse_name_directive(line, "pp-exact") { option::some(fs::basename(testfile)) } else { option::none @@ -102,13 +102,13 @@ fn parse_pp_exact(line: &istr, testfile: &istr) -> option::t<istr> { } } -fn parse_name_directive(line: &istr, directive: &istr) -> bool { +fn parse_name_directive(line: &str, directive: &str) -> bool { str::find(line, directive) >= 0 } -fn parse_name_value_directive(line: &istr, - directive: &istr) -> option::t<istr> { - let keycolon = directive + ~":"; +fn parse_name_value_directive(line: &str, + directive: &str) -> option::t<str> { + let keycolon = directive + ":"; if str::find(line, keycolon) >= 0 { let colon = str::find(line, keycolon) as uint; let value = diff --git a/src/test/compiletest/procsrv.rs b/src/test/compiletest/procsrv.rs index eb6d4676711..63a3807f6a5 100644 --- a/src/test/compiletest/procsrv.rs +++ b/src/test/compiletest/procsrv.rs @@ -27,8 +27,9 @@ export reqchan; type reqchan = chan<request>; -type handle = {task: option::t<(task::task, port<task::task_notification>)>, - chan: reqchan}; +type handle = + {task: option::t<(task::task, port<task::task_notification>)>, + chan: reqchan}; tag request { exec([u8], [u8], [[u8]], chan<response>); stop; } @@ -38,11 +39,11 @@ fn mk() -> handle { let setupport = port(); let task = task::spawn_joinable(bind fn (setupchan: chan<chan<request>>) { - let reqport = port(); - let reqchan = chan(reqport); - send(setupchan, reqchan); - worker(reqport); - }(chan(setupport))); + let reqport = port(); + let reqchan = chan(reqport); + send(setupchan, reqchan); + worker(reqport); + }(chan(setupport))); ret {task: option::some(task), chan: recv(setupport)}; } @@ -53,8 +54,8 @@ fn close(handle: &handle) { task::join(option::get(handle.task)); } -fn run(handle: &handle, lib_path: &istr, prog: &istr, args: &[istr], - input: &option::t<istr>) -> {status: int, out: istr, err: istr} { +fn run(handle: &handle, lib_path: &str, prog: &str, args: &[str], + input: &option::t<str>) -> {status: int, out: str, err: str} { let p = port(); let ch = chan(p); send(handle.chan, @@ -69,7 +70,7 @@ fn run(handle: &handle, lib_path: &istr, prog: &istr, args: &[istr], ret {status: status, out: output, err: errput}; } -fn writeclose(fd: int, s: &option::t<istr>) { +fn writeclose(fd: int, s: &option::t<str>) { if option::is_some(s) { let writer = io::new_writer(io::fd_buf_writer(fd, option::none)); writer.write_str(option::get(s)); @@ -78,11 +79,11 @@ fn writeclose(fd: int, s: &option::t<istr>) { os::libc::close(fd); } -fn readclose(fd: int) -> istr { +fn readclose(fd: int) -> str { // Copied from run::program_output let file = os::fd_FILE(fd); let reader = io::new_reader(io::FILE_buf_reader(file, option::none)); - let buf = ~""; + let buf = ""; while !reader.eof() { let bytes = reader.read_bytes(4096u); buf += str::unsafe_from_bytes(bytes); @@ -128,8 +129,7 @@ fn worker(p: port<request>) { let pipe_out = os::pipe(); let pipe_err = os::pipe(); let spawnproc = - bind run::spawn_process(execparms.prog, - execparms.args, + bind run::spawn_process(execparms.prog, execparms.args, pipe_in.in, pipe_out.out, pipe_err.out); let pid = with_lib_path(execparms.lib_path, spawnproc); @@ -151,7 +151,7 @@ fn worker(p: port<request>) { } } -fn with_lib_path<@T>(path: &istr, f: fn() -> T) -> T { +fn with_lib_path<@T>(path: &str, f: fn() -> T) -> T { let maybe_oldpath = getenv(util::lib_path_env_var()); append_lib_path(path); let res = f(); @@ -159,26 +159,22 @@ fn with_lib_path<@T>(path: &istr, f: fn() -> T) -> T { export_lib_path(option::get(maybe_oldpath)); } else { // FIXME: This should really be unset but we don't have that yet - export_lib_path(~""); + export_lib_path(""); } ret res; } -fn append_lib_path(path: &istr) { - export_lib_path(util::make_new_path(path)); -} +fn append_lib_path(path: &str) { export_lib_path(util::make_new_path(path)); } -fn export_lib_path(path: &istr) { - setenv(util::lib_path_env_var(), path); -} +fn export_lib_path(path: &str) { setenv(util::lib_path_env_var(), path); } -fn clone_vecstr(v: &[istr]) -> [[u8]] { +fn clone_vecstr(v: &[str]) -> [[u8]] { let r = []; - for t: istr in vec::slice(v, 0u, vec::len(v)) { r += [str::bytes(t)]; } + for t: str in vec::slice(v, 0u, vec::len(v)) { r += [str::bytes(t)]; } ret r; } -fn clone_vecu8str(v: &[[u8]]) -> [istr] { +fn clone_vecu8str(v: &[[u8]]) -> [str] { let r = []; for t in vec::slice(v, 0u, vec::len(v)) { r += [str::unsafe_from_bytes(t)]; diff --git a/src/test/compiletest/runtest.rs b/src/test/compiletest/runtest.rs index 9128160855b..87ae7750e03 100644 --- a/src/test/compiletest/runtest.rs +++ b/src/test/compiletest/runtest.rs @@ -22,7 +22,7 @@ fn run(cx: &cx, _testfile: -[u8]) { let testfile = str::unsafe_from_bytes(_testfile); if cx.config.verbose { // We're going to be dumping a lot of info. Start on a new line. - io::stdout().write_str(~"\n\n"); + io::stdout().write_str("\n\n"); } log #fmt["running %s", testfile]; let props = load_props(testfile); @@ -34,25 +34,25 @@ fn run(cx: &cx, _testfile: -[u8]) { } } -fn run_cfail_test(cx: &cx, props: &test_props, testfile: &istr) { +fn run_cfail_test(cx: &cx, props: &test_props, testfile: &str) { let procres = compile_test(cx, props, testfile); if procres.status == 0 { - fatal_procres(~"compile-fail test compiled successfully!", procres); + fatal_procres("compile-fail test compiled successfully!", procres); } check_error_patterns(props, testfile, procres); } -fn run_rfail_test(cx: &cx, props: &test_props, testfile: &istr) { +fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) { let procres = compile_test(cx, props, testfile); - if procres.status != 0 { fatal_procres(~"compilation failed!", procres); } + if procres.status != 0 { fatal_procres("compilation failed!", procres); } procres = exec_compiled_test(cx, props, testfile); if procres.status == 0 { - fatal_procres(~"run-fail test didn't produce an error!", procres); + fatal_procres("run-fail test didn't produce an error!", procres); } // This is the value valgrind returns on failure @@ -61,27 +61,27 @@ fn run_rfail_test(cx: &cx, props: &test_props, testfile: &istr) { // exit code on the command-line (137)? const valgrind_err: int = 9; if procres.status == valgrind_err { - fatal_procres(~"run-fail test isn't valgrind-clean!", procres); + fatal_procres("run-fail test isn't valgrind-clean!", procres); } check_error_patterns(props, testfile, procres); } -fn run_rpass_test(cx: &cx, props: &test_props, testfile: &istr) { +fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) { let procres = compile_test(cx, props, testfile); - if procres.status != 0 { fatal_procres(~"compilation failed!", procres); } + if procres.status != 0 { fatal_procres("compilation failed!", procres); } procres = exec_compiled_test(cx, props, testfile); - if procres.status != 0 { fatal_procres(~"test run failed!", procres); } + if procres.status != 0 { fatal_procres("test run failed!", procres); } } -fn run_pretty_test(cx: &cx, props: &test_props, testfile: &istr) { +fn run_pretty_test(cx: &cx, props: &test_props, testfile: &str) { if option::is_some(props.pp_exact) { - logv(cx.config, ~"testing for exact pretty-printing"); - } else { logv(cx.config, ~"testing for converging pretty-printing"); } + logv(cx.config, "testing for exact pretty-printing"); + } else { logv(cx.config, "testing for converging pretty-printing"); } let rounds = alt props.pp_exact { option::some(_) { 1 } option::none. { 2 } }; @@ -94,9 +94,8 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &istr) { let procres = print_source(cx, testfile, srcs[round]); if procres.status != 0 { - fatal_procres( - #fmt["pretty-printing failed in round %d", round], - procres); + fatal_procres(#fmt["pretty-printing failed in round %d", round], + procres); } srcs += [procres.stdout]; @@ -115,10 +114,10 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &istr) { if option::is_some(props.pp_exact) { // Now we have to care about line endings - let cr = ~"\r"; + let cr = "\r"; check (str::is_not_empty(cr)); - actual = str::replace(actual, cr, ~""); - expected = str::replace(expected, cr, ~""); + actual = str::replace(actual, cr, ""); + expected = str::replace(expected, cr, ""); } compare_source(expected, actual); @@ -127,25 +126,25 @@ fn run_pretty_test(cx: &cx, props: &test_props, testfile: &istr) { let procres = typecheck_source(cx, testfile, actual); if procres.status != 0 { - fatal_procres(~"pretty-printed source does not typecheck", procres); + fatal_procres("pretty-printed source does not typecheck", procres); } ret; - fn print_source(cx: &cx, testfile: &istr, src: &istr) -> procres { + fn print_source(cx: &cx, testfile: &str, src: &str) -> procres { compose_and_run(cx, testfile, make_pp_args, cx.config.compile_lib_path, option::some(src)) } - fn make_pp_args(config: &config, _testfile: &istr) -> procargs { + fn make_pp_args(config: &config, _testfile: &str) -> procargs { let prog = config.rustc_path; - let args = [~"-", ~"--pretty", ~"normal"]; + let args = ["-", "--pretty", "normal"]; ret {prog: prog, args: args}; } - fn compare_source(expected: &istr, actual: &istr) { + fn compare_source(expected: &str, actual: &str) { if expected != actual { - error(~"pretty-printed source does match expected source"); + error("pretty-printed source does match expected source"); let msg = #fmt["\n\ expected:\n\ @@ -157,41 +156,39 @@ actual:\n\ %s\n\ ------------------------------------------\n\ \n", - expected, - actual]; + expected, actual]; io::stdout().write_str(msg); fail; } } - fn typecheck_source(cx: &cx, testfile: &istr, src: &istr) -> procres { + fn typecheck_source(cx: &cx, testfile: &str, src: &str) -> procres { compose_and_run(cx, testfile, make_typecheck_args, cx.config.compile_lib_path, option::some(src)) } - fn make_typecheck_args(config: &config, _testfile: &istr) -> procargs { + fn make_typecheck_args(config: &config, _testfile: &str) -> procargs { let prog = config.rustc_path; - let args = [~"-", ~"--no-trans", ~"--lib"]; + let args = ["-", "--no-trans", "--lib"]; ret {prog: prog, args: args}; } } -fn check_error_patterns(props: &test_props, testfile: &istr, +fn check_error_patterns(props: &test_props, testfile: &str, procres: &procres) { if vec::is_empty(props.error_patterns) { - fatal(~"no error pattern specified in " + testfile); + fatal("no error pattern specified in " + testfile); } if procres.status == 0 { - fatal(~"process did not return an error status"); + fatal("process did not return an error status"); } let next_err_idx = 0u; let next_err_pat = props.error_patterns[next_err_idx]; - for line: istr in str::split(procres.stdout, '\n' as u8) { + for line: str in str::split(procres.stdout, '\n' as u8) { if str::find(line, next_err_pat) > 0 { - log #fmt["found error pattern %s", - next_err_pat]; + log #fmt["found error pattern %s", next_err_pat]; next_err_idx += 1u; if next_err_idx == vec::len(props.error_patterns) { log "found all error patterns"; @@ -205,83 +202,83 @@ fn check_error_patterns(props: &test_props, testfile: &istr, vec::slice(props.error_patterns, next_err_idx, vec::len(props.error_patterns)); if vec::len(missing_patterns) == 1u { - fatal_procres( - #fmt["error pattern '%s' not found!", - missing_patterns[0]], procres); + fatal_procres(#fmt["error pattern '%s' not found!", + missing_patterns[0]], procres); } else { - for pattern: istr in missing_patterns { - error(#fmt["error pattern '%s' not found!", - pattern]); + for pattern: str in missing_patterns { + error(#fmt["error pattern '%s' not found!", pattern]); } - fatal_procres(~"multiple error patterns not found", procres); + fatal_procres("multiple error patterns not found", procres); } } -type procargs = {prog: istr, args: [istr]}; +type procargs = {prog: str, args: [str]}; -type procres = {status: int, stdout: istr, stderr: istr, cmdline: istr}; +type procres = {status: int, stdout: str, stderr: str, cmdline: str}; -fn compile_test(cx: &cx, props: &test_props, testfile: &istr) -> procres { +fn compile_test(cx: &cx, props: &test_props, testfile: &str) -> procres { compose_and_run(cx, testfile, bind make_compile_args(_, props, _), cx.config.compile_lib_path, option::none) } -fn exec_compiled_test(cx: &cx, props: &test_props, testfile: &istr) -> +fn exec_compiled_test(cx: &cx, props: &test_props, testfile: &str) -> procres { compose_and_run(cx, testfile, bind make_run_args(_, props, _), cx.config.run_lib_path, option::none) } -fn compose_and_run(cx: &cx, testfile: &istr, - make_args: fn(&config, &istr) -> procargs, - lib_path: &istr, - input: option::t<istr>) -> procres { +fn compose_and_run(cx: &cx, testfile: &str, + make_args: fn(&config, &str) -> procargs, lib_path: &str, + input: option::t<str>) -> procres { let procargs = make_args(cx.config, testfile); ret program_output(cx, testfile, lib_path, procargs.prog, procargs.args, input); } -fn make_compile_args(config: &config, props: &test_props, testfile: &istr) -> +fn make_compile_args(config: &config, props: &test_props, testfile: &str) -> procargs { let prog = config.rustc_path; - let args = [testfile, ~"-o", make_exe_name(config, testfile)]; - let rustcflags = alt config.rustcflags { - option::some(s) { option::some(s) } - option::none. { option::none } - }; + let args = [testfile, "-o", make_exe_name(config, testfile)]; + let rustcflags = + alt config.rustcflags { + option::some(s) { option::some(s) } + option::none. { option::none } + }; args += split_maybe_args(rustcflags); args += split_maybe_args(props.compile_flags); ret {prog: prog, args: args}; } -fn make_exe_name(config: &config, testfile: &istr) -> istr { +fn make_exe_name(config: &config, testfile: &str) -> str { output_base_name(config, testfile) + os::exec_suffix() } -fn make_run_args(config: &config, props: &test_props, testfile: &istr) -> +fn make_run_args(config: &config, props: &test_props, testfile: &str) -> procargs { - let toolargs = if !props.no_valgrind { - // If we've got another tool to run under (valgrind), - // then split apart its command - let runtool = alt config.runtool { - option::some(s) { option::some(s) } - option::none. { option::none } - }; - split_maybe_args(runtool) - } else { [] }; + let toolargs = + if !props.no_valgrind { + // If we've got another tool to run under (valgrind), + // then split apart its command + let runtool = + alt config.runtool { + option::some(s) { option::some(s) } + option::none. { option::none } + }; + split_maybe_args(runtool) + } else { [] }; let args = toolargs + [make_exe_name(config, testfile)]; ret {prog: args[0], args: vec::slice(args, 1u, vec::len(args))}; } -fn split_maybe_args(argstr: &option::t<istr>) -> [istr] { - fn rm_whitespace(v: &[istr]) -> [istr] { - fn flt(s: &istr) -> option::t<istr> { +fn split_maybe_args(argstr: &option::t<str>) -> [str] { + fn rm_whitespace(v: &[str]) -> [str] { + fn flt(s: &str) -> option::t<str> { if !is_whitespace(s) { option::some(s) } else { option::none } } // FIXME: This should be in std - fn is_whitespace(s: &istr) -> bool { + fn is_whitespace(s: &str) -> bool { for c: u8 in s { if c != ' ' as u8 { ret false; } } ret true; } @@ -294,13 +291,12 @@ fn split_maybe_args(argstr: &option::t<istr>) -> [istr] { } } -fn program_output(cx: &cx, testfile: &istr, lib_path: &istr, prog: &istr, - args: &[istr], input: option::t<istr>) -> procres { +fn program_output(cx: &cx, testfile: &str, lib_path: &str, prog: &str, + args: &[str], input: option::t<str>) -> procres { let cmdline = { let cmdline = make_cmdline(lib_path, prog, args); - logv(cx.config, #fmt["executing %s", - cmdline]); + logv(cx.config, #fmt["executing %s", cmdline]); cmdline }; let res = procsrv::run(cx.procsrv, lib_path, prog, args, input); @@ -311,66 +307,58 @@ fn program_output(cx: &cx, testfile: &istr, lib_path: &istr, prog: &istr, cmdline: cmdline}; } -fn make_cmdline(libpath: &istr, prog: &istr, args: &[istr]) -> istr { - #fmt["%s %s %s", - lib_path_cmd_prefix(libpath), - prog, - str::connect(args, ~" ")] +fn make_cmdline(libpath: &str, prog: &str, args: &[str]) -> str { + #fmt["%s %s %s", lib_path_cmd_prefix(libpath), prog, + str::connect(args, " ")] } // Build the LD_LIBRARY_PATH variable as it would be seen on the command line // for diagnostic purposes -fn lib_path_cmd_prefix(path: &istr) -> istr { - #fmt["%s=\"%s\"", - util::lib_path_env_var(), - util::make_new_path(path)] +fn lib_path_cmd_prefix(path: &str) -> str { + #fmt["%s=\"%s\"", util::lib_path_env_var(), util::make_new_path(path)] } -fn dump_output(config: &config, testfile: &istr, out: &istr, err: &istr) { - dump_output_file(config, testfile, out, ~"out"); - dump_output_file(config, testfile, err, ~"err"); +fn dump_output(config: &config, testfile: &str, out: &str, err: &str) { + dump_output_file(config, testfile, out, "out"); + dump_output_file(config, testfile, err, "err"); maybe_dump_to_stdout(config, out, err); } #[cfg(target_os = "win32")] #[cfg(target_os = "linux")] -fn dump_output_file(config: &config, testfile: &istr, out: &istr, - extension: &istr) { +fn dump_output_file(config: &config, testfile: &str, out: &str, + extension: &str) { let outfile = make_out_name(config, testfile, extension); - let writer = io::file_writer(outfile, - [io::create, io::truncate]); + let writer = io::file_writer(outfile, [io::create, io::truncate]); writer.write_str(out); } // FIXME (726): Can't use file_writer on mac #[cfg(target_os = "macos")] -fn dump_output_file(config: &config, testfile: &istr, out: &istr, - extension: &istr) { +fn dump_output_file(config: &config, testfile: &str, out: &str, + extension: &str) { } -fn make_out_name(config: &config, testfile: &istr, - extension: &istr) -> istr { - output_base_name(config, testfile) + ~"." + extension +fn make_out_name(config: &config, testfile: &str, extension: &str) -> str { + output_base_name(config, testfile) + "." + extension } -fn output_base_name(config: &config, testfile: &istr) -> istr { +fn output_base_name(config: &config, testfile: &str) -> str { let base = config.build_base; let filename = { - let parts = str::split(fs::basename(testfile), - '.' as u8); + let parts = str::split(fs::basename(testfile), '.' as u8); parts = vec::slice(parts, 0u, vec::len(parts) - 1u); - str::connect(parts, ~".") + str::connect(parts, ".") }; - #fmt["%s%s.%s", base, filename, - config.stage_id] + #fmt["%s%s.%s", base, filename, config.stage_id] } -fn maybe_dump_to_stdout(config: &config, out: &istr, err: &istr) { +fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) { if config.verbose { - let sep1 = #fmt["------%s------------------------------", ~"stdout"]; - let sep2 = #fmt["------%s------------------------------", ~"stderr"]; - let sep3 = ~"------------------------------------------"; + let sep1 = #fmt["------%s------------------------------", "stdout"]; + let sep2 = #fmt["------%s------------------------------", "stderr"]; + let sep3 = "------------------------------------------"; io::stdout().write_line(sep1); io::stdout().write_line(out); io::stdout().write_line(sep2); @@ -379,13 +367,11 @@ fn maybe_dump_to_stdout(config: &config, out: &istr, err: &istr) { } } -fn error(err: &istr) { - io::stdout().write_line(#fmt["\nerror: %s", err]); -} +fn error(err: &str) { io::stdout().write_line(#fmt["\nerror: %s", err]); } -fn fatal(err: &istr) -> ! { error(err); fail; } +fn fatal(err: &str) -> ! { error(err); fail; } -fn fatal_procres(err: &istr, procres: procres) -> ! { +fn fatal_procres(err: &str, procres: procres) -> ! { let msg = #fmt["\n\ error: %s\n\ @@ -399,10 +385,7 @@ stderr:\n\ %s\n\ ------------------------------------------\n\ \n", - err, - procres.cmdline, - procres.stdout, - procres.stderr]; + err, procres.cmdline, procres.stdout, procres.stderr]; io::stdout().write_str(msg); fail; } diff --git a/src/test/compiletest/util.rs b/src/test/compiletest/util.rs index b15e16b5d4d..769b409ea43 100644 --- a/src/test/compiletest/util.rs +++ b/src/test/compiletest/util.rs @@ -5,29 +5,26 @@ import std::str; import common::config; -fn make_new_path(path: &istr) -> istr { +fn make_new_path(path: &str) -> str { // Windows just uses PATH as the library search path, so we have to // maintain the current value while adding our own alt getenv(lib_path_env_var()) { - option::some(curr) { - #fmt["%s:%s", path, curr] } + option::some(curr) { #fmt["%s:%s", path, curr] } option::none. { path } } } #[cfg(target_os = "linux")] -fn lib_path_env_var() -> istr { ~"LD_LIBRARY_PATH" } +fn lib_path_env_var() -> str { "LD_LIBRARY_PATH" } #[cfg(target_os = "macos")] -fn lib_path_env_var() -> istr { ~"DYLD_LIBRARY_PATH" } +fn lib_path_env_var() -> str { "DYLD_LIBRARY_PATH" } #[cfg(target_os = "win32")] -fn lib_path_env_var() -> istr { ~"PATH" } +fn lib_path_env_var() -> str { "PATH" } -fn logv(config: &config, s: &istr) { +fn logv(config: &config, s: &str) { log s; - if config.verbose { - io::stdout().write_line(s); - } + if config.verbose { io::stdout().write_line(s); } } diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index 56937260b54..b45e443759c 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -1,3 +1,3 @@ // error-pattern:wooooo // no-valgrind -fn main() { let a = 1; if 1 == 1 { a = 2; } fail ~"woooo" + ~"o"; } +fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; } diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 2791db07446..90256271fd2 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -2,4 +2,4 @@ // no-valgrind use std; -fn main() { let str_var: istr = ~"meh"; fail #fmt["%s", str_var]; } +fn main() { let str_var: str = "meh"; fail #fmt["%s", str_var]; } diff --git a/src/test/run-fail/fn-constraint.rs b/src/test/run-fail/fn-constraint.rs index f55772d2def..3499d44ceff 100644 --- a/src/test/run-fail/fn-constraint.rs +++ b/src/test/run-fail/fn-constraint.rs @@ -7,5 +7,5 @@ fn main() { let a: uint = 4u; let b: uint = 1u; check (le(a, b)); - log_err safe_slice(~"kitties", a, b); + log_err safe_slice("kitties", a, b); } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 95991e31243..dcc86fdd3c9 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -9,12 +9,12 @@ import std::vec::*; fn main() { let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 9u; // Silly, but necessary - check u8::le(a, j); - check uint::le(k, l); + check (u8::le(a, j)); + check (uint::le(k, l)); let chars = enum_chars(a, j); - let ints = enum_uints(k, l); + let ints = enum_uints(k, l); - check same_length(chars, ints); + check (same_length(chars, ints)); let ps = zip(chars, ints); fail "the impossible happened"; -} \ No newline at end of file +} diff --git a/src/test/run-pass/alt-str.rs b/src/test/run-pass/alt-str.rs index 57e68552e80..e51263db804 100644 --- a/src/test/run-pass/alt-str.rs +++ b/src/test/run-pass/alt-str.rs @@ -1,31 +1,21 @@ // Issue #53 fn main() { - alt ~"test" { - ~"not-test" { fail; } - ~"test" { } - _ { fail; } - } + alt "test" { "not-test" { fail; } "test" { } _ { fail; } } - tag t { tag1(istr); tag2; } + tag t { tag1(str); tag2; } - alt tag1(~"test") { + alt tag1("test") { tag2. { fail; } - tag1(~"not-test") { fail; } - tag1(~"test") { } + tag1("not-test") { fail; } + tag1("test") { } _ { fail; } } - let x = alt ~"a" { - ~"a" { 1 } - ~"b" { 2 } - }; - assert x == 1; + let x = alt "a" { "a" { 1 } "b" { 2 } }; + assert (x == 1); - alt ~"a" { - ~"a" { } - ~"b" { } - } + alt "a" { "a" { } "b" { } } } diff --git a/src/test/run-pass/argv.rs b/src/test/run-pass/argv.rs index 4ed753c8333..0bb536086ba 100644 --- a/src/test/run-pass/argv.rs +++ b/src/test/run-pass/argv.rs @@ -1,5 +1,5 @@ -fn main(args: [istr]) { - let vs: [istr] = [~"hi", ~"there", ~"this", ~"is", ~"a", ~"vec"]; - let vvs: [[istr]] = [args, vs]; - for vs: [istr] in vvs { for s: istr in vs { log s; } } +fn main(args: [str]) { + let vs: [str] = ["hi", "there", "this", "is", "a", "vec"]; + let vvs: [[str]] = [args, vs]; + for vs: [str] in vvs { for s: str in vs { log s; } } } diff --git a/src/test/run-pass/bug-862.rs b/src/test/run-pass/bug-862.rs index e3cddda3f8a..0c4c49a0a3d 100644 --- a/src/test/run-pass/bug-862.rs +++ b/src/test/run-pass/bug-862.rs @@ -4,8 +4,4 @@ fn f(i: int, j: int) : p(j) -> int { j } fn g(i: int, j: int) : p(j) -> int { f(i, j) } -fn main() { - let x = 1; - check p(x); - log g(x, x); -} \ No newline at end of file +fn main() { let x = 1; check (p(x)); log g(x, x); } diff --git a/src/test/run-pass/check-pattern-bound.rs b/src/test/run-pass/check-pattern-bound.rs index 0ebaf84b96d..32c6ac2475b 100644 --- a/src/test/run-pass/check-pattern-bound.rs +++ b/src/test/run-pass/check-pattern-bound.rs @@ -1,16 +1,10 @@ use std; import std::option::*; -pure fn p(x:int) -> bool { true } +pure fn p(x: int) -> bool { true } -fn f(x:int) : p(x) { } +fn f(x: int) : p(x) { } fn main() { - alt some(5) { - some(y) { - check p(y); - f(y); - } - _ { fail "yuck"; } - } + alt some(5) { some(y) { check (p(y)); f(y); } _ { fail "yuck"; } } } diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index c902809e447..9a54dbd5c90 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -3,6 +3,6 @@ use std; import std::task; -fn child2(s: -istr) { } +fn child2(s: -str) { } -fn main() { let x = task::spawn(bind child2(~"hi")); } +fn main() { let x = task::spawn(bind child2("hi")); } diff --git a/src/test/run-pass/command-line-args.rs b/src/test/run-pass/command-line-args.rs index b044af7d839..efd5d2bb04c 100644 --- a/src/test/run-pass/command-line-args.rs +++ b/src/test/run-pass/command-line-args.rs @@ -1,3 +1,3 @@ -fn main(args: [istr]) { log args[0]; } +fn main(args: [str]) { log args[0]; } diff --git a/src/test/run-pass/constraint-prop-expr-move.rs b/src/test/run-pass/constraint-prop-expr-move.rs index a8f4f976872..56ebc914b93 100644 --- a/src/test/run-pass/constraint-prop-expr-move.rs +++ b/src/test/run-pass/constraint-prop-expr-move.rs @@ -8,5 +8,5 @@ fn main() { let c: uint = 17u; check (le(a, b)); c <- a; - log safe_slice(~"kitties", c, b); + log safe_slice("kitties", c, b); } diff --git a/src/test/run-pass/constraint-prop-move.rs b/src/test/run-pass/constraint-prop-move.rs index b691fb75dbd..97285adae0c 100644 --- a/src/test/run-pass/constraint-prop-move.rs +++ b/src/test/run-pass/constraint-prop-move.rs @@ -7,5 +7,5 @@ fn main() { let b: uint = 4u; check (le(a, b)); let c <- a; - log safe_slice(~"kitties", c, b); + log safe_slice("kitties", c, b); } diff --git a/src/test/run-pass/constraint-prop-swap.rs b/src/test/run-pass/constraint-prop-swap.rs index 5814f095f66..7b96a89bb16 100644 --- a/src/test/run-pass/constraint-prop-swap.rs +++ b/src/test/run-pass/constraint-prop-swap.rs @@ -7,5 +7,5 @@ fn main() { let b: uint = 1u; check (le(b, a)); b <-> a; - log safe_slice(~"kitties", a, b); + log safe_slice("kitties", a, b); } diff --git a/src/test/run-pass/constraint-prop.rs b/src/test/run-pass/constraint-prop.rs index c0a5903f69c..71f151f5260 100644 --- a/src/test/run-pass/constraint-prop.rs +++ b/src/test/run-pass/constraint-prop.rs @@ -7,5 +7,5 @@ fn main() { let b: uint = 4u; check (le(a, b)); let c = b; - log safe_slice(~"kitties", a, c); + log safe_slice("kitties", a, c); } diff --git a/src/test/run-pass/fn-constraint.rs b/src/test/run-pass/fn-constraint.rs index 5e2dac48eab..f9ea572a735 100644 --- a/src/test/run-pass/fn-constraint.rs +++ b/src/test/run-pass/fn-constraint.rs @@ -6,5 +6,5 @@ fn main() { let a: uint = 1u; let b: uint = 4u; check (le(a, b)); - log safe_slice(~"kitties", a, b); + log safe_slice("kitties", a, b); } diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 49e7fd3b7fe..2da4a0296fd 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -1,16 +1,13 @@ fn main() { - let a = alt 10 { - x when x < 7 { 1 } - x when x < 11 { 2 } - 10 { 3 } - _ { 4 } - }; - assert a == 2; + let a = + alt 10 { x when x < 7 { 1 } x when x < 11 { 2 } 10 { 3 } _ { 4 } }; + assert (a == 2); - let b = alt {x: 10, y: 20} { - x when x.x < 5 && x.y < 5 { 1 } - {x, y} when x == 10 && y == 20 { 2 } - {x, y} { 3 } - }; - assert b == 2; + let b = + alt {x: 10, y: 20} { + x when x.x < 5 && x.y < 5 { 1 } + {x: x, y: y} when x == 10 && y == 20 { 2 } + {x: x, y: y} { 3 } + }; + assert (b == 2); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 81c827bfb22..6d5203f4884 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -19,31 +19,29 @@ import std::comm::send; import std::comm::recv; import std::comm; -fn map(filename: &istr, emit: map_reduce::putter) { emit(filename, ~"1"); } +fn map(filename: &str, emit: map_reduce::putter) { emit(filename, "1"); } mod map_reduce { export putter; export mapper; export map_reduce; - type putter = fn(&istr, &istr); + type putter = fn(&str, &str); - type mapper = fn(&istr, putter); + type mapper = fn(&str, putter); tag ctrl_proto { find_reducer([u8], chan<int>); mapper_done; } - fn start_mappers(ctrl: chan<ctrl_proto>, inputs: &[istr]) { - for i: istr in inputs { - task::spawn(bind map_task(ctrl, i)); - } + fn start_mappers(ctrl: chan<ctrl_proto>, inputs: &[str]) { + for i: str in inputs { task::spawn(bind map_task(ctrl, i)); } } - fn map_task(ctrl: chan<ctrl_proto>, input: -istr) { + fn map_task(ctrl: chan<ctrl_proto>, input: -str) { let intermediates = map::new_str_hash(); - fn emit(im: &map::hashmap<istr, int>, ctrl: chan<ctrl_proto>, - key: &istr, val: &istr) { + fn emit(im: &map::hashmap<str, int>, ctrl: chan<ctrl_proto>, + key: &str, val: &str) { let c; alt im.find(key) { some(_c) { c = _c } @@ -63,13 +61,13 @@ mod map_reduce { send(ctrl, mapper_done); } - fn map_reduce(inputs: &[istr]) { + fn map_reduce(inputs: &[str]) { let ctrl = port(); // This task becomes the master control task. It spawns others // to do the rest. - let reducers: map::hashmap<istr, int>; + let reducers: map::hashmap<str, int>; reducers = map::new_str_hash(); @@ -94,5 +92,5 @@ mod map_reduce { } fn main() { - map_reduce::map_reduce([~"../src/test/run-pass/hashmap-memory.rs"]); + map_reduce::map_reduce(["../src/test/run-pass/hashmap-memory.rs"]); } diff --git a/src/test/run-pass/import4.rs b/src/test/run-pass/import4.rs index 20b60a41e24..9e263b73413 100644 --- a/src/test/run-pass/import4.rs +++ b/src/test/run-pass/import4.rs @@ -5,4 +5,4 @@ mod zed { fn bar() { log "bar"; } } -fn main(args: [istr]) { let zed = 42; bar(); } +fn main(args: [str]) { let zed = 42; bar(); } diff --git a/src/test/run-pass/import5.rs b/src/test/run-pass/import5.rs index 14dbd577361..9f3ec6d2b45 100644 --- a/src/test/run-pass/import5.rs +++ b/src/test/run-pass/import5.rs @@ -7,4 +7,4 @@ mod foo { } } -fn main(args: [istr]) { bar(); } +fn main(args: [str]) { bar(); } diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs index a50dcff79d1..40c3d2357bf 100644 --- a/src/test/run-pass/import7.rs +++ b/src/test/run-pass/import7.rs @@ -12,4 +12,4 @@ mod bar { mod zed { } } } -fn main(args: [istr]) { baz(); } +fn main(args: [str]) { baz(); } diff --git a/src/test/run-pass/issue-687.rs b/src/test/run-pass/issue-687.rs index 65cdfd899a8..0306326e824 100644 --- a/src/test/run-pass/issue-687.rs +++ b/src/test/run-pass/issue-687.rs @@ -36,8 +36,7 @@ fn packager(cb: chan<chan<[u8]>>, msg: chan<msg>) { fn main() { let p: port<msg> = port(); let recv_reader: port<chan<[u8]>> = port(); - let pack = - task::spawn(bind packager(chan(recv_reader), chan(p))); + let pack = task::spawn(bind packager(chan(recv_reader), chan(p))); let source_chan: chan<[u8]> = recv(recv_reader); let prod = task::spawn(bind producer(source_chan)); diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 8b0eb0ddc05..affdbd06f17 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -1,60 +1,53 @@ fn test_stack_assign() { - let s: istr = ~"a"; + let s: str = "a"; log s; - let t: istr = ~"a"; - assert s == t; - let u: istr = ~"b"; - assert s != u; + let t: str = "a"; + assert (s == t); + let u: str = "b"; + assert (s != u); } -fn test_heap_lit() { - ~"a big string"; -} +fn test_heap_lit() { "a big string"; } fn test_heap_assign() { - let s: istr = ~"a big ol' string"; - let t: istr = ~"a big ol' string"; - assert s == t; - let u: istr = ~"a bad ol' string"; - assert s != u; + let s: str = "a big ol' string"; + let t: str = "a big ol' string"; + assert (s == t); + let u: str = "a bad ol' string"; + assert (s != u); } -fn test_heap_log() { - let s = ~"a big ol' string"; - log s; -} +fn test_heap_log() { let s = "a big ol' string"; log s; } fn test_stack_add() { - assert ~"a" + ~"b" == ~"ab"; - let s: istr = ~"a"; - assert s + s == ~"aa"; - assert ~"" + ~"" == ~""; + assert ("a" + "b" == "ab"); + let s: str = "a"; + assert (s + s == "aa"); + assert ("" + "" == ""); } -fn test_stack_heap_add() { - assert ~"a" + ~"bracadabra" == ~"abracadabra"; -} +fn test_stack_heap_add() { assert ("a" + "bracadabra" == "abracadabra"); } fn test_heap_add() { - assert ~"this should" + ~" totally work" == ~"this should totally work"; + assert ("this should" + " totally work" == "this should totally work"); } fn test_append() { - let s = ~""; - s += ~"a"; - assert s == ~"a"; + let s = ""; + s += "a"; + assert (s == "a"); - let s = ~"a"; - s += ~"b"; + let s = "a"; + s += "b"; log s; - assert s == ~"ab"; + assert (s == "ab"); - let s = ~"c"; - s += ~"offee"; - assert s == ~"coffee"; + let s = "c"; + s += "offee"; + assert (s == "coffee"); - s += ~"&tea"; - assert s == ~"coffee&tea"; + s += "&tea"; + assert (s == "coffee&tea"); } fn main() { @@ -66,4 +59,4 @@ fn main() { test_stack_heap_add(); test_heap_add(); test_append(); -} \ No newline at end of file +} diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index dd5fb0b18b3..3701d229059 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -167,7 +167,7 @@ mod test_distinguish_syntax_ext { use std; fn f() { - #fmt["test%s", ~"s"]; + #fmt["test%s", "s"]; #[attr = "val"] fn g() { } } diff --git a/src/test/run-pass/iter-ret.rs b/src/test/run-pass/iter-ret.rs index 25f350680ba..b450a34c411 100644 --- a/src/test/run-pass/iter-ret.rs +++ b/src/test/run-pass/iter-ret.rs @@ -4,4 +4,4 @@ iter x() -> int { } fn f() -> bool { for each i: int in x() { ret true; } ret false; } -fn main(args: [istr]) { f(); } +fn main(args: [str]) { f(); } diff --git a/src/test/run-pass/main-ivec.rs b/src/test/run-pass/main-ivec.rs index 376374f68eb..ec2403a9151 100644 --- a/src/test/run-pass/main-ivec.rs +++ b/src/test/run-pass/main-ivec.rs @@ -1,3 +1 @@ -fn main(args: [istr]) { - for s in args { log s } -} +fn main(args: [str]) { for s in args { log s } } diff --git a/src/test/run-pass/native2.rs b/src/test/run-pass/native2.rs index 2840c6a3a78..c0340387cfe 100644 --- a/src/test/run-pass/native2.rs +++ b/src/test/run-pass/native2.rs @@ -14,4 +14,4 @@ native "cdecl" mod libc = "" { native "cdecl" mod baz = "" { } -fn main(args: [istr]) { } +fn main(args: [str]) { } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index 61477258bb4..9478735d932 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -3,30 +3,23 @@ use std; import std::list::*; pure fn pure_length_go<@T>(ls: &list<T>, acc: uint) -> uint { - alt ls { - nil. { acc } - cons(_, tl) { pure_length_go(*tl, acc + 1u) } - } + alt ls { nil. { acc } cons(_, tl) { pure_length_go(*tl, acc + 1u) } } } -pure fn pure_length<@T>(ls: &list<T>) -> uint { - pure_length_go(ls, 0u) -} +pure fn pure_length<@T>(ls: &list<T>) -> uint { pure_length_go(ls, 0u) } -pure fn nonempty_list<@T>(ls: &list<T>) -> bool { - pure_length(ls) > 0u -} +pure fn nonempty_list<@T>(ls: &list<T>) -> bool { pure_length(ls) > 0u } - // Of course, the compiler can't take advantage of the - // knowledge that ls is a cons node. Future work. - // Also, this is pretty contrived since nonempty_list - // could be a "tag refinement", if we implement those. +// Of course, the compiler can't take advantage of the +// knowledge that ls is a cons node. Future work. +// Also, this is pretty contrived since nonempty_list +// could be a "tag refinement", if we implement those. fn safe_head<@T>(ls: &list<T>) : nonempty_list(ls) -> T { car(ls) } fn main() { let mylist = cons(@1u, @nil); // Again, a way to eliminate such "obvious" checks seems // desirable. (Tags could have postconditions.) - check(nonempty_list(mylist)); - assert (*(safe_head(mylist)) == 1u); -} \ No newline at end of file + check (nonempty_list(mylist)); + assert (*safe_head(mylist) == 1u); +} diff --git a/src/test/run-pass/path.rs b/src/test/run-pass/path.rs index 0cac07f3c99..4fe43d18121 100644 --- a/src/test/run-pass/path.rs +++ b/src/test/run-pass/path.rs @@ -4,4 +4,4 @@ mod foo { fn bar(offset: uint) { } } -fn main(args: [istr]) { foo::bar(0u); } +fn main(args: [str]) { foo::bar(0u); } diff --git a/src/test/run-pass/sio-client.rs b/src/test/run-pass/sio-client.rs index f3eefbcaef9..14e5e2e44cf 100644 --- a/src/test/run-pass/sio-client.rs +++ b/src/test/run-pass/sio-client.rs @@ -13,9 +13,9 @@ fn connectTask(cx: sio::ctx, ip: net::ip_addr, portnum: int) { fn main() { let cx: sio::ctx = sio::new(); let srv: sio::server = sio::create_server( - cx, net::parse_addr(~"0.0.0.0"), 9090); + cx, net::parse_addr("0.0.0.0"), 9090); let child = task::_spawn(bind connectTask(cx, - net::parse_addr(~"127.0.0.1"), + net::parse_addr("127.0.0.1"), 9090)); let client: sio::client = sio::accept_from(srv); task::join_id(child); diff --git a/src/test/run-pass/sio-read.rs b/src/test/run-pass/sio-read.rs index 9f7272e6d92..0085f4983f2 100644 --- a/src/test/run-pass/sio-read.rs +++ b/src/test/run-pass/sio-read.rs @@ -15,9 +15,9 @@ fn connectTask(cx: sio::ctx, ip: net::ip_addr, portnum: int) { fn main() { let cx: sio::ctx = sio::new(); let srv: sio::server = sio::create_server( - cx, net::parse_addr(~"0.0.0.0"), 9090); + cx, net::parse_addr("0.0.0.0"), 9090); let child = task::_spawn(bind connectTask(cx, - net::parse_addr(~"127.0.0.1"), + net::parse_addr("127.0.0.1"), 9090)); let client: sio::client = sio::accept_from(srv); sio::write_data(client, str::bytes("hello, world\n")); diff --git a/src/test/run-pass/sio-srv.rs b/src/test/run-pass/sio-srv.rs index c51a2c0d9d4..1171971427e 100644 --- a/src/test/run-pass/sio-srv.rs +++ b/src/test/run-pass/sio-srv.rs @@ -6,7 +6,7 @@ import std::net; fn main() { let cx: sio::ctx = sio::new(); let srv: sio::server = sio::create_server(cx, - net::parse_addr(~"127.0.0.1"), + net::parse_addr("127.0.0.1"), 9090); sio::close_server(srv); sio::destroy(cx); diff --git a/src/test/run-pass/sio-write.rs b/src/test/run-pass/sio-write.rs index 63e1cf4f3b1..cc372bc916d 100644 --- a/src/test/run-pass/sio-write.rs +++ b/src/test/run-pass/sio-write.rs @@ -13,9 +13,9 @@ fn connectTask(cx: sio::ctx, ip: net::ip_addr, portnum: int) { fn main() { let cx: sio::ctx = sio::new(); - let srv: sio::server = sio::create_server(cx, net::parse_addr(~"0.0.0.0"), + let srv: sio::server = sio::create_server(cx, net::parse_addr("0.0.0.0"), 9090); - let child = task::_spawn(bind connectTask(cx, net::parse_addr(~"127.0.0.1"), + let child = task::_spawn(bind connectTask(cx, net::parse_addr("127.0.0.1"), 9090)); let client: sio::client = sio::accept_from(srv); sio::write_data(client, str::bytes("hello, world\n")); diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index bfaba60bcd1..612fdecb4ab 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -4,12 +4,12 @@ use std; import std::task::yield; import std::task; -fn x(s: -istr, n: int) { log s; log n; } +fn x(s: -str, n: int) { log s; log n; } fn main() { - task::spawn(bind x(~"hello from first spawned fn", 65)); - task::spawn(bind x(~"hello from second spawned fn", 66)); - task::spawn(bind x(~"hello from third spawned fn", 67)); + task::spawn(bind x("hello from first spawned fn", 65)); + task::spawn(bind x("hello from second spawned fn", 66)); + task::spawn(bind x("hello from third spawned fn", 67)); let i: int = 30; while i > 0 { i = i - 1; log "parent sleeping"; yield(); } } diff --git a/src/test/run-pass/spawn-module-qualified.rs b/src/test/run-pass/spawn-module-qualified.rs index e5775550c44..38bf6afe1e5 100644 --- a/src/test/run-pass/spawn-module-qualified.rs +++ b/src/test/run-pass/spawn-module-qualified.rs @@ -2,10 +2,7 @@ use std; import std::task::join; import std::task::spawn_joinable; -fn main() { - let x = spawn_joinable(bind m::child(10)); - join(x); -} +fn main() { let x = spawn_joinable(bind m::child(10)); join(x); } mod m { fn child(i: int) { log i; } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index 33ac76300a7..3a4ce18f3a2 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -12,9 +12,9 @@ import std::task; type ctx = comm::chan<int>; -fn iotask(cx: ctx, ip: -istr) { assert (str::eq(ip, ~"localhost")); } +fn iotask(cx: ctx, ip: -str) { assert (str::eq(ip, "localhost")); } fn main() { let p = comm::port::<int>(); - task::spawn(bind iotask(comm::chan(p), ~"localhost")); + task::spawn(bind iotask(comm::chan(p), "localhost")); } diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 9086b7d0e37..50c599f42af 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -4,10 +4,7 @@ use std; import std::task; -fn main() { - let t = task::spawn_joinable(bind child(10)); - task::join(t); -} +fn main() { let t = task::spawn_joinable(bind child(10)); task::join(t); } fn child(i: int) { log_err i; assert (i == 10); } diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs index 5677f562a2f..e1fa92738cb 100644 --- a/src/test/run-pass/str-append.rs +++ b/src/test/run-pass/str-append.rs @@ -5,8 +5,8 @@ use std; import std::str; fn test1() { - let s: istr = ~"hello"; - s += ~"world"; + let s: str = "hello"; + s += "world"; log s; assert (s[9] == 'd' as u8); } @@ -14,13 +14,13 @@ fn test1() { fn test2() { // This tests for issue #163 - let ff: istr = ~"abc"; - let a: istr = ff + ~"ABC" + ff; - let b: istr = ~"ABC" + ff + ~"ABC"; + let ff: str = "abc"; + let a: str = ff + "ABC" + ff; + let b: str = "ABC" + ff + "ABC"; log a; log b; - assert (str::eq(a, ~"abcABCabc")); - assert (str::eq(b, ~"ABCabcABC")); + assert (str::eq(a, "abcABCabc")); + assert (str::eq(b, "ABCabcABC")); } fn main() { test1(); test2(); } diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs index 3df1a7d926f..15a13083321 100644 --- a/src/test/run-pass/str-multiline.rs +++ b/src/test/run-pass/str-multiline.rs @@ -5,13 +5,13 @@ use std; import std::str; fn main() { - let a: istr = ~"this \ + let a: str = "this \ is a test"; - let b: istr = - ~"this \ + let b: str = + "this \ is \ another \ test"; - assert (str::eq(a, ~"this is a test")); - assert (str::eq(b, ~"this is another test")); + assert (str::eq(a, "this is a test")); + assert (str::eq(b, "this is another test")); } diff --git a/src/test/run-pass/string-self-append.rs b/src/test/run-pass/string-self-append.rs index 29bef1379bb..94a9696adf0 100644 --- a/src/test/run-pass/string-self-append.rs +++ b/src/test/run-pass/string-self-append.rs @@ -3,7 +3,7 @@ import std::str; fn main() { // Make sure we properly handle repeated self-appends. - let a: istr = ~"A"; + let a: str = "A"; let i = 20; let expected_len = 1u; while i > 0 { diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index 77ae154085f..88204cfffeb 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -1,17 +1,17 @@ use std; import std::str; -fn test(actual: &istr, expected: &istr) { +fn test(actual: &str, expected: &str) { log actual; log expected; assert (str::eq(actual, expected)); } fn main() { - test(#fmt[~"hello %d friends and %s things", 10, ~"formatted"], - ~"hello 10 friends and formatted things"); + test(#fmt["hello %d friends and %s things", 10, "formatted"], + "hello 10 friends and formatted things"); - test(#fmt[~"test"], ~"test"); + test(#fmt["test"], "test"); // a quadratic optimization in LLVM (jump-threading) makes this test a // bit slow to compile unless we break it up @@ -26,192 +26,192 @@ fn main() { fn part1() { // Simple tests for types - test(#fmt[~"%d", 1], ~"1"); - test(#fmt[~"%i", 2], ~"2"); - test(#fmt[~"%i", -1], ~"-1"); - test(#fmt[~"%u", 10u], ~"10"); - test(#fmt[~"%s", ~"test"], ~"test"); - test(#fmt[~"%b", true], ~"true"); - test(#fmt[~"%b", false], ~"false"); - test(#fmt[~"%c", 'A'], ~"A"); - test(#fmt[~"%x", 0xff_u], ~"ff"); - test(#fmt[~"%X", 0x12ab_u], ~"12AB"); - test(#fmt[~"%o", 10u], ~"12"); - test(#fmt[~"%t", 0b11010101_u], ~"11010101"); + test(#fmt["%d", 1], "1"); + test(#fmt["%i", 2], "2"); + test(#fmt["%i", -1], "-1"); + test(#fmt["%u", 10u], "10"); + test(#fmt["%s", "test"], "test"); + test(#fmt["%b", true], "true"); + test(#fmt["%b", false], "false"); + test(#fmt["%c", 'A'], "A"); + test(#fmt["%x", 0xff_u], "ff"); + test(#fmt["%X", 0x12ab_u], "12AB"); + test(#fmt["%o", 10u], "12"); + test(#fmt["%t", 0b11010101_u], "11010101"); // 32-bit limits - test(#fmt[~"%i", -2147483648], ~"-2147483648"); - test(#fmt[~"%i", 2147483647], ~"2147483647"); - test(#fmt[~"%u", 4294967295u], ~"4294967295"); - test(#fmt[~"%x", 0xffffffff_u], ~"ffffffff"); - test(#fmt[~"%o", 0xffffffff_u], ~"37777777777"); - test(#fmt[~"%t", 0xffffffff_u], ~"11111111111111111111111111111111"); + test(#fmt["%i", -2147483648], "-2147483648"); + test(#fmt["%i", 2147483647], "2147483647"); + test(#fmt["%u", 4294967295u], "4294967295"); + test(#fmt["%x", 0xffffffff_u], "ffffffff"); + test(#fmt["%o", 0xffffffff_u], "37777777777"); + test(#fmt["%t", 0xffffffff_u], "11111111111111111111111111111111"); } fn part2() { // Widths - test(#fmt[~"%1d", 500], ~"500"); - test(#fmt[~"%10d", 500], ~" 500"); - test(#fmt[~"%10d", -500], ~" -500"); - test(#fmt[~"%10u", 500u], ~" 500"); - test(#fmt[~"%10s", ~"test"], ~" test"); - test(#fmt[~"%10b", true], ~" true"); - test(#fmt[~"%10x", 0xff_u], ~" ff"); - test(#fmt[~"%10X", 0xff_u], ~" FF"); - test(#fmt[~"%10o", 10u], ~" 12"); - test(#fmt[~"%10t", 0xff_u], ~" 11111111"); - test(#fmt[~"%10c", 'A'], ~" A"); + test(#fmt["%1d", 500], "500"); + test(#fmt["%10d", 500], " 500"); + test(#fmt["%10d", -500], " -500"); + test(#fmt["%10u", 500u], " 500"); + test(#fmt["%10s", "test"], " test"); + test(#fmt["%10b", true], " true"); + test(#fmt["%10x", 0xff_u], " ff"); + test(#fmt["%10X", 0xff_u], " FF"); + test(#fmt["%10o", 10u], " 12"); + test(#fmt["%10t", 0xff_u], " 11111111"); + test(#fmt["%10c", 'A'], " A"); // Left justify - test(#fmt[~"%-10d", 500], ~"500 "); - test(#fmt[~"%-10d", -500], ~"-500 "); - test(#fmt[~"%-10u", 500u], ~"500 "); - test(#fmt[~"%-10s", ~"test"], ~"test "); - test(#fmt[~"%-10b", true], ~"true "); - test(#fmt[~"%-10x", 0xff_u], ~"ff "); - test(#fmt[~"%-10X", 0xff_u], ~"FF "); - test(#fmt[~"%-10o", 10u], ~"12 "); - test(#fmt[~"%-10t", 0xff_u], ~"11111111 "); - test(#fmt[~"%-10c", 'A'], ~"A "); + test(#fmt["%-10d", 500], "500 "); + test(#fmt["%-10d", -500], "-500 "); + test(#fmt["%-10u", 500u], "500 "); + test(#fmt["%-10s", "test"], "test "); + test(#fmt["%-10b", true], "true "); + test(#fmt["%-10x", 0xff_u], "ff "); + test(#fmt["%-10X", 0xff_u], "FF "); + test(#fmt["%-10o", 10u], "12 "); + test(#fmt["%-10t", 0xff_u], "11111111 "); + test(#fmt["%-10c", 'A'], "A "); } fn part3() { // Precision - test(#fmt[~"%.d", 0], ~""); - test(#fmt[~"%.u", 0u], ~""); - test(#fmt[~"%.x", 0u], ~""); - test(#fmt[~"%.t", 0u], ~""); - test(#fmt[~"%.d", 10], ~"10"); - test(#fmt[~"%.d", -10], ~"-10"); - test(#fmt[~"%.u", 10u], ~"10"); - test(#fmt[~"%.s", ~"test"], ~""); - test(#fmt[~"%.x", 127u], ~"7f"); - test(#fmt[~"%.o", 10u], ~"12"); - test(#fmt[~"%.t", 3u], ~"11"); - test(#fmt[~"%.c", 'A'], ~"A"); - test(#fmt[~"%.0d", 0], ~""); - test(#fmt[~"%.0u", 0u], ~""); - test(#fmt[~"%.0x", 0u], ~""); - test(#fmt[~"%.0t", 0u], ~""); - test(#fmt[~"%.0d", 10], ~"10"); - test(#fmt[~"%.0d", -10], ~"-10"); - test(#fmt[~"%.0u", 10u], ~"10"); - test(#fmt[~"%.0s", ~"test"], ~""); - test(#fmt[~"%.0x", 127u], ~"7f"); - test(#fmt[~"%.0o", 10u], ~"12"); - test(#fmt[~"%.0t", 3u], ~"11"); - test(#fmt[~"%.0c", 'A'], ~"A"); - test(#fmt[~"%.1d", 0], ~"0"); - test(#fmt[~"%.1u", 0u], ~"0"); - test(#fmt[~"%.1x", 0u], ~"0"); - test(#fmt[~"%.1t", 0u], ~"0"); - test(#fmt[~"%.1d", 10], ~"10"); - test(#fmt[~"%.1d", -10], ~"-10"); - test(#fmt[~"%.1u", 10u], ~"10"); - test(#fmt[~"%.1s", ~"test"], ~"t"); - test(#fmt[~"%.1x", 127u], ~"7f"); - test(#fmt[~"%.1o", 10u], ~"12"); - test(#fmt[~"%.1t", 3u], ~"11"); - test(#fmt[~"%.1c", 'A'], ~"A"); + test(#fmt["%.d", 0], ""); + test(#fmt["%.u", 0u], ""); + test(#fmt["%.x", 0u], ""); + test(#fmt["%.t", 0u], ""); + test(#fmt["%.d", 10], "10"); + test(#fmt["%.d", -10], "-10"); + test(#fmt["%.u", 10u], "10"); + test(#fmt["%.s", "test"], ""); + test(#fmt["%.x", 127u], "7f"); + test(#fmt["%.o", 10u], "12"); + test(#fmt["%.t", 3u], "11"); + test(#fmt["%.c", 'A'], "A"); + test(#fmt["%.0d", 0], ""); + test(#fmt["%.0u", 0u], ""); + test(#fmt["%.0x", 0u], ""); + test(#fmt["%.0t", 0u], ""); + test(#fmt["%.0d", 10], "10"); + test(#fmt["%.0d", -10], "-10"); + test(#fmt["%.0u", 10u], "10"); + test(#fmt["%.0s", "test"], ""); + test(#fmt["%.0x", 127u], "7f"); + test(#fmt["%.0o", 10u], "12"); + test(#fmt["%.0t", 3u], "11"); + test(#fmt["%.0c", 'A'], "A"); + test(#fmt["%.1d", 0], "0"); + test(#fmt["%.1u", 0u], "0"); + test(#fmt["%.1x", 0u], "0"); + test(#fmt["%.1t", 0u], "0"); + test(#fmt["%.1d", 10], "10"); + test(#fmt["%.1d", -10], "-10"); + test(#fmt["%.1u", 10u], "10"); + test(#fmt["%.1s", "test"], "t"); + test(#fmt["%.1x", 127u], "7f"); + test(#fmt["%.1o", 10u], "12"); + test(#fmt["%.1t", 3u], "11"); + test(#fmt["%.1c", 'A'], "A"); } fn part4() { - test(#fmt[~"%.5d", 0], ~"00000"); - test(#fmt[~"%.5u", 0u], ~"00000"); - test(#fmt[~"%.5x", 0u], ~"00000"); - test(#fmt[~"%.5t", 0u], ~"00000"); - test(#fmt[~"%.5d", 10], ~"00010"); - test(#fmt[~"%.5d", -10], ~"-00010"); - test(#fmt[~"%.5u", 10u], ~"00010"); - test(#fmt[~"%.5s", ~"test"], ~"test"); - test(#fmt[~"%.5x", 127u], ~"0007f"); - test(#fmt[~"%.5o", 10u], ~"00012"); - test(#fmt[~"%.5t", 3u], ~"00011"); - test(#fmt[~"%.5c", 'A'], ~"A"); + test(#fmt["%.5d", 0], "00000"); + test(#fmt["%.5u", 0u], "00000"); + test(#fmt["%.5x", 0u], "00000"); + test(#fmt["%.5t", 0u], "00000"); + test(#fmt["%.5d", 10], "00010"); + test(#fmt["%.5d", -10], "-00010"); + test(#fmt["%.5u", 10u], "00010"); + test(#fmt["%.5s", "test"], "test"); + test(#fmt["%.5x", 127u], "0007f"); + test(#fmt["%.5o", 10u], "00012"); + test(#fmt["%.5t", 3u], "00011"); + test(#fmt["%.5c", 'A'], "A"); // Bool precision. I'm not sure if it's good or bad to have bool // conversions support precision - it's not standard printf so we // can do whatever. For now I'm making it behave the same as string // conversions. - test(#fmt[~"%.b", true], ~""); - test(#fmt[~"%.0b", true], ~""); - test(#fmt[~"%.1b", true], ~"t"); + test(#fmt["%.b", true], ""); + test(#fmt["%.0b", true], ""); + test(#fmt["%.1b", true], "t"); } fn part5() { // Explicit + sign. Only for signed conversions - test(#fmt[~"%+d", 0], ~"+0"); - test(#fmt[~"%+d", 1], ~"+1"); - test(#fmt[~"%+d", -1], ~"-1"); + test(#fmt["%+d", 0], "+0"); + test(#fmt["%+d", 1], "+1"); + test(#fmt["%+d", -1], "-1"); // Leave space for sign - test(#fmt[~"% d", 0], ~" 0"); - test(#fmt[~"% d", 1], ~" 1"); - test(#fmt[~"% d", -1], ~"-1"); + test(#fmt["% d", 0], " 0"); + test(#fmt["% d", 1], " 1"); + test(#fmt["% d", -1], "-1"); // Plus overrides space - test(#fmt[~"% +d", 0], ~"+0"); - test(#fmt[~"%+ d", 0], ~"+0"); + test(#fmt["% +d", 0], "+0"); + test(#fmt["%+ d", 0], "+0"); // 0-padding - test(#fmt[~"%05d", 0], ~"00000"); - test(#fmt[~"%05d", 1], ~"00001"); - test(#fmt[~"%05d", -1], ~"-0001"); - test(#fmt[~"%05u", 1u], ~"00001"); - test(#fmt[~"%05x", 127u], ~"0007f"); - test(#fmt[~"%05X", 127u], ~"0007F"); - test(#fmt[~"%05o", 10u], ~"00012"); - test(#fmt[~"%05t", 3u], ~"00011"); + test(#fmt["%05d", 0], "00000"); + test(#fmt["%05d", 1], "00001"); + test(#fmt["%05d", -1], "-0001"); + test(#fmt["%05u", 1u], "00001"); + test(#fmt["%05x", 127u], "0007f"); + test(#fmt["%05X", 127u], "0007F"); + test(#fmt["%05o", 10u], "00012"); + test(#fmt["%05t", 3u], "00011"); // 0-padding a string is undefined but glibc does this: - test(#fmt[~"%05s", ~"test"], ~" test"); - test(#fmt[~"%05c", 'A'], ~" A"); - test(#fmt[~"%05b", true], ~" true"); + test(#fmt["%05s", "test"], " test"); + test(#fmt["%05c", 'A'], " A"); + test(#fmt["%05b", true], " true"); // Left-justify overrides 0-padding - test(#fmt[~"%-05d", 0], ~"0 "); - test(#fmt[~"%-05d", 1], ~"1 "); - test(#fmt[~"%-05d", -1], ~"-1 "); - test(#fmt[~"%-05u", 1u], ~"1 "); - test(#fmt[~"%-05x", 127u], ~"7f "); - test(#fmt[~"%-05X", 127u], ~"7F "); - test(#fmt[~"%-05o", 10u], ~"12 "); - test(#fmt[~"%-05t", 3u], ~"11 "); - test(#fmt[~"%-05s", ~"test"], ~"test "); - test(#fmt[~"%-05c", 'A'], ~"A "); - test(#fmt[~"%-05b", true], ~"true "); + test(#fmt["%-05d", 0], "0 "); + test(#fmt["%-05d", 1], "1 "); + test(#fmt["%-05d", -1], "-1 "); + test(#fmt["%-05u", 1u], "1 "); + test(#fmt["%-05x", 127u], "7f "); + test(#fmt["%-05X", 127u], "7F "); + test(#fmt["%-05o", 10u], "12 "); + test(#fmt["%-05t", 3u], "11 "); + test(#fmt["%-05s", "test"], "test "); + test(#fmt["%-05c", 'A'], "A "); + test(#fmt["%-05b", true], "true "); } fn part6() { // Precision overrides 0-padding - test(#fmt[~"%06.5d", 0], ~" 00000"); - test(#fmt[~"%06.5u", 0u], ~" 00000"); - test(#fmt[~"%06.5x", 0u], ~" 00000"); - test(#fmt[~"%06.5d", 10], ~" 00010"); - test(#fmt[~"%06.5d", -10], ~"-00010"); - test(#fmt[~"%06.5u", 10u], ~" 00010"); - test(#fmt[~"%06.5s", ~"test"], ~" test"); - test(#fmt[~"%06.5c", 'A'], ~" A"); - test(#fmt[~"%06.5x", 127u], ~" 0007f"); - test(#fmt[~"%06.5X", 127u], ~" 0007F"); - test(#fmt[~"%06.5o", 10u], ~" 00012"); + test(#fmt["%06.5d", 0], " 00000"); + test(#fmt["%06.5u", 0u], " 00000"); + test(#fmt["%06.5x", 0u], " 00000"); + test(#fmt["%06.5d", 10], " 00010"); + test(#fmt["%06.5d", -10], "-00010"); + test(#fmt["%06.5u", 10u], " 00010"); + test(#fmt["%06.5s", "test"], " test"); + test(#fmt["%06.5c", 'A'], " A"); + test(#fmt["%06.5x", 127u], " 0007f"); + test(#fmt["%06.5X", 127u], " 0007F"); + test(#fmt["%06.5o", 10u], " 00012"); // Signed combinations - test(#fmt[~"% 5d", 1], ~" 1"); - test(#fmt[~"% 5d", -1], ~" -1"); - test(#fmt[~"%+5d", 1], ~" +1"); - test(#fmt[~"%+5d", -1], ~" -1"); - test(#fmt[~"% 05d", 1], ~" 0001"); - test(#fmt[~"% 05d", -1], ~"-0001"); - test(#fmt[~"%+05d", 1], ~"+0001"); - test(#fmt[~"%+05d", -1], ~"-0001"); - test(#fmt[~"%- 5d", 1], ~" 1 "); - test(#fmt[~"%- 5d", -1], ~"-1 "); - test(#fmt[~"%-+5d", 1], ~"+1 "); - test(#fmt[~"%-+5d", -1], ~"-1 "); - test(#fmt[~"%- 05d", 1], ~" 1 "); - test(#fmt[~"%- 05d", -1], ~"-1 "); - test(#fmt[~"%-+05d", 1], ~"+1 "); - test(#fmt[~"%-+05d", -1], ~"-1 "); + test(#fmt["% 5d", 1], " 1"); + test(#fmt["% 5d", -1], " -1"); + test(#fmt["%+5d", 1], " +1"); + test(#fmt["%+5d", -1], " -1"); + test(#fmt["% 05d", 1], " 0001"); + test(#fmt["% 05d", -1], "-0001"); + test(#fmt["%+05d", 1], "+0001"); + test(#fmt["%+05d", -1], "-0001"); + test(#fmt["%- 5d", 1], " 1 "); + test(#fmt["%- 5d", -1], "-1 "); + test(#fmt["%-+5d", 1], "+1 "); + test(#fmt["%-+5d", -1], "-1 "); + test(#fmt["%- 05d", 1], " 1 "); + test(#fmt["%- 05d", -1], "-1 "); + test(#fmt["%-+05d", 1], "+1 "); + test(#fmt["%-+05d", -1], "-1 "); } diff --git a/src/test/run-pass/tag-in-block.rs b/src/test/run-pass/tag-in-block.rs index c84bfeacee5..d76ee9ed12a 100644 --- a/src/test/run-pass/tag-in-block.rs +++ b/src/test/run-pass/tag-in-block.rs @@ -6,4 +6,4 @@ fn foo() { fn baz() { zed(nil); } } -fn main(args: [istr]) { } +fn main(args: [str]) { } diff --git a/src/test/run-pass/tag.rs b/src/test/run-pass/tag.rs index 12ac2614efe..d0022341f8d 100644 --- a/src/test/run-pass/tag.rs +++ b/src/test/run-pass/tag.rs @@ -4,10 +4,6 @@ // -*- rust -*- tag colour { red(int, int); green; } -fn f() { - let x = red(1, 2); - let y = green; - assert (x != y); -} +fn f() { let x = red(1, 2); let y = green; assert (x != y); } fn main() { f(); } diff --git a/src/test/run-pass/task-life-0.rs b/src/test/run-pass/task-life-0.rs index b8c78ecd12b..d272410be80 100644 --- a/src/test/run-pass/task-life-0.rs +++ b/src/test/run-pass/task-life-0.rs @@ -1,6 +1,6 @@ use std; import std::task; -fn main() { task::spawn(bind child(~"Hello")); } +fn main() { task::spawn(bind child("Hello")); } fn child(s: -str) { diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index 4e6bda36845..8e032197085 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -3,41 +3,21 @@ use std; -fn test_break() { - while true { - let x: @int = break; - } -} +fn test_break() { while true { let x: @int = break; } } -fn test_cont() { - let i = 0; - while i < 1 { - i += 1; - let x: @int = cont; - } -} +fn test_cont() { let i = 0; while i < 1 { i += 1; let x: @int = cont; } } -fn test_ret() { - let x: @int = ret; -} +fn test_ret() { let x: @int = ret; } fn test_fail() { - fn f() { - std::task::unsupervise(); - let x: @int = fail; - } + fn f() { std::task::unsupervise(); let x: @int = fail; } let g = f; std::task::spawn(g); } fn test_fail_indirect() { - fn f() -> ! { - fail; - } - fn g() { - std::task::unsupervise(); - let x: @int = f(); - } + fn f() -> ! { fail; } + fn g() { std::task::unsupervise(); let x: @int = f(); } let h = g; std::task::spawn(h); } @@ -48,4 +28,4 @@ fn main() { test_ret(); test_fail(); test_fail_indirect(); -} \ No newline at end of file +} diff --git a/src/test/run-pass/type-param.rs b/src/test/run-pass/type-param.rs index 1ad437ed67f..be55ba86cac 100644 --- a/src/test/run-pass/type-param.rs +++ b/src/test/run-pass/type-param.rs @@ -2,4 +2,4 @@ type lteq<T> = fn(&T) -> bool; -fn main(args: [istr]) { } +fn main(args: [str]) { } diff --git a/src/test/run-pass/type-ptr.rs b/src/test/run-pass/type-ptr.rs index 000fb1a1558..e608a9f9836 100644 --- a/src/test/run-pass/type-ptr.rs +++ b/src/test/run-pass/type-ptr.rs @@ -2,4 +2,4 @@ fn f(a: *int) -> *int { ret a; } fn g(a: *int) -> *int { let b = f(a); ret b; } -fn main(args: [istr]) { ret; } +fn main(args: [str]) { ret; } diff --git a/src/test/run-pass/unchecked-predicates.rs b/src/test/run-pass/unchecked-predicates.rs index 56b7dcc7837..d456f1f2e90 100644 --- a/src/test/run-pass/unchecked-predicates.rs +++ b/src/test/run-pass/unchecked-predicates.rs @@ -6,35 +6,28 @@ import std::list::*; // Can't easily be written as a "pure fn" because there's // no syntax for specifying that f is pure. fn pure_foldl<@T, @U>(ls: &list<T>, u: &U, f: &block(&T, &U) -> U) -> U { - alt ls { - nil. { u } - cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) } - } + alt ls { nil. { u } cons(hd, tl) { f(hd, pure_foldl(*tl, f(hd, u), f)) } } } // Shows how to use an "unchecked" block to call a general // fn from a pure fn pure fn pure_length<@T>(ls: &list<T>) -> uint { fn count<T>(_t: &T, u: &uint) -> uint { u + 1u } - unchecked { - pure_foldl(ls, 0u, count) - } + unchecked{ pure_foldl(ls, 0u, count) } } -pure fn nonempty_list<@T>(ls: &list<T>) -> bool { - pure_length(ls) > 0u -} +pure fn nonempty_list<@T>(ls: &list<T>) -> bool { pure_length(ls) > 0u } - // Of course, the compiler can't take advantage of the - // knowledge that ls is a cons node. Future work. - // Also, this is pretty contrived since nonempty_list - // could be a "tag refinement", if we implement those. +// Of course, the compiler can't take advantage of the +// knowledge that ls is a cons node. Future work. +// Also, this is pretty contrived since nonempty_list +// could be a "tag refinement", if we implement those. fn safe_head<@T>(ls: &list<T>) : nonempty_list(ls) -> T { car(ls) } fn main() { let mylist = cons(@1u, @nil); // Again, a way to eliminate such "obvious" checks seems // desirable. (Tags could have postconditions.) - check(nonempty_list(mylist)); - assert (*(safe_head(mylist)) == 1u); -} \ No newline at end of file + check (nonempty_list(mylist)); + assert (*safe_head(mylist) == 1u); +} diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 4b292d1ba86..e7f7f9a1524 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -5,7 +5,7 @@ import std::vec; fn main() { // Chars of 1, 2, 3, and 4 bytes let chs: [char] = ['e', 'é', '€', 0x10000 as char]; - let s: istr = str::from_chars(chs); + let s: str = str::from_chars(chs); assert (str::byte_len(s) == 10u); assert (str::char_len(s) == 4u); @@ -19,13 +19,13 @@ fn main() { assert (!str::is_utf8([0xc0_u8])); assert (!str::is_utf8([0xc0_u8, 0x10_u8])); - let stack = ~"a×c€"; + let stack = "a×c€"; assert (str::pop_char(stack) == '€'); assert (str::pop_char(stack) == 'c'); str::push_char(stack, 'u'); - assert (str::eq(stack, ~"a×u")); + assert (str::eq(stack, "a×u")); assert (str::shift_char(stack) == 'a'); assert (str::shift_char(stack) == '×'); str::unshift_char(stack, 'ß'); - assert (str::eq(stack, ~"ßu")); + assert (str::eq(stack, "ßu")); } diff --git a/src/test/run-pass/vec-self-append.rs b/src/test/run-pass/vec-self-append.rs index 47e9f27686b..8e023cf03da 100644 --- a/src/test/run-pass/vec-self-append.rs +++ b/src/test/run-pass/vec-self-append.rs @@ -5,17 +5,17 @@ fn test_heap_to_heap() { // a spills onto the heap let a = [0, 1, 2, 3, 4]; a += a; - assert vec::len(a) == 10u; - assert a[0] == 0; - assert a[1] == 1; - assert a[2] == 2; - assert a[3] == 3; - assert a[4] == 4; - assert a[5] == 0; - assert a[6] == 1; - assert a[7] == 2; - assert a[8] == 3; - assert a[9] == 4; + assert (vec::len(a) == 10u); + assert (a[0] == 0); + assert (a[1] == 1); + assert (a[2] == 2); + assert (a[3] == 3); + assert (a[4] == 4); + assert (a[5] == 0); + assert (a[6] == 1); + assert (a[7] == 2); + assert (a[8] == 3); + assert (a[9] == 4); } fn test_stack_to_heap() { @@ -23,13 +23,13 @@ fn test_stack_to_heap() { let a = [0, 1, 2]; // a spills to the heap a += a; - assert vec::len(a) == 6u; - assert a[0] == 0; - assert a[1] == 1; - assert a[2] == 2; - assert a[3] == 0; - assert a[4] == 1; - assert a[5] == 2; + assert (vec::len(a) == 6u); + assert (a[0] == 0); + assert (a[1] == 1); + assert (a[2] == 2); + assert (a[3] == 0); + assert (a[4] == 1); + assert (a[5] == 2); } fn test_loop() { @@ -46,8 +46,4 @@ fn test_loop() { } } -fn main() { - test_heap_to_heap(); - test_stack_to_heap(); - test_loop(); -} +fn main() { test_heap_to_heap(); test_stack_to_heap(); test_loop(); } diff --git a/src/test/run-pass/while-cont.rs b/src/test/run-pass/while-cont.rs index 78c4163c3bd..6a2e9acfda3 100644 --- a/src/test/run-pass/while-cont.rs +++ b/src/test/run-pass/while-cont.rs @@ -1,10 +1,2 @@ // Issue #825: Should recheck the loop contition after continuing -fn main() { - let i = 1; - while i > 0 { - assert i > 0; - log i; - i -= 1; - cont; - } -} \ No newline at end of file +fn main() { let i = 1; while i > 0 { assert (i > 0); log i; i -= 1; cont; } } diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs index 5427f548d35..b2ccf093883 100644 --- a/src/test/run-pass/zip-same-length.rs +++ b/src/test/run-pass/zip-same-length.rs @@ -9,15 +9,15 @@ import std::vec::*; fn main() { let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u; // Silly, but necessary - check u8::le(a, j); - check uint::le(k, l); + check (u8::le(a, j)); + check (uint::le(k, l)); let chars = enum_chars(a, j); - let ints = enum_uints(k, l); + let ints = enum_uints(k, l); - check same_length(chars, ints); + check (same_length(chars, ints)); let ps = zip(chars, ints); - check is_not_empty(ps); + check (is_not_empty(ps)); assert (head(ps) == ('a', 1u)); assert (last_total(ps) == (j as char, 10u)); } diff --git a/src/test/stdtest/comm.rs b/src/test/stdtest/comm.rs index 1fafd1a0375..9c31c5e6f72 100644 --- a/src/test/stdtest/comm.rs +++ b/src/test/stdtest/comm.rs @@ -2,10 +2,7 @@ use std; import std::comm; #[test] -fn create_port_and_chan() { - let p = comm::port::<int>(); - comm::chan(p); -} +fn create_port_and_chan() { let p = comm::port::<int>(); comm::chan(p); } #[test] fn send_recv_fn() { diff --git a/src/test/stdtest/fs.rs b/src/test/stdtest/fs.rs index f2e49232800..36e8ae23c5d 100644 --- a/src/test/stdtest/fs.rs +++ b/src/test/stdtest/fs.rs @@ -5,28 +5,26 @@ import std::fs; #[test] fn test_connect() { let slash = fs::path_sep(); - log_err fs::connect(~"a", ~"b"); - assert (fs::connect(~"a", ~"b") == ~"a" + slash + ~"b"); - assert (fs::connect(~"a" + slash, ~"b") == ~"a" + slash + ~"b"); + log_err fs::connect("a", "b"); + assert (fs::connect("a", "b") == "a" + slash + "b"); + assert (fs::connect("a" + slash, "b") == "a" + slash + "b"); } // Issue #712 #[test] -fn test_list_dir_no_invalid_memory_access() { fs::list_dir(~"."); } +fn test_list_dir_no_invalid_memory_access() { fs::list_dir("."); } #[test] fn list_dir() { - let dirs = fs::list_dir(~"."); + let dirs = fs::list_dir("."); // Just assuming that we've got some contents in the current directory - assert std::vec::len(dirs) > 0u; + assert (std::vec::len(dirs) > 0u); - for dir in dirs { - log dir; - } + for dir in dirs { log dir; } } #[test] fn file_is_dir() { - assert fs::file_is_dir(~"."); - assert !fs::file_is_dir(~"test/stdtest/fs.rs"); -} \ No newline at end of file + assert (fs::file_is_dir(".")); + assert (!fs::file_is_dir("test/stdtest/fs.rs")); +} diff --git a/src/test/stdtest/getopts.rs b/src/test/stdtest/getopts.rs index 332ec484c95..55d67729129 100644 --- a/src/test/stdtest/getopts.rs +++ b/src/test/stdtest/getopts.rs @@ -27,13 +27,13 @@ fn check_fail_type(f: opt::fail_, ft: fail_type) { // Tests for reqopt #[test] fn test_reqopt_long() { - let args = [~"--test=20"]; - let opts = [opt::reqopt(~"test")]; + let args = ["--test=20"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); } _ { fail; } } @@ -41,8 +41,8 @@ fn test_reqopt_long() { #[test] fn test_reqopt_long_missing() { - let args = [~"blah"]; - let opts = [opt::reqopt(~"test")]; + let args = ["blah"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_missing); } @@ -52,8 +52,8 @@ fn test_reqopt_long_missing() { #[test] fn test_reqopt_long_no_arg() { - let args = [~"--test"]; - let opts = [opt::reqopt(~"test")]; + let args = ["--test"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -63,8 +63,8 @@ fn test_reqopt_long_no_arg() { #[test] fn test_reqopt_long_multi() { - let args = [~"--test=20", ~"--test=30"]; - let opts = [opt::reqopt(~"test")]; + let args = ["--test=20", "--test=30"]; + let opts = [opt::reqopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -74,13 +74,13 @@ fn test_reqopt_long_multi() { #[test] fn test_reqopt_short() { - let args = [~"-t", ~"20"]; - let opts = [opt::reqopt(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); } _ { fail; } } @@ -88,8 +88,8 @@ fn test_reqopt_short() { #[test] fn test_reqopt_short_missing() { - let args = [~"blah"]; - let opts = [opt::reqopt(~"t")]; + let args = ["blah"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_missing); } @@ -99,8 +99,8 @@ fn test_reqopt_short_missing() { #[test] fn test_reqopt_short_no_arg() { - let args = [~"-t"]; - let opts = [opt::reqopt(~"t")]; + let args = ["-t"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -110,8 +110,8 @@ fn test_reqopt_short_no_arg() { #[test] fn test_reqopt_short_multi() { - let args = [~"-t", ~"20", ~"-t", ~"30"]; - let opts = [opt::reqopt(~"t")]; + let args = ["-t", "20", "-t", "30"]; + let opts = [opt::reqopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -123,13 +123,13 @@ fn test_reqopt_short_multi() { // Tests for optopt #[test] fn test_optopt_long() { - let args = [~"--test=20"]; - let opts = [opt::optopt(~"test")]; + let args = ["--test=20"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); } _ { fail; } } @@ -137,19 +137,19 @@ fn test_optopt_long() { #[test] fn test_optopt_long_missing() { - let args = [~"blah"]; - let opts = [opt::optopt(~"test")]; + let args = ["blah"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"test")); } + opt::success(m) { assert (!opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optopt_long_no_arg() { - let args = [~"--test"]; - let opts = [opt::optopt(~"test")]; + let args = ["--test"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -159,8 +159,8 @@ fn test_optopt_long_no_arg() { #[test] fn test_optopt_long_multi() { - let args = [~"--test=20", ~"--test=30"]; - let opts = [opt::optopt(~"test")]; + let args = ["--test=20", "--test=30"]; + let opts = [opt::optopt("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -170,13 +170,13 @@ fn test_optopt_long_multi() { #[test] fn test_optopt_short() { - let args = [~"-t", ~"20"]; - let opts = [opt::optopt(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); } _ { fail; } } @@ -184,19 +184,19 @@ fn test_optopt_short() { #[test] fn test_optopt_short_missing() { - let args = [~"blah"]; - let opts = [opt::optopt(~"t")]; + let args = ["blah"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"t")); } + opt::success(m) { assert (!opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optopt_short_no_arg() { - let args = [~"-t"]; - let opts = [opt::optopt(~"t")]; + let args = ["-t"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -206,8 +206,8 @@ fn test_optopt_short_no_arg() { #[test] fn test_optopt_short_multi() { - let args = [~"-t", ~"20", ~"-t", ~"30"]; - let opts = [opt::optopt(~"t")]; + let args = ["-t", "20", "-t", "30"]; + let opts = [opt::optopt("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -219,30 +219,30 @@ fn test_optopt_short_multi() { // Tests for optflag #[test] fn test_optflag_long() { - let args = [~"--test"]; - let opts = [opt::optflag(~"test")]; + let args = ["--test"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (opt::opt_present(m, ~"test")); } + opt::success(m) { assert (opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optflag_long_missing() { - let args = [~"blah"]; - let opts = [opt::optflag(~"test")]; + let args = ["blah"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"test")); } + opt::success(m) { assert (!opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optflag_long_arg() { - let args = [~"--test=20"]; - let opts = [opt::optflag(~"test")]; + let args = ["--test=20"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { @@ -255,8 +255,8 @@ fn test_optflag_long_arg() { #[test] fn test_optflag_long_multi() { - let args = [~"--test", ~"--test"]; - let opts = [opt::optflag(~"test")]; + let args = ["--test", "--test"]; + let opts = [opt::optflag("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -266,36 +266,36 @@ fn test_optflag_long_multi() { #[test] fn test_optflag_short() { - let args = [~"-t"]; - let opts = [opt::optflag(~"t")]; + let args = ["-t"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (opt::opt_present(m, ~"t")); } + opt::success(m) { assert (opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optflag_short_missing() { - let args = [~"blah"]; - let opts = [opt::optflag(~"t")]; + let args = ["blah"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"t")); } + opt::success(m) { assert (!opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optflag_short_arg() { - let args = [~"-t", ~"20"]; - let opts = [opt::optflag(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { // The next variable after the flag is just a free argument - assert (m.free[0] == ~"20"); + assert (m.free[0] == "20"); } _ { fail; } } @@ -303,8 +303,8 @@ fn test_optflag_short_arg() { #[test] fn test_optflag_short_multi() { - let args = [~"-t", ~"-t"]; - let opts = [opt::optflag(~"t")]; + let args = ["-t", "-t"]; + let opts = [opt::optflag("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, option_duplicated); } @@ -316,13 +316,13 @@ fn test_optflag_short_multi() { // Tests for optmulti #[test] fn test_optmulti_long() { - let args = [~"--test=20"]; - let opts = [opt::optmulti(~"test")]; + let args = ["--test=20"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); } _ { fail; } } @@ -330,19 +330,19 @@ fn test_optmulti_long() { #[test] fn test_optmulti_long_missing() { - let args = [~"blah"]; - let opts = [opt::optmulti(~"test")]; + let args = ["blah"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"test")); } + opt::success(m) { assert (!opt::opt_present(m, "test")); } _ { fail; } } } #[test] fn test_optmulti_long_no_arg() { - let args = [~"--test"]; - let opts = [opt::optmulti(~"test")]; + let args = ["--test"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -352,15 +352,15 @@ fn test_optmulti_long_no_arg() { #[test] fn test_optmulti_long_multi() { - let args = [~"--test=20", ~"--test=30"]; - let opts = [opt::optmulti(~"test")]; + let args = ["--test=20", "--test=30"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"test")); - assert (opt::opt_str(m, ~"test") == ~"20"); - assert (opt::opt_strs(m, ~"test")[0] == ~"20"); - assert (opt::opt_strs(m, ~"test")[1] == ~"30"); + assert (opt::opt_present(m, "test")); + assert (opt::opt_str(m, "test") == "20"); + assert (opt::opt_strs(m, "test")[0] == "20"); + assert (opt::opt_strs(m, "test")[1] == "30"); } _ { fail; } } @@ -368,13 +368,13 @@ fn test_optmulti_long_multi() { #[test] fn test_optmulti_short() { - let args = [~"-t", ~"20"]; - let opts = [opt::optmulti(~"t")]; + let args = ["-t", "20"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); } _ { fail; } } @@ -382,19 +382,19 @@ fn test_optmulti_short() { #[test] fn test_optmulti_short_missing() { - let args = [~"blah"]; - let opts = [opt::optmulti(~"t")]; + let args = ["blah"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { - opt::success(m) { assert (!opt::opt_present(m, ~"t")); } + opt::success(m) { assert (!opt::opt_present(m, "t")); } _ { fail; } } } #[test] fn test_optmulti_short_no_arg() { - let args = [~"-t"]; - let opts = [opt::optmulti(~"t")]; + let args = ["-t"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, argument_missing); } @@ -404,15 +404,15 @@ fn test_optmulti_short_no_arg() { #[test] fn test_optmulti_short_multi() { - let args = [~"-t", ~"20", ~"-t", ~"30"]; - let opts = [opt::optmulti(~"t")]; + let args = ["-t", "20", "-t", "30"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (opt::opt_present(m, ~"t")); - assert (opt::opt_str(m, ~"t") == ~"20"); - assert (opt::opt_strs(m, ~"t")[0] == ~"20"); - assert (opt::opt_strs(m, ~"t")[1] == ~"30"); + assert (opt::opt_present(m, "t")); + assert (opt::opt_str(m, "t") == "20"); + assert (opt::opt_strs(m, "t")[0] == "20"); + assert (opt::opt_strs(m, "t")[1] == "30"); } _ { fail; } } @@ -420,8 +420,8 @@ fn test_optmulti_short_multi() { #[test] fn test_unrecognized_option_long() { - let args = [~"--untest"]; - let opts = [opt::optmulti(~"t")]; + let args = ["--untest"]; + let opts = [opt::optmulti("t")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, unrecognized_option); } @@ -431,8 +431,8 @@ fn test_unrecognized_option_long() { #[test] fn test_unrecognized_option_short() { - let args = [~"-t"]; - let opts = [opt::optmulti(~"test")]; + let args = ["-t"]; + let opts = [opt::optmulti("test")]; let rs = opt::getopts(args, opts); alt rs { opt::failure(f) { check_fail_type(f, unrecognized_option); } @@ -443,25 +443,24 @@ fn test_unrecognized_option_short() { #[test] fn test_combined() { let args = - [~"prog", ~"free1", ~"-s", ~"20", ~"free2", ~"--flag", - ~"--long=30", ~"-f", ~"-m", ~"40", ~"-m", ~"50"]; + ["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", "-f", + "-m", "40", "-m", "50"]; let opts = - [opt::optopt(~"s"), opt::optflag(~"flag"), opt::reqopt(~"long"), - opt::optflag(~"f"), opt::optmulti(~"m"), - opt::optopt(~"notpresent")]; + [opt::optopt("s"), opt::optflag("flag"), opt::reqopt("long"), + opt::optflag("f"), opt::optmulti("m"), opt::optopt("notpresent")]; let rs = opt::getopts(args, opts); alt rs { opt::success(m) { - assert (m.free[0] == ~"prog"); - assert (m.free[1] == ~"free1"); - assert (opt::opt_str(m, ~"s") == ~"20"); - assert (m.free[2] == ~"free2"); - assert (opt::opt_present(m, ~"flag")); - assert (opt::opt_str(m, ~"long") == ~"30"); - assert (opt::opt_present(m, ~"f")); - assert (opt::opt_strs(m, ~"m")[0] == ~"40"); - assert (opt::opt_strs(m, ~"m")[1] == ~"50"); - assert (!opt::opt_present(m, ~"notpresent")); + assert (m.free[0] == "prog"); + assert (m.free[1] == "free1"); + assert (opt::opt_str(m, "s") == "20"); + assert (m.free[2] == "free2"); + assert (opt::opt_present(m, "flag")); + assert (opt::opt_str(m, "long") == "30"); + assert (opt::opt_present(m, "f")); + assert (opt::opt_strs(m, "m")[0] == "40"); + assert (opt::opt_strs(m, "m")[1] == "50"); + assert (!opt::opt_present(m, "notpresent")); } _ { fail; } } diff --git a/src/test/stdtest/int.rs b/src/test/stdtest/int.rs index bc13e248d0b..61d3448a175 100644 --- a/src/test/stdtest/int.rs +++ b/src/test/stdtest/int.rs @@ -5,11 +5,11 @@ import std::str::eq; #[test] fn test_to_str() { - assert (eq(int::to_str(0, 10u), ~"0")); - assert (eq(int::to_str(1, 10u), ~"1")); - assert (eq(int::to_str(-1, 10u), ~"-1")); - assert (eq(int::to_str(255, 16u), ~"ff")); - assert (eq(int::to_str(100, 10u), ~"100")); + assert (eq(int::to_str(0, 10u), "0")); + assert (eq(int::to_str(1, 10u), "1")); + assert (eq(int::to_str(-1, 10u), "-1")); + assert (eq(int::to_str(255, 16u), "ff")); + assert (eq(int::to_str(100, 10u), "100")); } #[test] diff --git a/src/test/stdtest/io.rs b/src/test/stdtest/io.rs index a66b3bab464..08330c619fc 100644 --- a/src/test/stdtest/io.rs +++ b/src/test/stdtest/io.rs @@ -7,9 +7,9 @@ import std::str; #[cfg(target_os = "win32")] #[test] fn test_simple() { - let tmpfile: istr = ~"test/run-pass/lib-io-test-simple.tmp"; + let tmpfile: str = "test/run-pass/lib-io-test-simple.tmp"; log tmpfile; - let frood: istr = ~"A hoopy frood who really knows where his towel is."; + let frood: str = "A hoopy frood who really knows where his towel is."; log frood; { let out: io::writer = @@ -17,7 +17,7 @@ fn test_simple() { out.write_str(frood); } let inp: io::reader = io::file_reader(tmpfile); - let frood2: istr = inp.read_c_str(); + let frood2: str = inp.read_c_str(); log frood2; assert (str::eq(frood, frood2)); } diff --git a/src/test/stdtest/map.rs b/src/test/stdtest/map.rs index 585bae03cc9..67240a7c69b 100644 --- a/src/test/stdtest/map.rs +++ b/src/test/stdtest/map.rs @@ -14,8 +14,8 @@ fn test_simple() { fn eq_uint(x: &uint, y: &uint) -> bool { ret x == y; } let hasher_uint: map::hashfn<uint> = util::id; let eqer_uint: map::eqfn<uint> = eq_uint; - let hasher_str: map::hashfn<istr> = str::hash; - let eqer_str: map::eqfn<istr> = str::eq; + let hasher_str: map::hashfn<str> = str::hash; + let eqer_str: map::eqfn<str> = str::eq; log "uint -> uint"; let hm_uu: map::hashmap<uint, uint> = map::mk_hashmap::<uint, uint>(hasher_uint, eqer_uint); @@ -29,49 +29,49 @@ fn test_simple() { assert (hm_uu.get(12u) == 14u); assert (!hm_uu.insert(12u, 12u)); assert (hm_uu.get(12u) == 12u); - let ten: istr = ~"ten"; - let eleven: istr = ~"eleven"; - let twelve: istr = ~"twelve"; + let ten: str = "ten"; + let eleven: str = "eleven"; + let twelve: str = "twelve"; log "str -> uint"; - let hm_su: map::hashmap<istr, uint> = - map::mk_hashmap::<istr, uint>(hasher_str, eqer_str); - assert (hm_su.insert(~"ten", 12u)); + let hm_su: map::hashmap<str, uint> = + map::mk_hashmap::<str, uint>(hasher_str, eqer_str); + assert (hm_su.insert("ten", 12u)); assert (hm_su.insert(eleven, 13u)); - assert (hm_su.insert(~"twelve", 14u)); + assert (hm_su.insert("twelve", 14u)); assert (hm_su.get(eleven) == 13u); - assert (hm_su.get(~"eleven") == 13u); - assert (hm_su.get(~"twelve") == 14u); - assert (hm_su.get(~"ten") == 12u); - assert (!hm_su.insert(~"twelve", 14u)); - assert (hm_su.get(~"twelve") == 14u); - assert (!hm_su.insert(~"twelve", 12u)); - assert (hm_su.get(~"twelve") == 12u); + assert (hm_su.get("eleven") == 13u); + assert (hm_su.get("twelve") == 14u); + assert (hm_su.get("ten") == 12u); + assert (!hm_su.insert("twelve", 14u)); + assert (hm_su.get("twelve") == 14u); + assert (!hm_su.insert("twelve", 12u)); + assert (hm_su.get("twelve") == 12u); log "uint -> str"; - let hm_us: map::hashmap<uint, istr> = - map::mk_hashmap::<uint, istr>(hasher_uint, eqer_uint); - assert (hm_us.insert(10u, ~"twelve")); - assert (hm_us.insert(11u, ~"thirteen")); - assert (hm_us.insert(12u, ~"fourteen")); - assert (str::eq(hm_us.get(11u), ~"thirteen")); - assert (str::eq(hm_us.get(12u), ~"fourteen")); - assert (str::eq(hm_us.get(10u), ~"twelve")); - assert (!hm_us.insert(12u, ~"fourteen")); - assert (str::eq(hm_us.get(12u), ~"fourteen")); - assert (!hm_us.insert(12u, ~"twelve")); - assert (str::eq(hm_us.get(12u), ~"twelve")); + let hm_us: map::hashmap<uint, str> = + map::mk_hashmap::<uint, str>(hasher_uint, eqer_uint); + assert (hm_us.insert(10u, "twelve")); + assert (hm_us.insert(11u, "thirteen")); + assert (hm_us.insert(12u, "fourteen")); + assert (str::eq(hm_us.get(11u), "thirteen")); + assert (str::eq(hm_us.get(12u), "fourteen")); + assert (str::eq(hm_us.get(10u), "twelve")); + assert (!hm_us.insert(12u, "fourteen")); + assert (str::eq(hm_us.get(12u), "fourteen")); + assert (!hm_us.insert(12u, "twelve")); + assert (str::eq(hm_us.get(12u), "twelve")); log "str -> str"; - let hm_ss: map::hashmap<istr, istr> = - map::mk_hashmap::<istr, istr>(hasher_str, eqer_str); - assert (hm_ss.insert(ten, ~"twelve")); - assert (hm_ss.insert(eleven, ~"thirteen")); - assert (hm_ss.insert(twelve, ~"fourteen")); - assert (str::eq(hm_ss.get(~"eleven"), ~"thirteen")); - assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); - assert (str::eq(hm_ss.get(~"ten"), ~"twelve")); - assert (!hm_ss.insert(~"twelve", ~"fourteen")); - assert (str::eq(hm_ss.get(~"twelve"), ~"fourteen")); - assert (!hm_ss.insert(~"twelve", ~"twelve")); - assert (str::eq(hm_ss.get(~"twelve"), ~"twelve")); + let hm_ss: map::hashmap<str, str> = + map::mk_hashmap::<str, str>(hasher_str, eqer_str); + assert (hm_ss.insert(ten, "twelve")); + assert (hm_ss.insert(eleven, "thirteen")); + assert (hm_ss.insert(twelve, "fourteen")); + assert (str::eq(hm_ss.get("eleven"), "thirteen")); + assert (str::eq(hm_ss.get("twelve"), "fourteen")); + assert (str::eq(hm_ss.get("ten"), "twelve")); + assert (!hm_ss.insert("twelve", "fourteen")); + assert (str::eq(hm_ss.get("twelve"), "fourteen")); + assert (!hm_ss.insert("twelve", "twelve")); + assert (str::eq(hm_ss.get("twelve"), "twelve")); log "*** finished test_simple"; } @@ -92,14 +92,14 @@ fn test_growth() { let i: uint = 0u; while i < num_to_insert { assert (hm_uu.insert(i, i * i)); - log ~"inserting " + uint::to_str(i, 10u) + ~" -> " + + log "inserting " + uint::to_str(i, 10u) + " -> " + uint::to_str(i * i, 10u); i += 1u; } log "-----"; i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; @@ -110,44 +110,42 @@ fn test_growth() { hm_uu.rehash(); i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm_uu.get(i), 10u); assert (hm_uu.get(i) == i * i); i += 1u; } log "str -> str"; - let hasher_str: map::hashfn<istr> = str::hash; - let eqer_str: map::eqfn<istr> = str::eq; - let hm_ss: map::hashmap<istr, istr> = - map::mk_hashmap::<istr, istr>(hasher_str, eqer_str); + let hasher_str: map::hashfn<str> = str::hash; + let eqer_str: map::eqfn<str> = str::eq; + let hm_ss: map::hashmap<str, str> = + map::mk_hashmap::<str, str>(hasher_str, eqer_str); i = 0u; while i < num_to_insert { - assert (hm_ss.insert(uint::to_str(i, 2u), - uint::to_str(i * i, 2u))); - log ~"inserting \"" + uint::to_str(i, 2u) + ~"\" -> \"" + - uint::to_str(i * i, 2u) + ~"\""; + assert (hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u))); + log "inserting \"" + uint::to_str(i, 2u) + "\" -> \"" + + uint::to_str(i * i, 2u) + "\""; i += 1u; } log "-----"; i = 0u; while i < num_to_insert { - log ~"get(\"" + uint::to_str(i, 2u) + ~"\") = \"" + - hm_ss.get(uint::to_str(i, 2u)) + ~"\""; + log "get(\"" + uint::to_str(i, 2u) + "\") = \"" + + hm_ss.get(uint::to_str(i, 2u)) + "\""; assert (str::eq(hm_ss.get(uint::to_str(i, 2u)), uint::to_str(i * i, 2u))); i += 1u; } assert (hm_ss.insert(uint::to_str(num_to_insert, 2u), uint::to_str(17u, 2u))); - assert (str::eq(hm_ss.get( - uint::to_str(num_to_insert, 2u)), + assert (str::eq(hm_ss.get(uint::to_str(num_to_insert, 2u)), uint::to_str(17u, 2u))); log "-----"; hm_ss.rehash(); i = 0u; while i < num_to_insert { - log ~"get(\"" + uint::to_str(i, 2u) + ~"\") = \"" + - hm_ss.get(uint::to_str(i, 2u)) + ~"\""; + log "get(\"" + uint::to_str(i, 2u) + "\") = \"" + + hm_ss.get(uint::to_str(i, 2u)) + "\""; assert (str::eq(hm_ss.get(uint::to_str(i, 2u)), uint::to_str(i * i, 2u))); i += 1u; @@ -176,7 +174,7 @@ fn test_removal() { let i: uint = 0u; while i < num_to_insert { assert (hm.insert(i, i * i)); - log ~"inserting " + uint::to_str(i, 10u) + ~" -> " + + log "inserting " + uint::to_str(i, 10u) + " -> " + uint::to_str(i * i, 10u); i += 1u; } @@ -186,10 +184,8 @@ fn test_removal() { i = 0u; while i < num_to_insert { let v = hm.remove(i); - alt (v) { - option::some(u) { - assert (u == (i * i)); - } + alt v { + option::some(u) { assert (u == i * i); } option::none. { fail; } } i += 2u; @@ -198,7 +194,7 @@ fn test_removal() { log "-----"; i = 1u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; @@ -209,7 +205,7 @@ fn test_removal() { log "-----"; i = 1u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 2u; @@ -218,7 +214,7 @@ fn test_removal() { i = 0u; while i < num_to_insert { assert (hm.insert(i, i * i)); - log ~"inserting " + uint::to_str(i, 10u) + ~" -> " + + log "inserting " + uint::to_str(i, 10u) + " -> " + uint::to_str(i * i, 10u); i += 2u; } @@ -226,7 +222,7 @@ fn test_removal() { log "-----"; i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; @@ -238,7 +234,7 @@ fn test_removal() { assert (hm.size() == num_to_insert); i = 0u; while i < num_to_insert { - log ~"get(" + uint::to_str(i, 10u) + ~") = " + + log "get(" + uint::to_str(i, 10u) + ") = " + uint::to_str(hm.get(i), 10u); assert (hm.get(i) == i * i); i += 1u; @@ -248,18 +244,18 @@ fn test_removal() { #[test] fn test_contains_key() { - let key = ~"k"; - let map = map::mk_hashmap::<istr, istr>(str::hash, str::eq); + let key = "k"; + let map = map::mk_hashmap::<str, str>(str::hash, str::eq); assert (!map.contains_key(key)); - map.insert(key, ~"val"); + map.insert(key, "val"); assert (map.contains_key(key)); } #[test] fn test_find() { - let key = ~"k"; - let map = map::mk_hashmap::<istr, istr>(str::hash, str::eq); + let key = "k"; + let map = map::mk_hashmap::<str, str>(str::hash, str::eq); assert (std::option::is_none(map.find(key))); - map.insert(key, ~"val"); - assert (std::option::get(map.find(key)) == ~"val"); + map.insert(key, "val"); + assert (std::option::get(map.find(key)) == "val"); } diff --git a/src/test/stdtest/net.rs b/src/test/stdtest/net.rs index d2f185a4fde..9da7a12a060 100644 --- a/src/test/stdtest/net.rs +++ b/src/test/stdtest/net.rs @@ -3,12 +3,10 @@ import std::net; #[test] fn test_format_ip() { - assert (net::format_addr(net::ipv4( - 127u8, 0u8, 0u8, 1u8)) == ~"127.0.0.1") + assert (net::format_addr(net::ipv4(127u8, 0u8, 0u8, 1u8)) == "127.0.0.1") } #[test] fn test_parse_ip() { - assert (net::parse_addr(~"127.0.0.1") - == net::ipv4(127u8, 0u8, 0u8, 1u8)); + assert (net::parse_addr("127.0.0.1") == net::ipv4(127u8, 0u8, 0u8, 1u8)); } diff --git a/src/test/stdtest/os.rs b/src/test/stdtest/os.rs index fc508595329..49ebb217dbf 100644 --- a/src/test/stdtest/os.rs +++ b/src/test/stdtest/os.rs @@ -6,26 +6,26 @@ import std::option; fn test_setenv() { // NB: Each test of setenv needs to use different variable names or the // tests will not be threadsafe - setenv(~"NAME1", ~"VALUE"); - assert (getenv(~"NAME1") == option::some(~"VALUE")); + setenv("NAME1", "VALUE"); + assert (getenv("NAME1") == option::some("VALUE")); } #[test] fn test_setenv_overwrite() { - setenv(~"NAME2", ~"1"); - setenv(~"NAME2", ~"2"); - assert (getenv(~"NAME2") == option::some(~"2")); + setenv("NAME2", "1"); + setenv("NAME2", "2"); + assert (getenv("NAME2") == option::some("2")); } // Windows GetEnvironmentVariable requires some extra work to make sure // the buffer the variable is copied into is the right size #[test] fn test_getenv_big() { - let s = ~""; + let s = ""; let i = 0; - while i < 100 { s += ~"aaaaaaaaaa"; i += 1; } - setenv(~"NAME3", s); - assert (getenv(~"NAME3") == option::some(s)); + while i < 100 { s += "aaaaaaaaaa"; i += 1; } + setenv("NAME3", s); + assert (getenv("NAME3") == option::some(s)); } // Local Variables: diff --git a/src/test/stdtest/path.rs b/src/test/stdtest/path.rs index 82fe54413d9..911bc6b0dd9 100644 --- a/src/test/stdtest/path.rs +++ b/src/test/stdtest/path.rs @@ -8,10 +8,10 @@ import std::os; #[test] fn test() { - assert (!fs::path_is_absolute(~"test-path")); + assert (!fs::path_is_absolute("test-path")); - log ~"Current working directory: " + os::getcwd(); + log "Current working directory: " + os::getcwd(); - log fs::make_absolute(~"test-path"); - log fs::make_absolute(~"/usr/bin"); + log fs::make_absolute("test-path"); + log fs::make_absolute("/usr/bin"); } diff --git a/src/test/stdtest/qsort.rs b/src/test/stdtest/qsort.rs index 32109dc1caa..609adf3afe4 100644 --- a/src/test/stdtest/qsort.rs +++ b/src/test/stdtest/qsort.rs @@ -51,8 +51,8 @@ fn test_simple() { let immut_names = vec::from_mut(names); - // Silly, but what else can we do? - check vec::same_length(expected, immut_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 { log #fmt["%d %d", a, b]; assert (a == b); } } diff --git a/src/test/stdtest/run.rs b/src/test/stdtest/run.rs index 5c62ed3eb0e..b60a3935500 100644 --- a/src/test/stdtest/run.rs +++ b/src/test/stdtest/run.rs @@ -11,9 +11,9 @@ import std::vec; #[cfg(target_os = "macos")] #[test] fn test_leaks() { - run::run_program(~"echo", []); - run::start_program(~"echo", []); - run::program_output(~"echo", []); + run::run_program("echo", []); + run::start_program("echo", []); + run::program_output("echo", []); } // FIXME @@ -29,14 +29,13 @@ fn test_pipes() { let pipe_err = os::pipe(); let pid = - run::spawn_process(~"cat", [], - pipe_in.in, pipe_out.out, pipe_err.out); + run::spawn_process("cat", [], pipe_in.in, pipe_out.out, pipe_err.out); os::libc::close(pipe_in.in); os::libc::close(pipe_out.out); os::libc::close(pipe_err.out); if pid == -1 { fail; } - let expected = ~"test"; + let expected = "test"; writeclose(pipe_in.out, expected); let actual = readclose(pipe_out.in); readclose(pipe_err.in); @@ -46,18 +45,18 @@ fn test_pipes() { log actual; assert (expected == actual); - fn writeclose(fd: int, s: &istr) { + fn writeclose(fd: int, s: &str) { let writer = io::new_writer(io::fd_buf_writer(fd, option::none)); writer.write_str(s); os::libc::close(fd); } - fn readclose(fd: int) -> istr { + fn readclose(fd: int) -> str { // Copied from run::program_output let file = os::fd_FILE(fd); let reader = io::new_reader(io::FILE_buf_reader(file, option::none)); - let buf = ~""; + let buf = ""; while !reader.eof() { let bytes = reader.read_bytes(4096u); buf += str::unsafe_from_bytes(bytes); diff --git a/src/test/stdtest/sha1.rs b/src/test/stdtest/sha1.rs index a66b898ddfa..6b72be20dd5 100644 --- a/src/test/stdtest/sha1.rs +++ b/src/test/stdtest/sha1.rs @@ -9,24 +9,24 @@ import std::str; #[test] fn test() { - type test = {input: istr, output: [u8]}; + type test = {input: str, output: [u8]}; - fn a_million_letter_a() -> istr { + fn a_million_letter_a() -> str { let i = 0; - let rs = ~""; - while i < 100000 { rs += ~"aaaaaaaaaa"; i += 1; } + let rs = ""; + while i < 100000 { rs += "aaaaaaaaaa"; i += 1; } ret rs; } // Test messages from FIPS 180-1 let fips_180_1_tests: [test] = - [{input: ~"abc", + [{input: "abc", output: [0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8, 0x06u8, 0x81u8, 0x6Au8, 0xBAu8, 0x3Eu8, 0x25u8, 0x71u8, 0x78u8, 0x50u8, 0xC2u8, 0x6Cu8, 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]}, - {input: ~"abcdbcdecdefdefgefghfghighij" - + ~"hijkijkljklmklmnlmnomnopnopq", + {input: + "abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq", output: [0x84u8, 0x98u8, 0x3Eu8, 0x44u8, 0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8, 0xBAu8, 0xAEu8, 0x4Au8, 0xA1u8, 0xF9u8, 0x51u8, 0x29u8, 0xE5u8, @@ -39,12 +39,12 @@ fn test() { // Examples from wikipedia let wikipedia_tests: [test] = - [{input: ~"The quick brown fox jumps over the lazy dog", + [{input: "The quick brown fox jumps over the lazy dog", output: [0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8, 0x2du8, 0x28u8, 0xfcu8, 0xedu8, 0x84u8, 0x9eu8, 0xe1u8, 0xbbu8, 0x76u8, 0xe7u8, 0x39u8, 0x1bu8, 0x93u8, 0xebu8, 0x12u8]}, - {input: ~"The quick brown fox jumps over the lazy cog", + {input: "The quick brown fox jumps over the lazy cog", output: [0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8, 0x5eu8, 0x1bu8, 0x3au8, 0xfau8, 0xd3u8, 0xe8u8, 0x5au8, 0x0bu8, 0xd1u8, 0x7du8, 0x9bu8, diff --git a/src/test/stdtest/str.rs b/src/test/stdtest/str.rs index a559b61d3f2..2852822f8d4 100644 --- a/src/test/stdtest/str.rs +++ b/src/test/stdtest/str.rs @@ -3,105 +3,103 @@ import std::vec; #[test] fn test_eq() { - assert str::eq(~"", ~""); - assert str::eq(~"foo", ~"foo"); - assert !str::eq(~"foo", ~"bar"); + assert (str::eq("", "")); + assert (str::eq("foo", "foo")); + assert (!str::eq("foo", "bar")); } #[test] fn test_lteq() { - assert str::lteq(~"", ~""); - assert str::lteq(~"", ~"foo"); - assert str::lteq(~"foo", ~"foo"); - assert !str::eq(~"foo", ~"bar"); + assert (str::lteq("", "")); + assert (str::lteq("", "foo")); + assert (str::lteq("foo", "foo")); + assert (!str::eq("foo", "bar")); } #[test] fn test_bytes_len() { - assert (str::byte_len(~"") == 0u); - assert (str::byte_len(~"hello world") == 11u); - assert (str::byte_len(~"\x63") == 1u); - assert (str::byte_len(~"\xa2") == 2u); - assert (str::byte_len(~"\u03c0") == 2u); - assert (str::byte_len(~"\u2620") == 3u); - assert (str::byte_len(~"\U0001d11e") == 4u); + assert (str::byte_len("") == 0u); + assert (str::byte_len("hello world") == 11u); + assert (str::byte_len("\x63") == 1u); + assert (str::byte_len("\xa2") == 2u); + assert (str::byte_len("\u03c0") == 2u); + assert (str::byte_len("\u2620") == 3u); + assert (str::byte_len("\U0001d11e") == 4u); } #[test] fn test_index_and_rindex() { - assert (str::index(~"hello", 'e' as u8) == 1); - assert (str::index(~"hello", 'o' as u8) == 4); - assert (str::index(~"hello", 'z' as u8) == -1); - assert (str::rindex(~"hello", 'l' as u8) == 3); - assert (str::rindex(~"hello", 'h' as u8) == 0); - assert (str::rindex(~"hello", 'z' as u8) == -1); + assert (str::index("hello", 'e' as u8) == 1); + assert (str::index("hello", 'o' as u8) == 4); + assert (str::index("hello", 'z' as u8) == -1); + assert (str::rindex("hello", 'l' as u8) == 3); + assert (str::rindex("hello", 'h' as u8) == 0); + assert (str::rindex("hello", 'z' as u8) == -1); } #[test] fn test_split() { - fn t(s: &istr, c: char, i: int, k: &istr) { - log ~"splitting: " + s; + fn t(s: &str, c: char, i: int, k: &str) { + log "splitting: " + s; log i; let v = str::split(s, c as u8); - log ~"split to: "; - for z: istr in v { log z; } - log ~"comparing: " + v[i] + ~" vs. " + k; + log "split to: "; + for z: str in v { log z; } + log "comparing: " + v[i] + " vs. " + k; assert (str::eq(v[i], k)); } - t(~"abc.hello.there", '.', 0, ~"abc"); - t(~"abc.hello.there", '.', 1, ~"hello"); - t(~"abc.hello.there", '.', 2, ~"there"); - t(~".hello.there", '.', 0, ~""); - t(~".hello.there", '.', 1, ~"hello"); - t(~"...hello.there.", '.', 3, ~"hello"); - t(~"...hello.there.", '.', 5, ~""); + t("abc.hello.there", '.', 0, "abc"); + t("abc.hello.there", '.', 1, "hello"); + t("abc.hello.there", '.', 2, "there"); + t(".hello.there", '.', 0, ""); + t(".hello.there", '.', 1, "hello"); + t("...hello.there.", '.', 3, "hello"); + t("...hello.there.", '.', 5, ""); } #[test] fn test_find() { - fn t(haystack: &istr, needle: &istr, i: int) { + fn t(haystack: &str, needle: &str, i: int) { let j: int = str::find(haystack, needle); - log ~"searched for " + needle; + log "searched for " + needle; log j; assert (i == j); } - t(~"this is a simple", ~"is a", 5); - t(~"this is a simple", ~"is z", -1); - t(~"this is a simple", ~"", 0); - t(~"this is a simple", ~"simple", 10); - t(~"this", ~"simple", -1); + t("this is a simple", "is a", 5); + t("this is a simple", "is z", -1); + t("this is a simple", "", 0); + t("this is a simple", "simple", 10); + t("this", "simple", -1); } #[test] fn test_substr() { - fn t(a: &istr, b: &istr, start: int) { - assert (str::eq(str::substr(a, start as uint, - str::byte_len(b)), b)); + fn t(a: &str, b: &str, start: int) { + assert (str::eq(str::substr(a, start as uint, str::byte_len(b)), b)); } - t(~"hello", ~"llo", 2); - t(~"hello", ~"el", 1); - t(~"substr should not be a challenge", ~"not", 14); + t("hello", "llo", 2); + t("hello", "el", 1); + t("substr should not be a challenge", "not", 14); } #[test] fn test_concat() { - fn t(v: &[istr], s: &istr) { assert (str::eq(str::concat(v), s)); } - t([~"you", ~"know", ~"I'm", ~"no", ~"good"], ~"youknowI'mnogood"); - let v: [istr] = []; - t(v, ~""); - t([~"hi"], ~"hi"); + fn t(v: &[str], s: &str) { assert (str::eq(str::concat(v), s)); } + t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); + let v: [str] = []; + t(v, ""); + t(["hi"], "hi"); } #[test] fn test_connect() { - fn t(v: &[istr], sep: &istr, s: &istr) { + fn t(v: &[str], sep: &str, s: &str) { assert (str::eq(str::connect(v, sep), s)); } - t([~"you", ~"know", ~"I'm", ~"no", ~"good"], ~" ", - ~"you know I'm no good"); - let v: [istr] = []; - t(v, ~" ", ~""); - t([~"hi"], ~" ", ~"hi"); + t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good"); + let v: [str] = []; + t(v, " ", ""); + t(["hi"], " ", "hi"); } #[test] @@ -109,28 +107,28 @@ fn test_to_upper() { // to_upper doesn't understand unicode yet, // but we need to at least preserve it - let unicode = ~"\u65e5\u672c"; - let input = ~"abcDEF" + unicode + ~"xyz:.;"; - let expected = ~"ABCDEF" + unicode + ~"XYZ:.;"; + let unicode = "\u65e5\u672c"; + let input = "abcDEF" + unicode + "xyz:.;"; + let expected = "ABCDEF" + unicode + "XYZ:.;"; let actual = str::to_upper(input); assert (str::eq(expected, actual)); } #[test] fn test_slice() { - assert (str::eq(~"ab", str::slice(~"abc", 0u, 2u))); - assert (str::eq(~"bc", str::slice(~"abc", 1u, 3u))); - assert (str::eq(~"", str::slice(~"abc", 1u, 1u))); - fn a_million_letter_a() -> istr { + assert (str::eq("ab", str::slice("abc", 0u, 2u))); + assert (str::eq("bc", str::slice("abc", 1u, 3u))); + assert (str::eq("", str::slice("abc", 1u, 1u))); + fn a_million_letter_a() -> str { let i = 0; - let rs = ~""; - while i < 100000 { rs += ~"aaaaaaaaaa"; i += 1; } + let rs = ""; + while i < 100000 { rs += "aaaaaaaaaa"; i += 1; } ret rs; } - fn half_a_million_letter_a() -> istr { + fn half_a_million_letter_a() -> str { let i = 0; - let rs = ~""; - while i < 100000 { rs += ~"aaaaa"; i += 1; } + let rs = ""; + while i < 100000 { rs += "aaaaa"; i += 1; } ret rs; } assert (str::eq(half_a_million_letter_a(), @@ -139,123 +137,122 @@ fn test_slice() { #[test] fn test_starts_with() { - assert (str::starts_with(~"", ~"")); - assert (str::starts_with(~"abc", ~"")); - assert (str::starts_with(~"abc", ~"a")); - assert (!str::starts_with(~"a", ~"abc")); - assert (!str::starts_with(~"", ~"abc")); + assert (str::starts_with("", "")); + assert (str::starts_with("abc", "")); + assert (str::starts_with("abc", "a")); + assert (!str::starts_with("a", "abc")); + assert (!str::starts_with("", "abc")); } #[test] fn test_ends_with() { - assert (str::ends_with(~"", ~"")); - assert (str::ends_with(~"abc", ~"")); - assert (str::ends_with(~"abc", ~"c")); - assert (!str::ends_with(~"a", ~"abc")); - assert (!str::ends_with(~"", ~"abc")); + assert (str::ends_with("", "")); + assert (str::ends_with("abc", "")); + assert (str::ends_with("abc", "c")); + assert (!str::ends_with("a", "abc")); + assert (!str::ends_with("", "abc")); } #[test] fn test_is_empty() { - assert (str::is_empty(~"")); - assert (!str::is_empty(~"a")); + assert (str::is_empty("")); + assert (!str::is_empty("a")); } #[test] fn test_is_not_empty() { - assert (str::is_not_empty(~"a")); - assert (!str::is_not_empty(~"")); + assert (str::is_not_empty("a")); + assert (!str::is_not_empty("")); } #[test] fn test_replace() { - let a = ~"a"; + let a = "a"; check (str::is_not_empty(a)); - assert (str::replace(~"", a, ~"b") == ~""); - assert (str::replace(~"a", a, ~"b") == ~"b"); - assert (str::replace(~"ab", a, ~"b") == ~"bb"); - let test = ~"test"; + assert (str::replace("", a, "b") == ""); + assert (str::replace("a", a, "b") == "b"); + assert (str::replace("ab", a, "b") == "bb"); + let test = "test"; check (str::is_not_empty(test)); - assert (str::replace(~" test test ", test, ~"toast") - == ~" toast toast "); - assert (str::replace(~" test test ", test, ~"") == ~" "); + assert (str::replace(" test test ", test, "toast") == " toast toast "); + assert (str::replace(" test test ", test, "") == " "); } #[test] fn test_char_slice() { - assert (str::eq(~"ab", str::char_slice(~"abc", 0u, 2u))); - assert (str::eq(~"bc", str::char_slice(~"abc", 1u, 3u))); - assert (str::eq(~"", str::char_slice(~"abc", 1u, 1u))); - assert (str::eq(~"\u65e5", str::char_slice(~"\u65e5\u672c", 0u, 1u))); + assert (str::eq("ab", str::char_slice("abc", 0u, 2u))); + assert (str::eq("bc", str::char_slice("abc", 1u, 3u))); + assert (str::eq("", str::char_slice("abc", 1u, 1u))); + assert (str::eq("\u65e5", str::char_slice("\u65e5\u672c", 0u, 1u))); } #[test] fn trim_left() { - assert (str::trim_left(~"") == ~""); - assert (str::trim_left(~"a") == ~"a"); - assert (str::trim_left(~" ") == ~""); - assert (str::trim_left(~" blah") == ~"blah"); - assert (str::trim_left(~" \u3000 wut") == ~"wut"); - assert (str::trim_left(~"hey ") == ~"hey "); + assert (str::trim_left("") == ""); + assert (str::trim_left("a") == "a"); + assert (str::trim_left(" ") == ""); + assert (str::trim_left(" blah") == "blah"); + assert (str::trim_left(" \u3000 wut") == "wut"); + assert (str::trim_left("hey ") == "hey "); } #[test] fn trim_right() { - assert (str::trim_right(~"") == ~""); - assert (str::trim_right(~"a") == ~"a"); - assert (str::trim_right(~" ") == ~""); - assert (str::trim_right(~"blah ") == ~"blah"); - assert (str::trim_right(~"wut \u3000 ") == ~"wut"); - assert (str::trim_right(~" hey") == ~" hey"); + assert (str::trim_right("") == ""); + assert (str::trim_right("a") == "a"); + assert (str::trim_right(" ") == ""); + assert (str::trim_right("blah ") == "blah"); + assert (str::trim_right("wut \u3000 ") == "wut"); + assert (str::trim_right(" hey") == " hey"); } #[test] fn trim() { - assert (str::trim(~"") == ~""); - assert (str::trim(~"a") == ~"a"); - assert (str::trim(~" ") == ~""); - assert (str::trim(~" blah ") == ~"blah"); - assert (str::trim(~"\nwut \u3000 ") == ~"wut"); - assert (str::trim(~" hey dude ") == ~"hey dude"); + assert (str::trim("") == ""); + assert (str::trim("a") == "a"); + assert (str::trim(" ") == ""); + assert (str::trim(" blah ") == "blah"); + assert (str::trim("\nwut \u3000 ") == "wut"); + assert (str::trim(" hey dude ") == "hey dude"); } #[test] fn is_whitespace() { - assert (str::is_whitespace(~"")); - assert (str::is_whitespace(~" ")); - assert (str::is_whitespace(~"\u2009")); // Thin space - assert (str::is_whitespace(~" \n\t ")); - assert (!str::is_whitespace(~" _ ")); + assert (str::is_whitespace("")); + assert (str::is_whitespace(" ")); + assert (str::is_whitespace("\u2009")); // Thin space + assert (str::is_whitespace(" \n\t ")); + assert (!str::is_whitespace(" _ ")); } #[test] fn is_ascii() { - assert str::is_ascii(~""); - assert str::is_ascii(~"a"); - assert !str::is_ascii(~"\u2009"); + assert (str::is_ascii("")); + assert (str::is_ascii("a")); + assert (!str::is_ascii("\u2009")); } #[test] fn shift_byte() { - let s = ~"ABC"; + let s = "ABC"; let b = str::shift_byte(s); - assert s == ~"BC"; - assert b == 65u8; + assert (s == "BC"); + assert (b == 65u8); } #[test] fn pop_byte() { - let s = ~"ABC"; + let s = "ABC"; let b = str::pop_byte(s); - assert s == ~"AB"; - assert b == 67u8; + assert (s == "AB"); + assert (b == 67u8); } #[test] fn unsafe_from_bytes() { let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8]; let b = str::unsafe_from_bytes(a); - assert b == ~"AAAAAAA"; + assert (b == "AAAAAAA"); } #[test] @@ -263,43 +260,37 @@ fn str_from_cstr() { let a = [65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8]; let b = vec::to_ptr(a); let c = str::str_from_cstr(b); - assert c == ~"AAAAAAA"; + assert (c == "AAAAAAA"); } #[test] fn as_buf() { - let a = ~"Abcdefg"; - let b = str::as_buf(a, { |buf| - assert *buf == 65u8; - 100 - }); - assert b == 100; + let a = "Abcdefg"; + let b = str::as_buf(a, {|buf| assert (*buf == 65u8); 100 }); + assert (b == 100); } #[test] fn as_buf_small() { - let a = ~"A"; - let b = str::as_buf(a, { |buf| - assert *buf == 65u8; - 100 - }); - assert b == 100; + let a = "A"; + let b = str::as_buf(a, {|buf| assert (*buf == 65u8); 100 }); + assert (b == 100); } #[test] fn as_buf2() { - let s = ~"hello"; - let sb = str::as_buf(s, { |b| b }); + let s = "hello"; + let sb = str::as_buf(s, {|b| b }); let s_cstr = str::str_from_cstr(sb); assert (str::eq(s_cstr, s)); } #[test] fn vec_str_conversions() { - let s1: istr = ~"All mimsy were the borogoves"; + let s1: str = "All mimsy were the borogoves"; let v: [u8] = str::bytes(s1); - let s2: istr = str::unsafe_from_bytes(v); + let s2: str = str::unsafe_from_bytes(v); let i: uint = 0u; let n1: uint = str::byte_len(s1); let n2: uint = vec::len::<u8>(v); diff --git a/src/test/stdtest/sys.rs b/src/test/stdtest/sys.rs index 006aaaa8f5e..56cafe9217a 100644 --- a/src/test/stdtest/sys.rs +++ b/src/test/stdtest/sys.rs @@ -1,6 +1,4 @@ import std::sys; #[test] -fn last_os_error() { - log sys::rustrt::last_os_error(); -} \ No newline at end of file +fn last_os_error() { log sys::rustrt::last_os_error(); } diff --git a/src/test/stdtest/task.rs b/src/test/stdtest/task.rs index 1984202fd93..8c1776aa36f 100644 --- a/src/test/stdtest/task.rs +++ b/src/test/stdtest/task.rs @@ -67,12 +67,10 @@ fn test_join_convenient() { #[test] fn spawn_polymorphic() { - fn foo<~T>(x : -T) { - log_err x; - } + fn foo<~T>(x: -T) { log_err x; } let fb = bind foo(true); task::spawn(fb); task::spawn(bind foo(42)); -} \ No newline at end of file +} diff --git a/src/test/stdtest/test.rs b/src/test/stdtest/test.rs index cb4b9313029..eaecb80ba6b 100644 --- a/src/test/stdtest/test.rs +++ b/src/test/stdtest/test.rs @@ -9,7 +9,7 @@ fn do_not_run_ignored_tests() { let ran = @mutable false; let f = bind fn (ran: @mutable bool) { *ran = true; }(ran); - let desc = {name: ~"whatever", fn: f, ignore: true}; + let desc = {name: "whatever", fn: f, ignore: true}; test::run_test(desc, test::default_test_to_task); @@ -19,22 +19,22 @@ fn do_not_run_ignored_tests() { #[test] fn ignored_tests_result_in_ignored() { fn f() { } - let desc = {name: ~"whatever", fn: f, ignore: true}; + let desc = {name: "whatever", fn: f, ignore: true}; let res = test::run_test(desc, test::default_test_to_task).wait(); assert (res == test::tr_ignored); } #[test] fn first_free_arg_should_be_a_filter() { - let args = [~"progname", ~"filter"]; + let args = ["progname", "filter"]; check (vec::is_not_empty(args)); let opts = alt test::parse_opts(args) { either::left(o) { o } }; - assert (str::eq(~"filter", option::get(opts.filter))); + assert (str::eq("filter", option::get(opts.filter))); } #[test] fn parse_ignored_flag() { - let args = [~"progname", ~"filter", ~"--ignored"]; + let args = ["progname", "filter", "--ignored"]; check (vec::is_not_empty(args)); let opts = alt test::parse_opts(args) { either::left(o) { o } }; assert (opts.run_ignored); @@ -47,12 +47,12 @@ fn filter_for_ignored_option() { let opts = {filter: option::none, run_ignored: true}; let tests = - [{name: ~"1", fn: fn () { }, ignore: true}, - {name: ~"2", fn: fn () { }, ignore: false}]; + [{name: "1", fn: fn () { }, ignore: true}, + {name: "2", fn: fn () { }, ignore: false}]; let filtered = test::filter_tests(opts, tests); assert (vec::len(filtered) == 1u); - assert (filtered[0].name == ~"1"); + assert (filtered[0].name == "1"); assert (filtered[0].ignore == false); } @@ -61,17 +61,17 @@ fn sort_tests() { let opts = {filter: option::none, run_ignored: false}; let names = - [~"sha1::test", ~"int::test_to_str", ~"int::test_pow", - ~"test::do_not_run_ignored_tests", - ~"test::ignored_tests_result_in_ignored", - ~"test::first_free_arg_should_be_a_filter", - ~"test::parse_ignored_flag", ~"test::filter_for_ignored_option", - ~"test::sort_tests"]; + ["sha1::test", "int::test_to_str", "int::test_pow", + "test::do_not_run_ignored_tests", + "test::ignored_tests_result_in_ignored", + "test::first_free_arg_should_be_a_filter", + "test::parse_ignored_flag", "test::filter_for_ignored_option", + "test::sort_tests"]; let tests = { let testfn = fn () { }; let tests = []; - for name: istr in names { + for name: str in names { let test = {name: name, fn: testfn, ignore: false}; tests += [test]; } @@ -80,15 +80,13 @@ fn sort_tests() { let filtered = test::filter_tests(opts, tests); let expected = - [~"int::test_pow", ~"int::test_to_str", ~"sha1::test", - ~"test::do_not_run_ignored_tests", - ~"test::filter_for_ignored_option", - ~"test::first_free_arg_should_be_a_filter", - ~"test::ignored_tests_result_in_ignored", - ~"test::parse_ignored_flag", - ~"test::sort_tests"]; - - check vec::same_length(expected, filtered); + ["int::test_pow", "int::test_to_str", "sha1::test", + "test::do_not_run_ignored_tests", "test::filter_for_ignored_option", + "test::first_free_arg_should_be_a_filter", + "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); diff --git a/src/test/stdtest/treemap.rs b/src/test/stdtest/treemap.rs index 9a2ef1e8e68..0f4119c6c3d 100644 --- a/src/test/stdtest/treemap.rs +++ b/src/test/stdtest/treemap.rs @@ -5,41 +5,29 @@ import std::option::none; import std::str; #[test] -fn init_treemap() { - let m = init::<int, int>(); -} +fn init_treemap() { let m = init::<int, int>(); } #[test] -fn insert_one() { - let m = init(); - insert(m, 1, 2); -} +fn insert_one() { let m = init(); insert(m, 1, 2); } #[test] -fn insert_two() { - let m = init(); - insert(m, 1, 2); - insert(m, 3, 4); -} +fn insert_two() { let m = init(); insert(m, 1, 2); insert(m, 3, 4); } #[test] fn insert_find() { let m = init(); insert(m, 1, 2); - assert(find(m, 1) == some(2)); + assert (find(m, 1) == some(2)); } #[test] -fn find_empty() { - let m = init::<int, int>(); - assert(find(m, 1) == none); -} +fn find_empty() { let m = init::<int, int>(); assert (find(m, 1) == none); } #[test] fn find_not_found() { let m = init(); insert(m, 1, 2); - assert(find(m, 2) == none); + assert (find(m, 2) == none); } #[test] @@ -52,10 +40,7 @@ fn traverse_in_order() { insert(m, 1, ()); let n = 0; - fn t(n : &mutable int, k : &int, v : &()) { - assert(n == k); - n += 1; - } + fn t(n: &mutable int, k: &int, v: &()) { assert (n == k); n += 1; } traverse(m, bind t(n, _, _)); } @@ -63,12 +48,12 @@ fn traverse_in_order() { fn u8_map() { let m = init(); - let k1 = str::bytes(~"foo"); - let k2 = str::bytes(~"bar"); + let k1 = str::bytes("foo"); + let k2 = str::bytes("bar"); - insert(m, k1, ~"foo"); - insert(m, k2, ~"bar"); + insert(m, k1, "foo"); + insert(m, k2, "bar"); - assert(find(m, k2) == some(~"bar")); - assert(find(m, k1) == some(~"foo")); + assert (find(m, k2) == some("bar")); + assert (find(m, k1) == some("foo")); } diff --git a/src/test/stdtest/vec.rs b/src/test/stdtest/vec.rs index 3d1df459067..6194c461c15 100644 --- a/src/test/stdtest/vec.rs +++ b/src/test/stdtest/vec.rs @@ -303,7 +303,7 @@ fn test_zip_unzip() { let v1 = [1, 2, 3]; let v2 = [4, 5, 6]; - check same_length(v1, v2); // Silly, but what else can we do? + check (same_length(v1, v2)); // Silly, but what else can we do? let z1 = vec::zip(v1, v2); assert ((1, 4) == z1[0]); @@ -351,7 +351,7 @@ fn reverse_and_reversed() { // Make sure they work with 0-length vectors too. let v4 = vec::reversed::<int>([]); - assert v4 == []; + assert (v4 == []); let v3: [mutable int] = [mutable]; vec::reverse::<int>(v3); } |
