test: Fix tests.
This commit is contained in:
parent
88fe4ae09c
commit
dc4bf173f8
|
@ -40,17 +40,6 @@ pub mod runtest;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
mod std {
|
|
||||||
pub use core::clone;
|
|
||||||
pub use core::cmp;
|
|
||||||
pub use core::str;
|
|
||||||
pub use core::sys;
|
|
||||||
pub use core::unstable;
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> test: Fix tests.
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let args = os::args();
|
let args = os::args();
|
||||||
let config = parse_config(args);
|
let config = parse_config(args);
|
||||||
|
@ -91,7 +80,7 @@ pub fn parse_config(args: ~[~str]) -> config {
|
||||||
];
|
];
|
||||||
|
|
||||||
assert!(!args.is_empty());
|
assert!(!args.is_empty());
|
||||||
let argv0 = copy args[0];
|
let argv0 = args[0].clone();
|
||||||
let args_ = args.tail();
|
let args_ = args.tail();
|
||||||
if args[1] == ~"-h" || args[1] == ~"--help" {
|
if args[1] == ~"-h" || args[1] == ~"--help" {
|
||||||
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
|
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
|
||||||
|
@ -128,17 +117,10 @@ pub fn parse_config(args: ~[~str]) -> config {
|
||||||
mode: str_mode(getopts::opt_str(matches, "mode")),
|
mode: str_mode(getopts::opt_str(matches, "mode")),
|
||||||
run_ignored: getopts::opt_present(matches, "ignored"),
|
run_ignored: getopts::opt_present(matches, "ignored"),
|
||||||
filter:
|
filter:
|
||||||
<<<<<<< HEAD
|
|
||||||
if !matches.free.is_empty() {
|
if !matches.free.is_empty() {
|
||||||
Some(matches.free[0].clone())
|
Some(matches.free[0].clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
=======
|
|
||||||
if !matches.free.is_empty() {
|
|
||||||
option::Some(matches.free[0].clone())
|
|
||||||
} else {
|
|
||||||
option::None
|
|
||||||
>>>>>>> test: Fix tests.
|
|
||||||
},
|
},
|
||||||
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
|
logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)),
|
||||||
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map(|s| Path(*s)),
|
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map(|s| Path(*s)),
|
||||||
|
|
|
@ -852,7 +852,7 @@ fn make_o_name(config: &config, testfile: &Path) -> Path {
|
||||||
|
|
||||||
fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
|
fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
|
||||||
if suffix.len() == 0 {
|
if suffix.len() == 0 {
|
||||||
copy *p
|
(*p).clone()
|
||||||
} else {
|
} else {
|
||||||
let stem = p.filestem().get();
|
let stem = p.filestem().get();
|
||||||
p.with_filestem(stem + "-" + suffix)
|
p.with_filestem(stem + "-" + suffix)
|
||||||
|
|
|
@ -45,6 +45,8 @@ A BigDigit is half the size of machine word size.
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub type BigDigit = u32;
|
pub type BigDigit = u32;
|
||||||
|
|
||||||
|
pub static ZERO_BIG_DIGIT: BigDigit = 0;
|
||||||
|
|
||||||
pub mod BigDigit {
|
pub mod BigDigit {
|
||||||
use bigint::BigDigit;
|
use bigint::BigDigit;
|
||||||
|
|
||||||
|
@ -614,7 +616,8 @@ impl BigUint {
|
||||||
priv fn shl_unit(&self, n_unit: uint) -> BigUint {
|
priv fn shl_unit(&self, n_unit: uint) -> BigUint {
|
||||||
if n_unit == 0 || self.is_zero() { return (*self).clone(); }
|
if n_unit == 0 || self.is_zero() { return (*self).clone(); }
|
||||||
|
|
||||||
return BigUint::new(vec::from_elem(n_unit, 0u32) + self.data);
|
return BigUint::new(vec::from_elem(n_unit, ZERO_BIG_DIGIT)
|
||||||
|
+ self.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -417,28 +417,28 @@ mod tests {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn test_parameterized<T:Clone + Eq>(a: T, b: T, c: T, d: T) {
|
fn test_parameterized<T:Clone + Eq>(a: T, b: T, c: T, d: T) {
|
||||||
let mut deq = Deque::new();
|
let mut deq = RingBuf::new();
|
||||||
assert_eq!(deq.len(), 0);
|
assert_eq!(deq.len(), 0);
|
||||||
deq.add_front(a.clone());
|
deq.push_front(a.clone());
|
||||||
deq.add_front(b.clone());
|
deq.push_front(b.clone());
|
||||||
deq.add_back(c.clone());
|
deq.push_back(c.clone());
|
||||||
assert_eq!(deq.len(), 3);
|
assert_eq!(deq.len(), 3);
|
||||||
deq.add_back(d.clone());
|
deq.push_back(d.clone());
|
||||||
assert_eq!(deq.len(), 4);
|
assert_eq!(deq.len(), 4);
|
||||||
assert_eq!((*deq.peek_front()).clone(), b.clone());
|
assert_eq!((*deq.front().get()).clone(), b.clone());
|
||||||
assert_eq!((*deq.peek_back()).clone(), d.clone());
|
assert_eq!((*deq.back().get()).clone(), d.clone());
|
||||||
assert_eq!(deq.pop_front(), b.clone());
|
assert_eq!(deq.pop_front().get(), b.clone());
|
||||||
assert_eq!(deq.pop_back(), d.clone());
|
assert_eq!(deq.pop_back().get(), d.clone());
|
||||||
assert_eq!(deq.pop_back(), c.clone());
|
assert_eq!(deq.pop_back().get(), c.clone());
|
||||||
assert_eq!(deq.pop_back(), a.clone());
|
assert_eq!(deq.pop_back().get(), a.clone());
|
||||||
assert_eq!(deq.len(), 0);
|
assert_eq!(deq.len(), 0);
|
||||||
deq.add_back(c.clone());
|
deq.push_back(c.clone());
|
||||||
assert_eq!(deq.len(), 1);
|
assert_eq!(deq.len(), 1);
|
||||||
deq.add_front(b.clone());
|
deq.push_front(b.clone());
|
||||||
assert_eq!(deq.len(), 2);
|
assert_eq!(deq.len(), 2);
|
||||||
deq.add_back(d.clone());
|
deq.push_back(d.clone());
|
||||||
assert_eq!(deq.len(), 3);
|
assert_eq!(deq.len(), 3);
|
||||||
deq.add_front(a.clone());
|
deq.push_front(a.clone());
|
||||||
assert_eq!(deq.len(), 4);
|
assert_eq!(deq.len(), 4);
|
||||||
assert_eq!((*deq.get(0)).clone(), a.clone());
|
assert_eq!((*deq.get(0)).clone(), a.clone());
|
||||||
assert_eq!((*deq.get(1)).clone(), b.clone());
|
assert_eq!((*deq.get(1)).clone(), b.clone());
|
||||||
|
|
|
@ -1021,6 +1021,7 @@ mod big_tests {
|
||||||
|
|
||||||
use sort::*;
|
use sort::*;
|
||||||
|
|
||||||
|
use std::cast::unsafe_copy;
|
||||||
use std::local_data;
|
use std::local_data;
|
||||||
use std::rand::RngUtil;
|
use std::rand::RngUtil;
|
||||||
use std::rand;
|
use std::rand;
|
||||||
|
|
|
@ -663,7 +663,7 @@ mod test {
|
||||||
let server_stream_watcher = server_stream_watcher;
|
let server_stream_watcher = server_stream_watcher;
|
||||||
rtdebug!("starting read");
|
rtdebug!("starting read");
|
||||||
let alloc: AllocCallback = |size| {
|
let alloc: AllocCallback = |size| {
|
||||||
vec_to_uv_buf(vec::from_elem(size, 0))
|
vec_to_uv_buf(vec::from_elem(size, 0u8))
|
||||||
};
|
};
|
||||||
do client_tcp_watcher.read_start(alloc) |stream_watcher, nread, buf, status| {
|
do client_tcp_watcher.read_start(alloc) |stream_watcher, nread, buf, status| {
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ mod test {
|
||||||
|
|
||||||
rtdebug!("starting read");
|
rtdebug!("starting read");
|
||||||
let alloc: AllocCallback = |size| {
|
let alloc: AllocCallback = |size| {
|
||||||
vec_to_uv_buf(vec::from_elem(size, 0))
|
vec_to_uv_buf(vec::from_elem(size, 0u8))
|
||||||
};
|
};
|
||||||
|
|
||||||
do server.recv_start(alloc) |server, nread, buf, src, flags, status| {
|
do server.recv_start(alloc) |server, nread, buf, src, flags, status| {
|
||||||
|
@ -862,7 +862,7 @@ mod test {
|
||||||
|
|
||||||
rtdebug!("starting read");
|
rtdebug!("starting read");
|
||||||
let alloc: AllocCallback = |size| {
|
let alloc: AllocCallback = |size| {
|
||||||
vec_to_uv_buf(vec::from_elem(size, 0))
|
vec_to_uv_buf(vec::from_elem(size, 0u8))
|
||||||
};
|
};
|
||||||
|
|
||||||
do server.recv_start(alloc) |server, nread, buf, src, flags, status| {
|
do server.recv_start(alloc) |server, nread, buf, src, flags, status| {
|
||||||
|
|
|
@ -3468,7 +3468,7 @@ mod tests {
|
||||||
assert_eq!(values, [2, 3, 5, 6, 7]);
|
assert_eq!(values, [2, 3, 5, 6, 7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq)]
|
#[deriving(Clone, Eq)]
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -199,11 +199,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
||||||
white => {
|
white => {
|
||||||
let i = i as node_id;
|
let i = i as node_id;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
let neighbors = &graph[i];
|
let neighbors = &graph[i];
|
||||||
=======
|
|
||||||
let neighbors = graph[i].clone();
|
|
||||||
>>>>>>> librustc: Remove all uses of "copy".
|
|
||||||
|
|
||||||
let mut color = white;
|
let mut color = white;
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
// 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 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Tests correct kind-checking of the reason stack closures without the :Copy
|
|
||||||
// bound must be noncopyable. For details see
|
|
||||||
// http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
|
|
||||||
|
|
||||||
struct R<'self> {
|
|
||||||
// This struct is needed to create the
|
|
||||||
// otherwise infinite type of a fn that
|
|
||||||
// accepts itself as argument:
|
|
||||||
c: &'self fn:Copy(&R, bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn innocent_looking_victim() {
|
|
||||||
let mut x = Some(~"hello");
|
|
||||||
do conspirator |f, writer| {
|
|
||||||
if writer {
|
|
||||||
x = None; //~ ERROR cannot implicitly borrow
|
|
||||||
} else {
|
|
||||||
match x {
|
|
||||||
Some(ref msg) => {
|
|
||||||
(f.c)(f, true);
|
|
||||||
println(fmt!("%?", msg));
|
|
||||||
},
|
|
||||||
None => fail!("oops"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn conspirator(f: &fn:Copy(&R, bool)) {
|
|
||||||
let r = R {c: f};
|
|
||||||
f(&r, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() { innocent_looking_victim() }
|
|
|
@ -24,14 +24,4 @@ fn main() {
|
||||||
|
|
||||||
copy2(@3);
|
copy2(@3);
|
||||||
copy2(@&x); //~ ERROR does not fulfill `'static`
|
copy2(@&x); //~ ERROR does not fulfill `'static`
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
let boxed: @fn() = || {};
|
|
||||||
copy2(boxed);
|
|
||||||
let owned: ~fn() = || {};
|
|
||||||
copy2(owned); //~ ERROR does not fulfill `Copy`
|
|
||||||
let borrowed: &fn:Copy() = || {};
|
|
||||||
copy2(borrowed); //~ ERROR does not fulfill `'static`
|
|
||||||
=======
|
|
||||||
>>>>>>> librustc: Remove all uses of "copy".
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
// 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 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Though it should be legal to copy a heap-allocated "once fn:Copy",
|
|
||||||
// stack closures are not deep-copied, so (counterintuitively) it should be
|
|
||||||
// illegal to copy them.
|
|
||||||
|
|
||||||
fn foo<'r>(blk: &'r once fn:Copy()) -> (&'r once fn:Copy(), &'r once fn:Copy()) {
|
|
||||||
(copy blk, blk) //~ ERROR copying a value of non-copyable type
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
// 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 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
||||||
// option. This file may not be copied, modified, or distributed
|
|
||||||
// except according to those terms.
|
|
||||||
|
|
||||||
// Ensures that it's legal to create a recursive stack closure as long as
|
|
||||||
// its environment is copyable
|
|
||||||
|
|
||||||
struct R<'self> {
|
|
||||||
// This struct is needed to create the
|
|
||||||
// otherwise infinite type of a fn that
|
|
||||||
// accepts itself as argument:
|
|
||||||
c: &'self fn:Copy(&R, uint) -> uint
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
// Stupid version of fibonacci.
|
|
||||||
let fib: &fn:Copy(&R, uint) -> uint = |fib, x| {
|
|
||||||
if x == 0 || x == 1 {
|
|
||||||
x
|
|
||||||
} else {
|
|
||||||
(fib.c)(fib, x-1) + (fib.c)(fib, x-2)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
assert!(fib(&R { c: fib }, 7) == 13);
|
|
||||||
}
|
|
|
@ -9,11 +9,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
trait vec_utils<T> {
|
trait vec_utils<T> {
|
||||||
fn map_<U:Copy>(x: &Self, f: &fn(&T) -> U) -> ~[U];
|
fn map_<U>(x: &Self, f: &fn(&T) -> U) -> ~[U];
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> vec_utils<T> for ~[T] {
|
impl<T> vec_utils<T> for ~[T] {
|
||||||
fn map_<U:Copy>(x: &~[T], f: &fn(&T) -> U) -> ~[U] {
|
fn map_<U>(x: &~[T], f: &fn(&T) -> U) -> ~[U] {
|
||||||
let mut r = ~[];
|
let mut r = ~[];
|
||||||
for x.iter().advance |elt| {
|
for x.iter().advance |elt| {
|
||||||
r.push(f(elt));
|
r.push(f(elt));
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn parse_args() -> ~str {
|
||||||
let mut n = 0;
|
let mut n = 0;
|
||||||
|
|
||||||
while n < args.len() {
|
while n < args.len() {
|
||||||
match copy args[n] {
|
match args[n].clone() {
|
||||||
~"-v" => (),
|
~"-v" => (),
|
||||||
s => {
|
s => {
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -172,7 +172,7 @@ pub fn main() {
|
||||||
visit_ty::<~[int]>(vv);
|
visit_ty::<~[int]>(vv);
|
||||||
|
|
||||||
for v.types.iter().advance |s| {
|
for v.types.iter().advance |s| {
|
||||||
println(fmt!("type: %s", copy *s));
|
println(fmt!("type: %s", (*s).clone()));
|
||||||
}
|
}
|
||||||
assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]);
|
assert_eq!((*v.types).clone(), ~[~"bool", ~"int", ~"i8", ~"i16", ~"[", ~"int", ~"]"]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue