1
Fork 0

test: More run-pass test fixes

This commit is contained in:
Patrick Walton 2012-12-05 16:51:32 -08:00
parent 7a065f2434
commit 6084032270
29 changed files with 47 additions and 45 deletions

View file

@ -13,7 +13,7 @@ struct cat {
} }
impl cat : ToStr { impl cat : ToStr {
pure fn to_str() -> ~str { self.name } pure fn to_str() -> ~str { copy self.name }
} }
priv impl cat { priv impl cat {

View file

@ -12,5 +12,5 @@ type header_map = HashMap<~str, @DVec<@~str>>;
// the unused ty param is necessary so this gets monomorphized // the unused ty param is necessary so this gets monomorphized
fn request<T: Copy>(req: header_map) { fn request<T: Copy>(req: header_map) {
let _x = *(*req.get(~"METHOD"))[0u]; let _x = *(copy *req.get(~"METHOD"))[0u];
} }

View file

@ -6,5 +6,5 @@ trait to_strz {
} }
impl ~str: to_strz { impl ~str: to_strz {
fn to_strz() -> ~str { self } fn to_strz() -> ~str { copy self }
} }

View file

@ -8,7 +8,7 @@ pub struct MyInt {
} }
pub impl MyInt : Add<MyInt, MyInt> { pub impl MyInt : Add<MyInt, MyInt> {
pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) } pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
} }
pub impl MyInt : Sub<MyInt, MyInt> { pub impl MyInt : Sub<MyInt, MyInt> {

View file

@ -1,6 +1,8 @@
fn main() { fn main() {
let x = ~{mut a: ~10, b: ~20}; let x = ~{mut a: ~10, b: ~20};
match x { match x {
~{ref a, ref b} => { assert **a == 10; (*x).a = ~30; assert **a == 30; } ~{a: ref a, b: ref b} => {
assert **a == 10; (*x).a = ~30; assert **a == 30;
}
} }
} }

View file

@ -9,7 +9,7 @@ fn main() {
match getopts(args, opts) { match getopts(args, opts) {
result::Ok(ref m) => result::Ok(ref m) =>
assert !opt_present(m, "b"), assert !opt_present(m, "b"),
result::Err(f) => fail fail_str(f) result::Err(ref f) => fail fail_str(*f)
}; };
} }

View file

@ -4,5 +4,5 @@ fn a_val(&&x: ~int, +y: ~int) -> int {
fn main() { fn main() {
let z = ~22; let z = ~22;
a_val(z, z); a_val(copy z, copy z);
} }

View file

@ -17,5 +17,5 @@ fn nyan(kitty: cat, _kitty_info: kitty_info) {
fn main() { fn main() {
let mut kitty = cat(); let mut kitty = cat();
nyan(kitty, {kitty: kitty}); nyan(copy kitty, {kitty: copy kitty});
} }

View file

@ -13,9 +13,9 @@ fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str
{ {
match table.find(&key) match table.find(&key)
{ {
option::Some(std::json::String(s)) => option::Some(std::json::String(copy s)) =>
{ {
s copy s
} }
option::Some(value) => option::Some(value) =>
{ {
@ -33,9 +33,9 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str,
{ {
match &data match &data
{ {
&std::json::Object(interface) => &std::json::Object(copy interface) =>
{ {
let name = lookup(interface, ~"ifDescr", ~""); let name = lookup(copy interface, ~"ifDescr", ~"");
let label = fmt!("%s-%s", managed_ip, name); let label = fmt!("%s-%s", managed_ip, name);
(label, bool_value(false)) (label, bool_value(false))

View file

@ -1,6 +1,6 @@
fn test_stack_assign() { fn test_stack_assign() {
let s: ~str = ~"a"; let s: ~str = ~"a";
log(debug, s); log(debug, copy s);
let t: ~str = ~"a"; let t: ~str = ~"a";
assert (s == t); assert (s == t);
let u: ~str = ~"b"; let u: ~str = ~"b";
@ -39,7 +39,7 @@ fn test_append() {
let mut s = ~"a"; let mut s = ~"a";
s += ~"b"; s += ~"b";
log(debug, s); log(debug, copy s);
assert (s == ~"ab"); assert (s == ~"ab");
let mut s = ~"c"; let mut s = ~"c";

View file

@ -21,7 +21,7 @@ fn main() {
// Check that no false positives are found in loops. // Check that no false positives are found in loops.
let mut q = ~40, p = 10; let mut q = ~40, p = 10;
loop { loop {
let i = q; let i = copy q;
p += *i; p += *i;
if p > 100 { break; } if p > 100 { break; }
} }

View file

@ -2,7 +2,7 @@
fn foo() -> fn@() -> int { fn foo() -> fn@() -> int {
let k = ~22; let k = ~22;
let _u = {a: k}; let _u = {a: copy k};
return fn@(move k) -> int { 22 }; return fn@(move k) -> int { 22 };
} }

View file

@ -3,6 +3,6 @@
fn main() { fn main() {
fn invoke(f: fn@()) { f(); } fn invoke(f: fn@()) { f(); }
let k = ~22; let k = ~22;
let _u = {a: k}; let _u = {a: copy k};
invoke(|| log(error, k) ) invoke(|| log(error, k) )
} }

View file

@ -30,7 +30,7 @@ fn runtest2(f: fn~(), frame_backoff: u32, last_stk: *u8) -> u32 {
// We switched stacks, go back and try to hit the dynamic linker // We switched stacks, go back and try to hit the dynamic linker
frame_backoff frame_backoff
} else { } else {
let frame_backoff = runtest2(f, frame_backoff, curr_stk); let frame_backoff = runtest2(copy f, frame_backoff, curr_stk);
if frame_backoff > 1u32 { if frame_backoff > 1u32 {
frame_backoff - 1u32 frame_backoff - 1u32
} else if frame_backoff == 1u32 { } else if frame_backoff == 1u32 {

View file

@ -1,6 +1,6 @@
enum myvec<X> = ~[X]; enum myvec<X> = ~[X];
fn myvec_deref<X: Copy>(mv: myvec<X>) -> ~[X] { return *mv; } fn myvec_deref<X: Copy>(mv: myvec<X>) -> ~[X] { return copy *mv; }
fn myvec_elt<X: Copy>(mv: myvec<X>) -> X { return mv[0]; } fn myvec_elt<X: Copy>(mv: myvec<X>) -> X { return mv[0]; }

View file

@ -7,7 +7,7 @@ struct Point {
} }
impl Point : ops::Add<Point,Point> { impl Point : ops::Add<Point,Point> {
pure fn add(other: &Point) -> Point { pure fn add(&self, other: &Point) -> Point {
Point {x: self.x + (*other).x, y: self.y + (*other).y} Point {x: self.x + (*other).x, y: self.y + (*other).y}
} }
} }

View file

@ -6,6 +6,6 @@
// Issue #50. // Issue #50.
fn main() { fn main() {
let x = {foo: ~"hello", bar: ~"world"}; let x = {foo: ~"hello", bar: ~"world"};
log(debug, x.foo); log(debug, copy x.foo);
log(debug, x.bar); log(debug, copy x.bar);
} }

View file

@ -22,8 +22,8 @@ fn find_pos<T:Eq>(n: T, h: ~[T]) -> Option<uint> {
fn bail_deep(x: ~[~[bool]]) { fn bail_deep(x: ~[~[bool]]) {
let mut seen = false; let mut seen = false;
for iter(x) |x| { for iter(copy x) |x| {
for iter(x) |x| { for iter(copy x) |x| {
assert !seen; assert !seen;
if x { seen = true; return; } if x { seen = true; return; }
} }

View file

@ -16,12 +16,12 @@ fn make_generic_record<A: Copy, B: Copy>(a: A, b: B) -> pair<A,B> {
fn test05_start(&&f: fn~(&&v: float, &&v: ~str) -> pair<float, ~str>) { fn test05_start(&&f: fn~(&&v: float, &&v: ~str) -> pair<float, ~str>) {
let p = f(22.22f, ~"Hi"); let p = f(22.22f, ~"Hi");
log(debug, p); log(debug, copy p);
assert p.a == 22.22f; assert p.a == 22.22f;
assert p.b == ~"Hi"; assert p.b == ~"Hi";
let q = f(44.44f, ~"Ho"); let q = f(44.44f, ~"Ho");
log(debug, q); log(debug, copy q);
assert q.a == 44.44f; assert q.a == 44.44f;
assert q.b == ~"Ho"; assert q.b == ~"Ho";
} }

View file

@ -25,6 +25,6 @@ fn main() {
let p_: path_ = { global: true, idents: ~[~"hi"], types: ~[t] }; let p_: path_ = { global: true, idents: ~[~"hi"], types: ~[t] };
let p: path = { data: p_, span: sp }; let p: path = { data: p_, span: sp };
let x = { sp: sp, path: p }; let x = { sp: sp, path: p };
log(error, x.path); log(error, copy x.path);
log(error, x); log(error, copy x);
} }

View file

@ -8,7 +8,7 @@ fn main() {
{ {
match io::file_writer(&path, [io::Create, io::Truncate]) { match io::file_writer(&path, [io::Create, io::Truncate]) {
Err(e) => fail e, Err(copy e) => fail e,
Ok(f) => { Ok(f) => {
for uint::range(0, 1000) |_i| { for uint::range(0, 1000) |_i| {
f.write_u8(0); f.write_u8(0);

View file

@ -6,7 +6,7 @@ extern mod std;
fn test1() { fn test1() {
let mut s: ~str = ~"hello"; let mut s: ~str = ~"hello";
s += ~"world"; s += ~"world";
log(debug, s); log(debug, copy s);
assert (s[9] == 'd' as u8); assert (s[9] == 'd' as u8);
} }
@ -16,8 +16,8 @@ fn test2() {
let ff: ~str = ~"abc"; let ff: ~str = ~"abc";
let a: ~str = ff + ~"ABC" + ff; let a: ~str = ff + ~"ABC" + ff;
let b: ~str = ~"ABC" + ff + ~"ABC"; let b: ~str = ~"ABC" + ff + ~"ABC";
log(debug, a); log(debug, copy a);
log(debug, b); log(debug, copy b);
assert (a == ~"abcABCabc"); assert (a == ~"abcABCabc");
assert (b == ~"ABCabcABC"); assert (b == ~"ABCabcABC");
} }

View file

@ -6,6 +6,6 @@ fn main() {
let a: ~str = ~"hello"; let a: ~str = ~"hello";
let b: ~str = ~"world"; let b: ~str = ~"world";
let s: ~str = a + b; let s: ~str = a + b;
log(debug, s); log(debug, copy s);
assert (s[9] == 'd' as u8); assert (s[9] == 'd' as u8);
} }

View file

@ -1,8 +1,8 @@
extern mod std; extern mod std;
fn test(actual: ~str, expected: ~str) { fn test(actual: ~str, expected: ~str) {
log(debug, actual); log(debug, copy actual);
log(debug, expected); log(debug, copy expected);
assert (actual == expected); assert (actual == expected);
} }
@ -249,4 +249,4 @@ fn more_floats() {
assert ~"99" == fmt!("%.0f", 98.5); assert ~"99" == fmt!("%.0f", 98.5);
assert ~"7.0000" == fmt!("%.4f", 6.999999999); assert ~"7.0000" == fmt!("%.4f", 6.999999999);
assert ~"3.141590000" == fmt!("%.9f", 3.14159); assert ~"3.141590000" == fmt!("%.9f", 3.14159);
} }

View file

@ -5,7 +5,7 @@ trait MyNum : Add<self,self>, Sub<self,self>, Mul<self,self>, Eq { }
struct MyInt { val: int } struct MyInt { val: int }
impl MyInt : Add<MyInt, MyInt> { impl MyInt : Add<MyInt, MyInt> {
pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) } pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
} }
impl MyInt : Sub<MyInt, MyInt> { impl MyInt : Sub<MyInt, MyInt> {

View file

@ -2,9 +2,9 @@ fn main() {
let i = ~mut 1; let i = ~mut 1;
// Should be a copy // Should be a copy
let mut j; let mut j;
j = i; j = copy i;
*i = 2; *i = 2;
*j = 3; *j = 3;
assert *i == 2; assert *i == 2;
assert *j == 3; assert *j == 3;
} }

View file

@ -5,8 +5,8 @@ fn main() unsafe {
let i = ~@1; let i = ~@1;
let j = ~@2; let j = ~@2;
let rc1 = refcount(*i); let rc1 = refcount(*i);
let j = i; let j = copy i;
let rc2 = refcount(*i); let rc2 = refcount(*i);
error!("rc1: %u rc2: %u", rc1, rc2); error!("rc1: %u rc2: %u", rc1, rc2);
assert rc1 + 1u == rc2; assert rc1 + 1u == rc2;
} }

View file

@ -1,6 +1,6 @@
fn main() { fn main() {
let a = ~[~mut 10]; let a = ~[~mut 10];
let b = a; let b = copy a;
assert *a[0] == 10; assert *a[0] == 10;
assert *b[0] == 10; assert *b[0] == 10;
@ -10,4 +10,4 @@ fn main() {
assert *a[0] == 20; assert *a[0] == 20;
assert *b[0] == 10; assert *b[0] == 10;
} }

View file

@ -1,5 +1,5 @@
fn main() { fn main() {
let a = ~[1, 2, 3, 4, 5]; let a = ~[1, 2, 3, 4, 5];
let mut b = ~[a, a]; let mut b = ~[copy a, copy a];
b = b + b; // FIXME(#3387)---can't write b += b b = b + b; // FIXME(#3387)---can't write b += b
} }