From 9cc26cfdf43adffe51acdc5ef9886cb5e1844d46 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 21 Feb 2014 15:41:51 -0800 Subject: [PATCH] test: Clean out the test suite a bit This updates a number of ignore-test tests, and removes a few completely outdated tests due to the feature being tested no longer being supported. This brings a number of bench/shootout tests up to date so they're compiling again. I make no claims to the performance of these benchmarks, it's just nice to not have bitrotted code. Closes #2604 Closes #9407 --- src/libgreen/sched.rs | 2 - src/test/auxiliary/private_variant_1.rs | 2 +- src/test/bench/shootout-fannkuch-redux.rs | 129 ++++++------- src/test/bench/shootout-fasta-redux.rs | 178 ++++++++---------- src/test/bench/shootout-k-nucleotide.rs | 171 +++++++---------- src/test/bench/task-perf-linked-failure.rs | 103 ---------- src/test/compile-fail/dead-code-ret.rs | 17 +- src/test/compile-fail/empty-linkname.rs | 6 +- src/test/compile-fail/empty-linkname2.rs | 19 -- src/test/compile-fail/issue-2063.rs | 10 +- src/test/compile-fail/issue-2969.rs | 20 -- .../compile-fail/issue-3177-mutable-struct.rs | 22 --- src/test/compile-fail/issue-3973.rs | 4 +- src/test/compile-fail/issue-4542.rs | 19 -- src/test/compile-fail/issue-5035.rs | 6 +- src/test/compile-fail/issue-6801.rs | 4 +- .../compile-fail/kindck-owned-trait-scoped.rs | 61 ------ src/test/compile-fail/liveness-unused.rs | 14 +- src/test/compile-fail/pptypedef.rs | 13 +- src/test/compile-fail/private-variant-xc.rs | 3 +- src/test/compile-fail/private_variant_2.rs | 3 +- .../{run-pass => compile-fail}/recursion.rs | 9 +- src/test/compile-fail/redundant-link-args.rs | 30 --- src/test/compile-fail/regions-fn-bound.rs | 16 +- .../syntax-extension-minor.rs | 2 +- .../trait-inheritance-missing-requirement.rs | 32 ---- src/test/run-fail/issue-2061.rs | 2 +- src/test/run-fail/linked-failure.rs | 25 --- src/test/run-fail/linked-failure2.rs | 23 --- src/test/run-fail/linked-failure3.rs | 29 --- src/test/run-fail/linked-failure4.rs | 35 ---- src/test/run-fail/spawnfail.rs | 24 --- src/test/run-fail/task-comm-recv-block.rs | 29 --- src/test/run-pass/auto-encode.rs | 14 +- .../run-pass/deriving-encodable-decodable.rs | 2 +- src/test/run-pass/for-destruct.rs | 7 +- src/test/run-pass/foreign-lib-path.rs | 26 --- src/test/run-pass/foreign-mod.rc | 26 --- src/test/run-pass/foreign.rc | 22 --- .../{lots-a-fail.rs => issue-1451.rs} | 26 +-- .../{duplicate-use.rs => issue-2074.rs} | 17 +- src/test/run-pass/issue-2190-1.rs | 14 +- src/test/run-pass/issue-2190-2.rs | 4 +- src/test/run-pass/issue-2190.rs | 19 -- src/test/run-pass/issue-3168.rs | 35 ---- src/test/run-pass/issue-3290.rs | 1 - src/test/run-pass/issue-3796.rs | 20 -- src/test/run-pass/issue-3904.rs | 16 +- src/test/run-pass/issue-4241.rs | 130 ------------- src/test/run-pass/issue-4542.rs | 7 +- .../nullable-pointer-iotareduction.rs | 20 +- src/test/run-pass/send-iloop.rs | 39 ---- src/test/run-pass/task-killjoin-rsrc.rs | 87 --------- src/test/run-pass/task-killjoin.rs | 37 ---- 54 files changed, 309 insertions(+), 1322 deletions(-) delete mode 100644 src/test/bench/task-perf-linked-failure.rs delete mode 100644 src/test/compile-fail/empty-linkname2.rs delete mode 100644 src/test/compile-fail/issue-2969.rs delete mode 100644 src/test/compile-fail/issue-3177-mutable-struct.rs delete mode 100644 src/test/compile-fail/issue-4542.rs delete mode 100644 src/test/compile-fail/kindck-owned-trait-scoped.rs rename src/test/{run-pass => compile-fail}/recursion.rs (85%) delete mode 100644 src/test/compile-fail/redundant-link-args.rs rename src/test/{run-pass => compile-fail}/syntax-extension-minor.rs (94%) delete mode 100644 src/test/compile-fail/trait-inheritance-missing-requirement.rs delete mode 100644 src/test/run-fail/linked-failure.rs delete mode 100644 src/test/run-fail/linked-failure2.rs delete mode 100644 src/test/run-fail/linked-failure3.rs delete mode 100644 src/test/run-fail/linked-failure4.rs delete mode 100644 src/test/run-fail/spawnfail.rs delete mode 100644 src/test/run-fail/task-comm-recv-block.rs delete mode 100644 src/test/run-pass/foreign-lib-path.rs delete mode 100644 src/test/run-pass/foreign-mod.rc delete mode 100644 src/test/run-pass/foreign.rc rename src/test/run-pass/{lots-a-fail.rs => issue-1451.rs} (62%) rename src/test/run-pass/{duplicate-use.rs => issue-2074.rs} (70%) delete mode 100644 src/test/run-pass/issue-2190.rs delete mode 100644 src/test/run-pass/issue-3168.rs delete mode 100644 src/test/run-pass/issue-3796.rs delete mode 100644 src/test/run-pass/issue-4241.rs delete mode 100644 src/test/run-pass/send-iloop.rs delete mode 100644 src/test/run-pass/task-killjoin-rsrc.rs delete mode 100644 src/test/run-pass/task-killjoin.rs diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index c6db989d036..a128ee4a250 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -1394,8 +1394,6 @@ mod test { }); } - // FIXME: #9407: ignore-test - #[ignore] #[test] fn dont_starve_1() { let mut pool = SchedPool::new(PoolConfig { diff --git a/src/test/auxiliary/private_variant_1.rs b/src/test/auxiliary/private_variant_1.rs index 606a662315a..f711af43699 100644 --- a/src/test/auxiliary/private_variant_1.rs +++ b/src/test/auxiliary/private_variant_1.rs @@ -10,6 +10,6 @@ mod super_sekrit { pub enum sooper_sekrit { - pub quux, priv baz + quux, priv baz } } diff --git a/src/test/bench/shootout-fannkuch-redux.rs b/src/test/bench/shootout-fannkuch-redux.rs index 9a47dc2696b..2f637030802 100644 --- a/src/test/bench/shootout-fannkuch-redux.rs +++ b/src/test/bench/shootout-fannkuch-redux.rs @@ -8,11 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test reading from os::args()[1] - bogus! - -use std::from_str::FromStr; use std::os; -use std::vec::MutableVector; use std::vec; fn max(a: i32, b: i32) -> i32 { @@ -23,7 +19,6 @@ fn max(a: i32, b: i32) -> i32 { } } -#[inline(never)] fn fannkuch_redux(n: i32) -> i32 { let mut perm = vec::from_elem(n as uint, 0i32); let mut perm1 = vec::from_fn(n as uint, |i| i as i32); @@ -34,74 +29,70 @@ fn fannkuch_redux(n: i32) -> i32 { let mut r = n; loop { - unsafe { - while r != 1 { - count.unsafe_set((r-1) as uint, r); - r -= 1; - } - - for (perm_i, perm1_i) in perm.mut_iter().zip(perm1.iter()) { - *perm_i = *perm1_i; - } - - let mut flips_count: i32 = 0; - let mut k: i32; - loop { - k = *perm.unsafe_ref(0); - if k == 0 { - break; - } - - let k2 = (k+1) >> 1; - for i in range(0i32, k2) { - let (perm_i, perm_k_i) = { - (*perm.unsafe_ref(i as uint), - *perm.unsafe_ref((k-i) as uint)) - }; - perm.unsafe_set(i as uint, perm_k_i); - perm.unsafe_set((k-i) as uint, perm_i); - } - flips_count += 1; - } - - max_flips_count = max(max_flips_count, flips_count); - checksum += if perm_count % 2 == 0 { - flips_count - } else { - -flips_count - }; - - // Use incremental change to generate another permutation. - loop { - if r == n { - println!("{}", checksum); - return max_flips_count; - } - - let perm0 = perm1[0]; - let mut i: i32 = 0; - while i < r { - let j = i + 1; - let perm1_j = { *perm1.unsafe_ref(j as uint) }; - perm1.unsafe_set(i as uint, perm1_j); - i = j; - } - perm1.unsafe_set(r as uint, perm0); - - let count_r = { *count.unsafe_ref(r as uint) }; - count.unsafe_set(r as uint, count_r - 1); - if *count.unsafe_ref(r as uint) > 0 { - break; - } - r += 1; - } - - perm_count += 1; + while r != 1 { + count[r - 1] = r; + r -= 1; } + + for (perm_i, perm1_i) in perm.mut_iter().zip(perm1.iter()) { + *perm_i = *perm1_i; + } + + let mut flips_count: i32 = 0; + let mut k: i32; + loop { + k = perm[0]; + if k == 0 { + break; + } + + let k2 = (k+1) >> 1; + for i in range(0i32, k2) { + perm.swap(i as uint, (k - i) as uint); + } + flips_count += 1; + } + + max_flips_count = max(max_flips_count, flips_count); + checksum += if perm_count % 2 == 0 { + flips_count + } else { + -flips_count + }; + + // Use incremental change to generate another permutation. + loop { + if r == n { + println!("{}", checksum); + return max_flips_count; + } + + let perm0 = perm1[0]; + let mut i: i32 = 0; + while i < r { + let j = i + 1; + perm1[i] = perm1[j]; + i = j; + } + perm1[r] = perm0; + + count[r] -= 1; + if count[r] > 0 { + break; + } + r += 1; + } + + perm_count += 1; } } fn main() { - let n: i32 = FromStr::from_str(os::args()[1]).unwrap(); + let args = os::args(); + let n = if args.len() > 1 { + from_str::(args[1]).unwrap() + } else { + 2 + }; println!("Pfannkuchen({}) = {}", n as int, fannkuch_redux(n) as int); } diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs index 282ea57ccf3..f38acf0457d 100644 --- a/src/test/bench/shootout-fasta-redux.rs +++ b/src/test/bench/shootout-fasta-redux.rs @@ -8,13 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test reading from os::args()[1] - bogus! - -use std::cast::transmute; -use std::from_str::FromStr; -use std::libc::{FILE, STDOUT_FILENO, c_int, fdopen, fputc, fputs, fwrite, size_t}; +use std::cmp::min; +use std::io::{stdout, BufferedWriter, IoResult}; use std::os; -use std::uint::min; use std::vec::bytes::copy_memory; use std::vec; @@ -37,10 +33,6 @@ static ALU: &'static str = "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG\ static NULL_AMINO_ACID: AminoAcid = AminoAcid { c: ' ' as u8, p: 0.0 }; -static MESSAGE_1: &'static str = ">ONE Homo sapiens alu\n"; -static MESSAGE_2: &'static str = ">TWO IUB ambiguity codes\n"; -static MESSAGE_3: &'static str = ">THREE Homo sapiens frequency\n"; - static IUB: [AminoAcid, ..15] = [ AminoAcid { c: 'a' as u8, p: 0.27 }, AminoAcid { c: 'c' as u8, p: 0.12 }, @@ -85,75 +77,70 @@ struct AminoAcid { p: f32, } -struct RepeatFasta { +struct RepeatFasta<'a, W> { alu: &'static str, - stdout: *FILE, + out: &'a mut W } -impl RepeatFasta { - fn new(stdout: *FILE, alu: &'static str) -> RepeatFasta { - RepeatFasta { - alu: alu, - stdout: stdout, - } +impl<'a, W: Writer> RepeatFasta<'a, W> { + fn new(alu: &'static str, w: &'a mut W) -> RepeatFasta<'a, W> { + RepeatFasta { alu: alu, out: w } } - fn make(&mut self, n: uint) { - unsafe { - let stdout = self.stdout; - let alu_len = self.alu.len(); - let mut buf = vec::from_elem(alu_len + LINE_LEN, 0u8); - let alu: &[u8] = self.alu.as_bytes(); + fn make(&mut self, n: uint) -> IoResult<()> { + let alu_len = self.alu.len(); + let mut buf = vec::from_elem(alu_len + LINE_LEN, 0u8); + let alu: &[u8] = self.alu.as_bytes(); - copy_memory(buf, alu); - let buf_len = buf.len(); - copy_memory(buf.mut_slice(alu_len, buf_len), - alu.slice_to(LINE_LEN)); + copy_memory(buf, alu); + let buf_len = buf.len(); + copy_memory(buf.mut_slice(alu_len, buf_len), + alu.slice_to(LINE_LEN)); - let mut pos = 0; - let mut bytes; - let mut n = n; - while n > 0 { - bytes = min(LINE_LEN, n); - fwrite(transmute(&buf[pos]), bytes as size_t, 1, stdout); - fputc('\n' as c_int, stdout); - pos += bytes; - if pos > alu_len { - pos -= alu_len; - } - n -= bytes; + let mut pos = 0; + let mut bytes; + let mut n = n; + while n > 0 { + bytes = min(LINE_LEN, n); + try!(self.out.write(buf.slice(pos, pos + bytes))); + try!(self.out.write_u8('\n' as u8)); + pos += bytes; + if pos > alu_len { + pos -= alu_len; } + n -= bytes; } + Ok(()) } } -struct RandomFasta { - seed: u32, - stdout: *FILE, - lookup: [AminoAcid, ..LOOKUP_SIZE], +fn make_lookup(a: &[AminoAcid]) -> [AminoAcid, ..LOOKUP_SIZE] { + let mut lookup = [ NULL_AMINO_ACID, ..LOOKUP_SIZE ]; + let mut j = 0; + for (i, slot) in lookup.mut_iter().enumerate() { + while a[j].p < (i as f32) { + j += 1; + } + *slot = a[j]; + } + lookup } -impl RandomFasta { - fn new(stdout: *FILE, a: &[AminoAcid]) -> RandomFasta { +struct RandomFasta<'a, W> { + seed: u32, + lookup: [AminoAcid, ..LOOKUP_SIZE], + out: &'a mut W, +} + +impl<'a, W: Writer> RandomFasta<'a, W> { + fn new(w: &'a mut W, a: &[AminoAcid]) -> RandomFasta<'a, W> { RandomFasta { seed: 42, - stdout: stdout, - lookup: RandomFasta::make_lookup(a), + out: w, + lookup: make_lookup(a), } } - fn make_lookup(a: &[AminoAcid]) -> [AminoAcid, ..LOOKUP_SIZE] { - let mut lookup = [ NULL_AMINO_ACID, ..LOOKUP_SIZE ]; - let mut j = 0; - for (i, slot) in lookup.mut_iter().enumerate() { - while a[j].p < (i as f32) { - j += 1; - } - *slot = a[j]; - } - lookup - } - fn rng(&mut self, max: f32) -> f32 { self.seed = (self.seed * IA + IC) % IM; max * (self.seed as f32) / (IM as f32) @@ -169,51 +156,50 @@ impl RandomFasta { 0 } - fn make(&mut self, n: uint) { - unsafe { - let lines = n / LINE_LEN; - let chars_left = n % LINE_LEN; - let mut buf = [0, ..LINE_LEN + 1]; + fn make(&mut self, n: uint) -> IoResult<()> { + let lines = n / LINE_LEN; + let chars_left = n % LINE_LEN; + let mut buf = [0, ..LINE_LEN + 1]; - for _ in range(0, lines) { - for i in range(0u, LINE_LEN) { - buf[i] = self.nextc(); - } - buf[LINE_LEN] = '\n' as u8; - fwrite(transmute(&buf[0]), - LINE_LEN as size_t + 1, - 1, - self.stdout); - } - for i in range(0u, chars_left) { + for _ in range(0, lines) { + for i in range(0u, LINE_LEN) { buf[i] = self.nextc(); } - fwrite(transmute(&buf[0]), chars_left as size_t, 1, self.stdout); + buf[LINE_LEN] = '\n' as u8; + try!(self.out.write(buf)); } + for i in range(0u, chars_left) { + buf[i] = self.nextc(); + } + self.out.write(buf.slice_to(chars_left)) } } fn main() { - let n: uint = FromStr::from_str(os::args()[1]).unwrap(); + let args = os::args(); + let n = if args.len() > 1 { + from_str::(args[1]).unwrap() + } else { + 5 + }; - unsafe { - let mode = "w"; - let stdout = fdopen(STDOUT_FILENO as c_int, transmute(&mode[0])); + let mut out = BufferedWriter::new(stdout()); - fputs(transmute(&MESSAGE_1[0]), stdout); - let mut repeat = RepeatFasta::new(stdout, ALU); - repeat.make(n * 2); - - fputs(transmute(&MESSAGE_2[0]), stdout); - let iub = sum_and_scale(IUB); - let mut random = RandomFasta::new(stdout, iub); - random.make(n * 3); - - fputs(transmute(&MESSAGE_3[0]), stdout); - let homo_sapiens = sum_and_scale(HOMO_SAPIENS); - random.lookup = RandomFasta::make_lookup(homo_sapiens); - random.make(n * 5); - - fputc('\n' as c_int, stdout); + out.write_line(">ONE Homo sapiens alu").unwrap(); + { + let mut repeat = RepeatFasta::new(ALU, &mut out); + repeat.make(n * 2).unwrap(); } + + out.write_line(">TWO IUB ambiguity codes").unwrap(); + let iub = sum_and_scale(IUB); + let mut random = RandomFasta::new(&mut out, iub); + random.make(n * 3).unwrap(); + + random.out.write_line(">THREE Homo sapiens frequency").unwrap(); + let homo_sapiens = sum_and_scale(HOMO_SAPIENS); + random.lookup = make_lookup(homo_sapiens); + random.make(n * 5).unwrap(); + + random.out.write_str("\n").unwrap(); } diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 9190ff69347..a8f3489cb87 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -8,19 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test +// ignore-pretty -extern crate extra; +use std::str; +use std::vec; -use std::cast::transmute; -use std::i32::range; -use std::libc::{STDIN_FILENO, c_int, fdopen, fgets, fileno, fopen, fstat}; -use std::libc::{stat, strlen}; -use std::mem::init; -use std::ptr::null; -use std::vec::{reverse}; - -static LINE_LEN: uint = 80; static TABLE: [u8, ..4] = [ 'A' as u8, 'C' as u8, 'G' as u8, 'T' as u8 ]; static TABLE_SIZE: uint = 2 << 16; @@ -34,41 +26,37 @@ static OCCURRENCES: [&'static str, ..5] = [ // Code implementation -#[deriving(Eq, Ord)] +#[deriving(Eq, TotalOrd, TotalEq)] struct Code(u64); impl Code { fn hash(&self) -> u64 { - **self + let Code(ret) = *self; + return ret; } - #[inline(always)] fn push_char(&self, c: u8) -> Code { - Code((**self << 2) + (pack_symbol(c) as u64)) + Code((self.hash() << 2) + (pack_symbol(c) as u64)) } fn rotate(&self, c: u8, frame: i32) -> Code { - Code(*self.push_char(c) & ((1u64 << (2 * (frame as u64))) - 1)) + Code(self.push_char(c).hash() & ((1u64 << (2 * (frame as u64))) - 1)) } fn pack(string: &str) -> Code { - let mut code = Code(0u64); - for i in range(0u, string.len()) { - code = code.push_char(string[i]); - } - code + string.bytes().fold(Code(0u64), |a, b| a.push_char(b)) } // FIXME: Inefficient. fn unpack(&self, frame: i32) -> ~str { - let mut key = **self; + let mut key = self.hash(); let mut result = ~[]; for _ in range(0, frame) { result.push(unpack_symbol((key as u8) & 3)); key >>= 2; } - reverse(result); + result.reverse(); str::from_utf8_owned(result).unwrap() } } @@ -91,7 +79,8 @@ struct PrintCallback(&'static str); impl TableCallback for PrintCallback { fn f(&self, entry: &mut Entry) { - println!("{}\t{}", entry.count as int, **self); + let PrintCallback(s) = *self; + println!("{}\t{}", entry.count as int, s); } } @@ -103,14 +92,19 @@ struct Entry { struct Table { count: i32, - items: [Option<~Entry>, ..TABLE_SIZE] + items: ~[Option<~Entry>] +} + +struct Items<'a> { + cur: Option<&'a Entry>, + items: vec::Items<'a, Option<~Entry>>, } impl Table { fn new() -> Table { Table { count: 0, - items: [ None, ..TABLE_SIZE ], + items: vec::from_fn(TABLE_SIZE, |_| None), } } @@ -137,7 +131,7 @@ impl Table { } fn lookup(&mut self, key: Code, c: C) { - let index = *key % (TABLE_SIZE as u64); + let index = key.hash() % (TABLE_SIZE as u64); { if self.items[index].is_none() { @@ -153,7 +147,7 @@ impl Table { } { - let mut entry = &mut *self.items[index].get_mut_ref(); + let entry = &mut *self.items[index].get_mut_ref(); if entry.code == key { c.f(*entry); return; @@ -163,37 +157,45 @@ impl Table { } } - fn each(&self, f: |entry: &Entry| -> bool) { - for self.items.each |item| { - match *item { - None => {} - Some(ref item) => { - let mut item: &Entry = *item; - loop { - if !f(item) { - return; - } + fn iter<'a>(&'a self) -> Items<'a> { + Items { cur: None, items: self.items.iter() } + } +} - match item.next { - None => break, - Some(ref next_item) => item = &**next_item, - } +impl<'a> Iterator<&'a Entry> for Items<'a> { + fn next(&mut self) -> Option<&'a Entry> { + let ret = match self.cur { + None => { + let i; + loop { + match self.items.next() { + None => return None, + Some(&None) => {} + Some(&Some(ref a)) => { i = &**a; break } } } - }; + self.cur = Some(&*i); + &*i + } + Some(c) => c + }; + match ret.next { + None => { self.cur = None; } + Some(ref next) => { self.cur = Some(&**next); } } + return Some(ret); } } // Main program fn pack_symbol(c: u8) -> u8 { - match c { - 'a' as u8 | 'A' as u8 => 0, - 'c' as u8 | 'C' as u8 => 1, - 'g' as u8 | 'G' as u8 => 2, - 't' as u8 | 'T' as u8 => 3, - _ => fail!(c.to_str()) + match c as char { + 'a' | 'A' => 0, + 'c' | 'C' => 1, + 'g' | 'G' => 2, + 't' | 'T' => 3, + _ => fail!("{}", c as char), } } @@ -215,43 +217,6 @@ fn next_char<'a>(mut buf: &'a [u8]) -> &'a [u8] { buf } -#[inline(never)] -fn read_stdin() -> ~[u8] { - unsafe { - let mode = "r"; - //let stdin = fdopen(STDIN_FILENO as c_int, transmute(&mode[0])); - let path = "knucleotide-input.txt"; - let stdin = fopen(transmute(&path[0]), transmute(&mode[0])); - - let mut st: stat = init(); - fstat(fileno(stdin), &mut st); - let mut buf = vec::from_elem(st.st_size as uint, 0); - - let header = ">THREE".as_bytes(); - - { - let mut window: &mut [u8] = buf; - loop { - fgets(transmute(&mut window[0]), LINE_LEN as c_int, stdin); - - { - if window.slice(0, 6) == header { - break; - } - } - } - - while fgets(transmute(&mut window[0]), - LINE_LEN as c_int, - stdin) != null() { - window = window.mut_slice(strlen(transmute(&window[0])) as uint, window.len()); - } - } - - buf - } -} - fn generate_frequencies(frequencies: &mut Table, mut input: &[u8], frame: i32) { @@ -273,20 +238,20 @@ fn generate_frequencies(frequencies: &mut Table, fn print_frequencies(frequencies: &Table, frame: i32) { let mut vector = ~[]; - for frequencies.each |entry| { + for entry in frequencies.iter() { vector.push((entry.code, entry.count)); } vector.sort(); let mut total_count = 0; - for vector.each |&(_, count)| { + for &(_, count) in vector.iter() { total_count += count; } - for vector.each |&(key, count)| { + for &(key, count) in vector.iter() { println!("{} {:.3f}", key.unpack(frame), - (count as float * 100.0) / (total_count as float)); + (count as f32 * 100.0) / (total_count as f32)); } } @@ -295,22 +260,24 @@ fn print_occurrences(frequencies: &mut Table, occurrence: &'static str) { } fn main() { - let input = read_stdin(); + let input = include_str!("shootout-k-nucleotide.data"); + let pos = input.find_str(">THREE").unwrap(); + let pos2 = pos + input.slice_from(pos).find_str("\n").unwrap(); + let input = input.slice_from(pos2 + 1).as_bytes(); - let mut frequencies = ~Table::new(); - generate_frequencies(frequencies, input, 1); - print_frequencies(frequencies, 1); + let mut frequencies = Table::new(); + generate_frequencies(&mut frequencies, input, 1); + print_frequencies(&frequencies, 1); - *frequencies = Table::new(); - generate_frequencies(frequencies, input, 2); - print_frequencies(frequencies, 2); + frequencies = Table::new(); + generate_frequencies(&mut frequencies, input, 2); + print_frequencies(&frequencies, 2); - for range(0, 5) |i| { - let occurrence = OCCURRENCES[i]; - *frequencies = Table::new(); - generate_frequencies(frequencies, + for occurrence in OCCURRENCES.iter() { + frequencies = Table::new(); + generate_frequencies(&mut frequencies, input, occurrence.len() as i32); - print_occurrences(frequencies, occurrence); + print_occurrences(&mut frequencies, *occurrence); } } diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs deleted file mode 100644 index 189a3ac7448..00000000000 --- a/src/test/bench/task-perf-linked-failure.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-pretty -// ignore-test linked failure - -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/** - * Test performance of killing many tasks in a taskgroup. - * Along the way, tests various edge cases of ancestor group management. - * In particular, this tries to get each grandchild task to hit the - * "nobe_is_dead" case in each_ancestor only during task exit, but not during - * task spawn. This makes sure that defunct ancestor groups are handled correctly - * w.r.t. possibly leaving stale *rust_tasks lying around. - */ - -// Creates in the background 'num_tasks' tasks, all blocked forever. -// Doesn't return until all such tasks are ready, but doesn't block forever itself. - -use std::comm::{stream, Chan}; -use std::os; -use std::result; -use std::task; -use std::uint; - -fn grandchild_group(num_tasks: uint) { - let (po, ch) = stream(); - let ch = Chan::new(ch); - - for _ in range(0, num_tasks) { - let ch = ch.clone(); - let mut t = task::task(); - t.spawn(proc() { // linked - ch.send(()); - let (p, _c) = stream::<()>(); - p.recv(); // block forever - }); - } - error!("Grandchild group getting started"); - for _ in range(0, num_tasks) { - // Make sure all above children are fully spawned; i.e., enlisted in - // their ancestor groups. - po.recv(); - } - error!("Grandchild group ready to go."); - // Master grandchild task exits early. -} - -fn spawn_supervised_blocking(myname: &str, f: proc()) { - let mut builder = task::task(); - let res = builder.future_result(); - builder.supervised(); - builder.spawn(f); - error!("{} group waiting", myname); - let x = res.recv(); - assert!(x.is_ok()); -} - -fn main() { - let args = os::args(); - let args = if os::getenv("RUST_BENCH").is_some() { - ~[~"", ~"100000"] - } else if args.len() <= 1u { - ~[~"", ~"100"] - } else { - args.clone() - }; - - let num_tasks = from_str::(args[1]).unwrap(); - - // Main group #0 waits for unsupervised group #1. - // Grandparent group #1 waits for middle group #2, then fails, killing #3. - // Middle group #2 creates grandchild_group #3, waits for it to be ready, exits. - let x: result::Result<(), ~Any> = task::try(proc() { // unlinked - spawn_supervised_blocking("grandparent", proc() { - spawn_supervised_blocking("middle", proc() { - grandchild_group(num_tasks); - }); - // When grandchild group is ready to go, make the middle group exit. - error!("Middle group wakes up and exits"); - }); - // Grandparent group waits for middle group to be gone, then fails - error!("Grandparent group wakes up and fails"); - fail!(); - }); - assert!(x.is_err()); -} diff --git a/src/test/compile-fail/dead-code-ret.rs b/src/test/compile-fail/dead-code-ret.rs index 6733fa6832f..70e76b9fde1 100644 --- a/src/test/compile-fail/dead-code-ret.rs +++ b/src/test/compile-fail/dead-code-ret.rs @@ -8,24 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - -// ignored because the lint pass doesn't know to ignore standard library -// stuff. - -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +// error-pattern: unreachable statement #[deny(unreachable_code)]; fn main() { return; - info!("Paul is dead"); //~ ERROR: unreachable + info!("Paul is dead"); } diff --git a/src/test/compile-fail/empty-linkname.rs b/src/test/compile-fail/empty-linkname.rs index 8dcc07f50f7..cd5ee1cafec 100644 --- a/src/test/compile-fail/empty-linkname.rs +++ b/src/test/compile-fail/empty-linkname.rs @@ -8,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:empty #[link_name] not allowed; use #[nolink]. - -// ignore-test - -#[link_name = ""] +#[link(name = "")] //~ ERROR: given with empty name extern { } diff --git a/src/test/compile-fail/empty-linkname2.rs b/src/test/compile-fail/empty-linkname2.rs deleted file mode 100644 index bf4d2b85ed0..00000000000 --- a/src/test/compile-fail/empty-linkname2.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -// error-pattern:empty #[link_name] not allowed; use #[nolink]. -// Issue #1326 - -#[link_name = ""] -#[nolink] -extern { -} diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index 5f50b174493..846a51ca128 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -8,26 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - // test that autoderef of a type like this does not // cause compiler to loop. Note that no instances // of such a type could ever be constructed. -struct t(@t); //~ ERROR this type cannot be instantiated +struct t(~t); //~ ERROR this type cannot be instantiated trait to_str_2 { - fn to_str() -> ~str; + fn my_to_str() -> ~str; } // I use an impl here because it will cause // the compiler to attempt autoderef and then // try to resolve the method. impl to_str_2 for t { - fn to_str() -> ~str { ~"t" } + fn my_to_str() -> ~str { ~"t" } } fn new_t(x: t) { - x.to_str(); + x.my_to_str(); //~ ERROR does not implement } fn main() { diff --git a/src/test/compile-fail/issue-2969.rs b/src/test/compile-fail/issue-2969.rs deleted file mode 100644 index 414273b1bf3..00000000000 --- a/src/test/compile-fail/issue-2969.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -fn main() -{ -// See #2969 -- error message should be improved - let mut x = [1, 2, 4]; - let v : &int = &x[2]; - x[2] = 6; - assert_eq!(*v, 6); -} diff --git a/src/test/compile-fail/issue-3177-mutable-struct.rs b/src/test/compile-fail/issue-3177-mutable-struct.rs deleted file mode 100644 index ab90b7b253c..00000000000 --- a/src/test/compile-fail/issue-3177-mutable-struct.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test -// error-pattern: instantiating a type parameter with an incompatible type - -struct S { - s: T, - cant_nest: () -} - -fn main() { - let a1 = ~S{ s: true, cant_nest: () }; - let _a2 = ~S{ s: a1, cant_nest: () }; -} diff --git a/src/test/compile-fail/issue-3973.rs b/src/test/compile-fail/issue-3973.rs index 7b2a5a39aee..c44336aeaf5 100644 --- a/src/test/compile-fail/issue-3973.rs +++ b/src/test/compile-fail/issue-3973.rs @@ -23,11 +23,11 @@ impl ToStr for Point { //~ ERROR implements a method not defined in the trait } fn to_str(&self) -> ~str { - fmt!("(%f, %f)", self.x, self.y) + format!("({}, {})", self.x, self.y) } } fn main() { - let p = Point::new(0.0f, 0.0f); + let p = Point::new(0.0, 0.0); println!("{}", p.to_str()); } diff --git a/src/test/compile-fail/issue-4542.rs b/src/test/compile-fail/issue-4542.rs deleted file mode 100644 index b9f0b6cc612..00000000000 --- a/src/test/compile-fail/issue-4542.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -fn main() { - for os::args().each |arg| { - match (*arg).clone() { - s => { } - } - } -} diff --git a/src/test/compile-fail/issue-5035.rs b/src/test/compile-fail/issue-5035.rs index b2a9c9ba0fb..94110f07762 100644 --- a/src/test/compile-fail/issue-5035.rs +++ b/src/test/compile-fail/issue-5035.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - trait I {} -type K = I; -impl K for int {} +type K = I; //~ ERROR: reference to trait +impl K for int {} //~ ERROR: `K` is not a trait fn main() {} diff --git a/src/test/compile-fail/issue-6801.rs b/src/test/compile-fail/issue-6801.rs index 5d6b62fe283..a80d4b72192 100644 --- a/src/test/compile-fail/issue-6801.rs +++ b/src/test/compile-fail/issue-6801.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - // Creating a stack closure which references an owned pointer and then // transferring ownership of the owned box before invoking the stack // closure results in a crash. @@ -26,6 +24,6 @@ fn main() { let x : ~uint = ~9; let sq : || -> uint = || { *x * *x }; - twice(x); + twice(x); //~ ERROR: cannot move out of invoke(sq); } diff --git a/src/test/compile-fail/kindck-owned-trait-scoped.rs b/src/test/compile-fail/kindck-owned-trait-scoped.rs deleted file mode 100644 index 2e131485301..00000000000 --- a/src/test/compile-fail/kindck-owned-trait-scoped.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test -// ignored because to_foo() doesn't work. - -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// A dummy trait/impl that work close over any type. The trait will -// be parameterized by a region due to the &'a int constraint. - -trait foo { - fn foo(&self, i: &'a int) -> int; -} - -impl foo for T { - fn foo(&self, i: &'a int) -> int {*i} -} - -fn to_foo(t: T) { - // This version is ok because, although T may contain references - // it never escapes the fn body. We know this because - // the type of foo includes a region which will be resolved to - // the fn body itself. - let v = &3; - struct F { f: T } - let x = @F {f:t} as @foo; - assert_eq!(x.foo(v), 3); -} - -fn to_foo_2(t: T) -> @foo { - // Not OK---T may contain references and it is going to escape - // as part of the returned foo value - struct F { f: T } - @F {f:t} as @foo //~ ERROR value may contain references; add `'static` bound -} - -fn to_foo_3(t: T) -> @foo { - // OK---T may escape as part of the returned foo value, but it is - // owned and hence does not contain references - struct F { f: T } - @F {f:t} as @foo -} - -fn main() { -} diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 48e258fe5fe..83c911d916e 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -8,21 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test -// ignored because lint is messed up with the new visitor transition - -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - #[deny(unused_variable)]; #[deny(dead_assignment)]; +#[allow(dead_code, non_camel_case_types)]; fn f1(x: int) { //~^ ERROR unused variable: `x` diff --git a/src/test/compile-fail/pptypedef.rs b/src/test/compile-fail/pptypedef.rs index caf9fd6c661..79f0cc352e4 100644 --- a/src/test/compile-fail/pptypedef.rs +++ b/src/test/compile-fail/pptypedef.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - -type foo = Option; - -fn bar(_t: foo) {} +fn let_in(x: T, f: |T|) {} fn main() { - // we used to print foo: - bar(Some(3u)); //~ ERROR mismatched types: expected `foo` + let_in(3u, |i| { assert!(i == 3i); }); + //~^ ERROR expected `uint` but found `int` + + let_in(3i, |i| { assert!(i == 3u); }); + //~^ ERROR expected `int` but found `uint` } diff --git a/src/test/compile-fail/private-variant-xc.rs b/src/test/compile-fail/private-variant-xc.rs index 5a252eb2975..fb80c31d464 100644 --- a/src/test/compile-fail/private-variant-xc.rs +++ b/src/test/compile-fail/private-variant-xc.rs @@ -8,12 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test // aux-build:private_variant_xc.rs extern crate private_variant_xc; pub fn main() { let _ = private_variant_xc::Bar; - let _ = private_variant_xc::Baz; //~ ERROR unresolved name + let _ = private_variant_xc::Baz; //~ ERROR variant `Baz` is private } diff --git a/src/test/compile-fail/private_variant_2.rs b/src/test/compile-fail/private_variant_2.rs index 4afbe7ed48b..e4dd4b75fd4 100644 --- a/src/test/compile-fail/private_variant_2.rs +++ b/src/test/compile-fail/private_variant_2.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test // aux-build:private_variant_1.rs extern crate private_variant_1; fn main() { - let _x = private_variant_1::super_sekrit::baz; //~ ERROR baz is private + let _x = private_variant_1::super_sekrit::baz; //~ ERROR is private } diff --git a/src/test/run-pass/recursion.rs b/src/test/compile-fail/recursion.rs similarity index 85% rename from src/test/run-pass/recursion.rs rename to src/test/compile-fail/recursion.rs index d89227a3939..0fe042b924a 100644 --- a/src/test/run-pass/recursion.rs +++ b/src/test/compile-fail/recursion.rs @@ -8,20 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - enum Nil {Nil} struct Cons {head:int, tail:T} -trait Dot {fn dot(other:self) -> int;} +trait Dot {fn dot(&self, other:Self) -> int;} impl Dot for Nil { - fn dot(_:Nil) -> int {0} + fn dot(&self, _:Nil) -> int {0} } impl Dot for Cons { - fn dot(other:Cons) -> int { + fn dot(&self, other:Cons) -> int { self.head * other.head + self.tail.dot(other.tail) } } fn test (n:int, i:int, first:T, second:T) ->int { + //~^ ERROR: overly deep expansion of inlined function match n { 0 => {first.dot(second)} // Error message should be here. It should be a type error diff --git a/src/test/compile-fail/redundant-link-args.rs b/src/test/compile-fail/redundant-link-args.rs deleted file mode 100644 index 8edbeae1cc0..00000000000 --- a/src/test/compile-fail/redundant-link-args.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-fast -// ignore-test - -// error-pattern:library 'm' already added: can't specify link_args. - -/* I think it should undefined to have multiple modules that link in the same - library, but provide different link arguments. Unfortunately we don't track - link_args by module -- they are just appended as discovered into the crate - store -- but for now, it should be an error to provide link_args on a module - that's already been included (with or without link_args). */ - -#[link_name= "m"] -#[link_args="-foo"] // this could have been elided. -extern { -} - -#[link_name= "m"] -#[link_args="-bar"] // this is the actual error trigger. -extern { -} diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index 2eeca454854..b3b5993bf91 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -24,21 +24,23 @@ fn of() -> |T| { fail!(); } fn subtype(x: |T|) { fail!(); } -fn test_fn(_x: &'x T, _y: &'y T, _z: &'z T) { +fn test_fn<'x, 'y, 'z, T>(_x: &'x T, _y: &'y T, _z: &'z T) { // Here, x, y, and z are free. Other letters // are bound. Note that the arrangement // subtype::(of::()) will typecheck // iff T1 <: T2. // should be the default: - subtype::<'static ||>(of::<||>()); - subtype::<||>(of::<'static ||>()); + subtype::< ||:'static>(of::<||>()); + subtype::<||>(of::< ||:'static>()); // - subtype::<'x ||>(of::<||>()); //~ ERROR mismatched types - subtype::<'x ||>(of::<'y ||>()); //~ ERROR mismatched types + subtype::< <'x> ||>(of::<||>()); //~ ERROR mismatched types + subtype::< <'x> ||>(of::< <'y> ||>()); //~ ERROR mismatched types - subtype::<'x ||>(of::<'static ||>()); //~ ERROR mismatched types - subtype::<'static ||>(of::<'x ||>()); + subtype::< <'x> ||>(of::< ||:'static>()); //~ ERROR mismatched types + subtype::< ||:'static>(of::< <'x> ||>()); } + +fn main() {} diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/compile-fail/syntax-extension-minor.rs similarity index 94% rename from src/test/run-pass/syntax-extension-minor.rs rename to src/test/compile-fail/syntax-extension-minor.rs index dcce94da1ea..e65b1c0bf3a 100644 --- a/src/test/run-pass/syntax-extension-minor.rs +++ b/src/test/compile-fail/syntax-extension-minor.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test // this now fails (correctly, I claim) because hygiene prevents // the assembled identifier from being a reference to the binding. pub fn main() { let asdf_fdsa = ~"<.<"; assert_eq!(concat_idents!(asd, f_f, dsa), ~"<.<"); + //~^ ERROR: unresolved name `asdf_fdsa` assert!(stringify!(use_mention_distinction) == "use_mention_distinction"); diff --git a/src/test/compile-fail/trait-inheritance-missing-requirement.rs b/src/test/compile-fail/trait-inheritance-missing-requirement.rs deleted file mode 100644 index 29101158252..00000000000 --- a/src/test/compile-fail/trait-inheritance-missing-requirement.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test -// error-pattern: what - -trait Foo { - fn f(); -} - -trait Bar : Foo { - fn g(); -} - -struct A { - x: int -} - -// Can't implement Bar without an impl of Foo -impl Bar for A { - fn g() { } -} - -fn main() { -} diff --git a/src/test/run-fail/issue-2061.rs b/src/test/run-fail/issue-2061.rs index fed6f675105..49449be52af 100644 --- a/src/test/run-fail/issue-2061.rs +++ b/src/test/run-fail/issue-2061.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-test -// error-pattern: ran out of stack +// error-pattern: task '
' has overflowed its stack struct R { b: int, diff --git a/src/test/run-fail/linked-failure.rs b/src/test/run-fail/linked-failure.rs deleted file mode 100644 index fb5fdffffec..00000000000 --- a/src/test/run-fail/linked-failure.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// error-pattern:1 == 2 - -extern crate extra; - -use std::comm; -use std::task; - -fn child() { assert!((1 == 2)); } - -fn main() { - let (p, _c) = comm::stream::(); - task::spawn(|| child() ); - let x = p.recv(); -} diff --git a/src/test/run-fail/linked-failure2.rs b/src/test/run-fail/linked-failure2.rs deleted file mode 100644 index 8b9dd591f02..00000000000 --- a/src/test/run-fail/linked-failure2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// error-pattern:fail - -use std::comm; -use std::task; - -fn child() { fail!(); } - -fn main() { - let (p, _c) = comm::stream::<()>(); - task::spawn(|| child() ); - task::deschedule(); -} diff --git a/src/test/run-fail/linked-failure3.rs b/src/test/run-fail/linked-failure3.rs deleted file mode 100644 index 78119dd37a0..00000000000 --- a/src/test/run-fail/linked-failure3.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// error-pattern:fail - -use std::comm; -use std::task; - -fn grandchild() { fail!("grandchild dies"); } - -fn child() { - let (p, _c) = comm::stream::(); - task::spawn(|| grandchild() ); - let x = p.recv(); -} - -fn main() { - let (p, _c) = comm::stream::(); - task::spawn(|| child() ); - let x = p.recv(); -} diff --git a/src/test/run-fail/linked-failure4.rs b/src/test/run-fail/linked-failure4.rs deleted file mode 100644 index fc47f470dd0..00000000000 --- a/src/test/run-fail/linked-failure4.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// error-pattern:1 == 2 - -use std::comm; -use std::task; - -fn child() { assert!((1 == 2)); } - -fn parent() { - let (p, _c) = comm::stream::(); - task::spawn(|| child() ); - let x = p.recv(); -} - -// This task is not linked to the failure chain, but since the other -// tasks are going to fail the kernel, this one will fail too -fn sleeper() { - let (p, _c) = comm::stream::(); - let x = p.recv(); -} - -fn main() { - task::spawn(|| sleeper() ); - task::spawn(|| parent() ); -} diff --git a/src/test/run-fail/spawnfail.rs b/src/test/run-fail/spawnfail.rs deleted file mode 100644 index 01bc966e90a..00000000000 --- a/src/test/run-fail/spawnfail.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// error-pattern:explicit - -extern crate extra; - -use std::task; - -// We don't want to see any invalid reads -fn main() { - fn f() { - fail!(); - } - task::spawn(|| f() ); -} diff --git a/src/test/run-fail/task-comm-recv-block.rs b/src/test/run-fail/task-comm-recv-block.rs deleted file mode 100644 index 2eaca95ce2f..00000000000 --- a/src/test/run-fail/task-comm-recv-block.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// error-pattern:goodfail - -use std::comm; -use std::task; - -fn goodfail() { - task::deschedule(); - fail!("goodfail"); -} - -fn main() { - task::spawn(|| goodfail() ); - let (po, _c) = comm::stream(); - // We shouldn't be able to get past this recv since there's no - // message available - let i: int = po.recv(); - fail!("badfail"); -} diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 5383e9d5479..1ce6c1b77dd 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -13,32 +13,32 @@ #[feature(managed_boxes)]; -extern crate extra; extern crate time; +extern crate serialize; // These tests used to be separate files, but I wanted to refactor all // the common code. use std::hashmap::{HashMap, HashSet}; -use EBReader = extra::ebml::reader; -use EBWriter = extra::ebml::writer; +use EBReader = serialize::ebml::reader; +use EBWriter = serialize::ebml::writer; use std::cmp::Eq; use std::cmp; use std::io; use serialize::{Decodable, Encodable}; -fn test_ebml<'a, A: +fn test_ebml<'a, 'b, A: Eq + - Encodable + - Decodable> + Encodable> + + Decodable> >(a1: &A) { let mut wr = std::io::MemWriter::new(); let mut ebml_w = EBWriter::Encoder(&mut wr); a1.encode(&mut ebml_w); let bytes = wr.get_ref(); - let d: extra::ebml::Doc<'a> = EBReader::Doc(bytes); + let d: serialize::ebml::Doc<'a> = EBReader::Doc(bytes); let mut decoder: EBReader::Decoder<'a> = EBReader::Decoder(d); let a2: A = Decodable::decode(&mut decoder); assert!(*a1 == a2); diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs index 50ccac793c2..ac4101ae5b1 100644 --- a/src/test/run-pass/deriving-encodable-decodable.rs +++ b/src/test/run-pass/deriving-encodable-decodable.rs @@ -54,7 +54,7 @@ struct G { t: T } -fn roundtrip<'a, T: Rand + Eq + Encodable + +fn roundtrip<'a, T: Rand + Eq + Encodable> + Decodable>>() { let obj: T = random(); let mut w = MemWriter::new(); diff --git a/src/test/run-pass/for-destruct.rs b/src/test/run-pass/for-destruct.rs index d090f9a243c..fae67e9e3d9 100644 --- a/src/test/run-pass/for-destruct.rs +++ b/src/test/run-pass/for-destruct.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test: #3511: does not currently compile, due to rvalue issues - -use std::vec; - struct Pair { x: int, y: int } + pub fn main() { - for vec::each(~[Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) |elt| { + for elt in (~[Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]).iter() { assert_eq!(elt.x + elt.y, 30); } } diff --git a/src/test/run-pass/foreign-lib-path.rs b/src/test/run-pass/foreign-lib-path.rs deleted file mode 100644 index 3ee43d00dee..00000000000 --- a/src/test/run-pass/foreign-lib-path.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test FIXME I don't know how to test this (#2604) -// compile-flags:-L. -// The -L flag is also used for linking foreign libraries - -mod WHATGOESHERE { - // FIXME: I want to name a mod that would not link successfully - // wouthout providing a -L argument to the compiler, and that - // will also be found successfully at runtime. - extern { - pub fn IDONTKNOW() -> u32; - } -} - -pub fn main() { - assert_eq!(IDONTKNOW(), 0x_BAD_DOOD_u32); -} diff --git a/src/test/run-pass/foreign-mod.rc b/src/test/run-pass/foreign-mod.rc deleted file mode 100644 index 0e4114a3ad3..00000000000 --- a/src/test/run-pass/foreign-mod.rc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test FIXME #7308 - -native mod libc = target_libc { - fn open(int name, int flags, int mode) -> int; - fn close(int fd) -> int; - fn read(int fd, int buf, int count) -> int; - fn write(int fd, int buf, int count) -> int; - fn malloc(int sz) -> int; - fn free(int p) -> (); -} - -native "cdecl" mod rustrt { - fn str_buf(str s) -> int; -} - -mod inner = "native-mod-src/inner.rs"; diff --git a/src/test/run-pass/foreign.rc b/src/test/run-pass/foreign.rc deleted file mode 100644 index 129db5d8d44..00000000000 --- a/src/test/run-pass/foreign.rc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -native "cdecl" mod rustrt { - fn str_buf(str s) -> int; -} - - -native mod libc = target_libc { - fn puts(int s) -> (); -} - -mod user = "native-src/native.rs"; diff --git a/src/test/run-pass/lots-a-fail.rs b/src/test/run-pass/issue-1451.rs similarity index 62% rename from src/test/run-pass/lots-a-fail.rs rename to src/test/run-pass/issue-1451.rs index 9c33ff59dac..a0c0275c193 100644 --- a/src/test/run-pass/lots-a-fail.rs +++ b/src/test/run-pass/issue-1451.rs @@ -8,22 +8,26 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test linked failure +#[allow(unused_variable)]; -extern crate extra; +struct T { f: extern "Rust" fn() } +struct S { f: extern "Rust" fn() } -use std::task; - -fn die() { - fail!(); +fn fooS(t: S) { } -fn iloop() { - task::spawn(|| die() ); +fn fooT(t: T) { +} + +fn bar() { } pub fn main() { - for _ in range(0u, 100u) { - task::spawn_unlinked(|| iloop() ); - } + let x: extern "Rust" fn() = bar; + fooS(S {f: x}); + fooS(S {f: bar}); + + let x: extern "Rust" fn() = bar; + fooT(T {f: x}); + fooT(T {f: bar}); } diff --git a/src/test/run-pass/duplicate-use.rs b/src/test/run-pass/issue-2074.rs similarity index 70% rename from src/test/run-pass/duplicate-use.rs rename to src/test/run-pass/issue-2074.rs index c710eb5eafb..a8e3584364d 100644 --- a/src/test/run-pass/duplicate-use.rs +++ b/src/test/run-pass/issue-2074.rs @@ -8,13 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - -extern crate extra; - -use list = extra::oldmap::chained; -use extra::list; +#[allow(non_camel_case_types)]; pub fn main() { - let _x: list::T = list::mk(); + let one: || -> uint = || { + enum r { a }; + a as uint + }; + let two: || -> uint = || { + enum r { a }; + a as uint + }; + one(); two(); } diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index c00f5ddfb2b..0580dd89a30 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -8,18 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test +use std::task; static generations: uint = 1024+256+128+49; +fn spawn(f: proc()) { + let mut t = task::task(); + t.opts.stack_size = Some(32 * 1024); + t.spawn(f); +} + fn child_no(x: uint) -> proc() { - || { + proc() { if x < generations { - task::spawn(child_no(x+1)); + spawn(child_no(x+1)); } } } pub fn main() { - task::spawn(child_no(0)); + spawn(child_no(0)); } diff --git a/src/test/run-pass/issue-2190-2.rs b/src/test/run-pass/issue-2190-2.rs index b013e30047d..39a97b00b32 100644 --- a/src/test/run-pass/issue-2190-2.rs +++ b/src/test/run-pass/issue-2190-2.rs @@ -17,13 +17,13 @@ mod a { } mod b { - fn foo(f: Option<||>) { f.iter(|x|x()) } + fn foo(f: Option<||>) { f.map(|x|x()); } fn bar() {} pub fn main() { foo(Some(bar)); } } mod c { - fn foo(f: Option<||>) { f.iter(|x|x()) } + fn foo(f: Option<||>) { f.map(|x|x()); } fn bar() {} pub fn main() { foo(Some(||bar())); } } diff --git a/src/test/run-pass/issue-2190.rs b/src/test/run-pass/issue-2190.rs deleted file mode 100644 index daea219ff76..00000000000 --- a/src/test/run-pass/issue-2190.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -type t = { - f: proc() -}; - -pub fn main() { - let _t: t = { f: {||()} }; -} diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs deleted file mode 100644 index 34a855233a8..00000000000 --- a/src/test/run-pass/issue-3168.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -// ignore-fast - -use std::comm; -use std::task; - -pub fn main() { - let (p,c) = comm::stream(); - task::try(|| { - let (p2,c2) = comm::stream(); - task::spawn(|| { - p2.recv(); - error!("sibling fails"); - fail!(); - }); - let (p3,c3) = comm::stream(); - c.send(c3); - c2.send(()); - error!("child blocks"); - p3.recv(); - }); - error!("parent tries"); - assert!(!p.recv().try_send(())); - error!("all done!"); -} diff --git a/src/test/run-pass/issue-3290.rs b/src/test/run-pass/issue-3290.rs index 8cc91134c58..f2beda59733 100644 --- a/src/test/run-pass/issue-3290.rs +++ b/src/test/run-pass/issue-3290.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test FIXME #3290 pub fn main() { let mut x = ~3; x = x; diff --git a/src/test/run-pass/issue-3796.rs b/src/test/run-pass/issue-3796.rs deleted file mode 100644 index 37cccf717d5..00000000000 --- a/src/test/run-pass/issue-3796.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test FIXME #3796 - -#[deny(dead_assignment)]; -pub fn main() { - let mut x = 1; - let f: || -> int = || { x + 20 }; - assert_eq!(f(), 21); - x += 1; - assert_eq!(f(), 22); -} diff --git a/src/test/run-pass/issue-3904.rs b/src/test/run-pass/issue-3904.rs index 3360a726690..fe6521b4df9 100644 --- a/src/test/run-pass/issue-3904.rs +++ b/src/test/run-pass/issue-3904.rs @@ -8,30 +8,28 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - -type ErrPrinter = |&str, &str|; +type ErrPrinter<'a> = 'a |&str, &str|; fn example_err(prog: &str, arg: &str) { println!("{}: {}", prog, arg) } -fn exit(+print: ErrPrinter, prog: &str, arg: &str) { +fn exit(print: ErrPrinter, prog: &str, arg: &str) { print(prog, arg); } -struct X { - err: ErrPrinter +struct X<'a> { + err: ErrPrinter<'a> } -impl X { - pub fn boom() { +impl<'a> X<'a> { + pub fn boom(self) { exit(self.err, "prog", "arg"); } } pub fn main(){ - let val = &X{ + let val = X { err: example_err, }; val.boom(); diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs deleted file mode 100644 index f6c29658e6a..00000000000 --- a/src/test/run-pass/issue-4241.rs +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-fast -// ignore-test needs networking - -extern crate extra; - -use extra::net::tcp::TcpSocketBuf; - -use std::io; -use std::int; - -use std::io::{ReaderUtil,WriterUtil}; - -enum Result { - Nil, - Int(int), - Data(~[u8]), - List(~[Result]), - Error(~str), - Status(~str) -} - -priv fn parse_data(len: uint, io: @io::Reader) -> Result { - let res = - if (len > 0) { - let bytes = io.read_bytes(len as uint); - assert_eq!(bytes.len(), len); - Data(bytes) - } else { - Data(~[]) - }; - assert_eq!(io.read_char(), '\r'); - assert_eq!(io.read_char(), '\n'); - return res; -} - -priv fn parse_list(len: uint, io: @io::Reader) -> Result { - let mut list: ~[Result] = ~[]; - for _ in range(0, len) { - let v = match io.read_char() { - '$' => parse_bulk(io), - ':' => parse_int(io), - _ => fail!() - }; - list.push(v); - } - return List(list); -} - -priv fn chop(s: ~str) -> ~str { - s.slice(0, s.len() - 1).to_owned() -} - -priv fn parse_bulk(io: @io::Reader) -> Result { - match from_str::(chop(io.read_line())) { - None => fail!(), - Some(-1) => Nil, - Some(len) if len >= 0 => parse_data(len as uint, io), - Some(_) => fail!() - } -} - -priv fn parse_multi(io: @io::Reader) -> Result { - match from_str::(chop(io.read_line())) { - None => fail!(), - Some(-1) => Nil, - Some(0) => List(~[]), - Some(len) if len >= 0 => parse_list(len as uint, io), - Some(_) => fail!() - } -} - -priv fn parse_int(io: @io::Reader) -> Result { - match from_str::(chop(io.read_line())) { - None => fail!(), - Some(i) => Int(i) - } -} - -priv fn parse_response(io: @io::Reader) -> Result { - match io.read_char() { - '$' => parse_bulk(io), - '*' => parse_multi(io), - '+' => Status(chop(io.read_line())), - '-' => Error(chop(io.read_line())), - ':' => parse_int(io), - _ => fail!() - } -} - -priv fn cmd_to_str(cmd: ~[~str]) -> ~str { - let mut res = ~"*"; - res.push_str(cmd.len().to_str()); - res.push_str("\r\n"); - for s in cmd.iter() { - res.push_str([~"$", s.len().to_str(), ~"\r\n", - (*s).clone(), ~"\r\n"].concat() ); - } - res -} - -fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result { - let cmd = cmd_to_str(cmd); - //println!("{}", cmd); - sb.write_str(cmd); - let res = parse_response(@sb as @io::Reader); - res -} - -fn query2(cmd: ~[~str]) -> Result { - let _cmd = cmd_to_str(cmd); - io::with_str_reader(~"$3\r\nXXX\r\n")(|sb| { - let res = parse_response(@sb as @io::Reader); - println!("{:?}", res); - res - }); -} - - -pub fn main() { -} diff --git a/src/test/run-pass/issue-4542.rs b/src/test/run-pass/issue-4542.rs index e6a3d2fa3b2..024ee8c6dfe 100644 --- a/src/test/run-pass/issue-4542.rs +++ b/src/test/run-pass/issue-4542.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -11,9 +11,8 @@ use std::os; pub fn main() { - let x = os::args(); - for arg in x.iter() { - match arg.clone() { + for arg in os::args().iter() { + match (*arg).clone() { _s => { } } } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index ccf64144391..a922201c41a 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -8,19 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - -// ignored due to a bug in move detection for macros. - -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. +#[feature(macro_rules)]; use std::{option, cast}; @@ -42,7 +30,7 @@ impl E { } fn get_ref<'r>(&'r self) -> (int, &'r T) { match *self { - Nothing(..) => fail!("E::get_ref(Nothing::<%s>)", stringify!($T)), + Nothing(..) => fail!("E::get_ref(Nothing::<{}>)", stringify!(T)), Thing(x, ref y) => (x, y) } } @@ -71,7 +59,7 @@ macro_rules! check_fancy { let t_ = Thing::<$T>(23, e); match t_.get_ref() { (23, $v) => { $chk } - _ => fail!("Thing::<%s>(23, %s).get_ref() != (23, _)", + _ => fail!("Thing::<{}>(23, {}).get_ref() != (23, _)", stringify!($T), stringify!($e)) } }} @@ -91,7 +79,7 @@ pub fn main() { check_type!(~"foo": ~str); check_type!(~[20, 22]: ~[int]); let mint: uint = unsafe { cast::transmute(main) }; - check_type!(main: extern fn(), |pthing| { + check_type!(main: fn(), |pthing| { assert!(mint == unsafe { cast::transmute(*pthing) }) }); } diff --git a/src/test/run-pass/send-iloop.rs b/src/test/run-pass/send-iloop.rs deleted file mode 100644 index 5116dcb8dc8..00000000000 --- a/src/test/run-pass/send-iloop.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure -extern crate extra; - -use std::comm; -use std::task; - -fn die() { - fail!(); -} - -fn iloop() { - task::spawn(|| die() ); - let (p, c) = comm::stream::<()>(); - loop { - // Sending and receiving here because these actions deschedule, - // at which point our child can kill us. - c.send(()); - p.recv(); - // The above comment no longer makes sense but I'm - // reluctant to remove a linked failure test case. - task::deschedule(); - } -} - -pub fn main() { - for _ in range(0u, 16u) { - task::spawn_unlinked(|| iloop() ); - } -} diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs deleted file mode 100644 index 61af43ae161..00000000000 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure - -// A port of task-killjoin to use a class with a dtor to manage -// the join. - -use std::cell::Cell; -use std::comm::*; -use std::ptr; -use std::task; - -struct notify { - ch: Chan, - v: @Cell, -} - -#[unsafe_destructor] -impl Drop for notify { - fn drop(&mut self) { - unsafe { - error!("notify: task=%? v=%x unwinding=%b b=%b", - 0, - ptr::to_unsafe_ptr(&(*(self.v))) as uint, - task::failing(), - *(self.v)); - let b = *(self.v); - self.ch.send(b); - } - } -} - -fn notify(ch: Chan, v: @Cell) -> notify { - notify { - ch: ch, - v: v - } -} - -fn joinable(f: proc()) -> Port { - fn wrapper(c: Chan, f: ||) { - let b = @Cell::new(false); - error!("wrapper: task=%? allocated v=%x", - 0, - ptr::to_unsafe_ptr(&b) as uint); - let _r = notify(c, b); - f(); - *b = true; - } - let (p, c) = stream(); - task::spawn_unlinked(proc() { - let ccc = c; - wrapper(ccc, f) - }); - p -} - -fn join(port: Port) -> bool { - port.recv() -} - -fn supervised() { - // Deschedule to make sure the supervisor joins before we - // fail. This is currently not needed because the supervisor - // runs first, but I can imagine that changing. - error!("supervised task=%?", 0); - task::deschedule(); - fail!(); -} - -fn supervisor() { - error!("supervisor task=%?", 0); - let t = joinable(supervised); - join(t); -} - -pub fn main() { - join(joinable(supervisor)); -} diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs deleted file mode 100644 index 3d4e091beee..00000000000 --- a/src/test/run-pass/task-killjoin.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test linked failure - -// Create a task that is supervised by another task, join the supervised task -// from the supervising task, then fail the supervised task. The supervised -// task will kill the supervising task, waking it up. The supervising task no -// longer needs to be wakened when the supervised task exits. - -use std::task; - -fn supervised() { - // Deschedule to make sure the supervisor joins before we fail. This is - // currently not needed because the supervisor runs first, but I can - // imagine that changing. - task::deschedule(); - fail!(); -} - -fn supervisor() { - // Unsupervise this task so the process doesn't return a failure status as - // a result of the main task being killed. - let f = supervised; - task::try(supervised); -} - -pub fn main() { - task::spawn_unlinked(supervisor) -}