auto merge of #6115 : jbclements/rust/test-case-fixes, r=jbclements

In developing the grammar a few weeks ago, I fixed up a bunch of test cases that had rotted to the point that they didn't parse.
This commit is contained in:
bors
2013-04-30 21:12:36 -07:00
25 changed files with 146 additions and 304 deletions
-13
View File
@@ -1,13 +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 <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.
#[link(name = "issue2196a", vers = "0.1")];
#[crate_type = "lib"];
-18
View File
@@ -1,18 +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 <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.
#[link(name = "issue2196b", vers = "0.1")];
#[crate_type = "lib"];
use a(name = "issue2196a");
type d = str;
impl d for d { }
-16
View File
@@ -1,16 +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 <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.
#[link(name = "issue2196c", vers = "0.1")];
#[crate_type = "lib"];
use b(name = "issue2196b");
#[path = "issue-2196-d.rs"]
mod d;
View File
+7 -4
View File
@@ -8,13 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[link (name = "issue2378a")];
#[crate_type = "lib"];
enum maybe<T> { just(T), nothing }
impl copy> for maybe<T> for methods<T {
fn ~[](idx: uint) -> T {
impl <T:Copy> Index<uint,T> for maybe<T> {
fn index(&self, idx: &uint) -> T {
match self {
just(t) { t }
nothing { fail!(); }
&just(ref t) => copy *t,
&nothing => { fail!(); }
}
}
}
+8 -6
View File
@@ -8,15 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use issue2378a;
#[link (name = "issue2378b")];
#[crate_type = "lib"];
extern mod issue2378a;
use issue2378a::maybe;
use issue2378a::methods;
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
struct two_maybes<T> {a: maybe<T>, b: maybe<T>}
impl copy> for two_maybes<T> for methods<T {
fn ~[](idx: uint) -> (T, T) {
(self.a[idx], self.b[idx])
impl <T:Copy> Index<uint,(T,T)> for two_maybes<T> {
fn index(&self, idx: &uint) -> (T, T) {
(self.a[*idx], self.b[*idx])
}
}
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// 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.
//
@@ -8,7 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use b::d;
type t = uint;
// error-pattern:unresolved enum variant
fn main() {
let z = match 3 {
x() => x
};
assert_eq!(z,3);
}
-17
View File
@@ -1,17 +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 <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.
// exec-env:RUST_CC_ZEAL=1
// xfail-test
pub fn main() {
error!("%?", os::getenv(~"RUST_CC_ZEAL"));
let _x = @{a: @10, b: ~true};
}
-33
View File
@@ -1,33 +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 <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.
// exec-env:RUST_CC_ZEAL=1
enum maybe_pointy {
none,
p(@mut Pointy)
}
struct Pointy {
a : maybe_pointy,
f : @fn()->(),
}
fn empty_pointy() -> @mut Pointy {
return @mut Pointy{
a : none,
f : || {},
}
}
pub fn main() {
let v = ~[empty_pointy(), empty_pointy()];
v[0].a = p(v[0]);
}
+28 -4
View File
@@ -8,22 +8,46 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test FIXME #2263
// does the second one subsume the first?
// xfail-test
// xfail-fast
// notes on this test case:
// On Thu, Apr 18, 2013 at 6:30 PM, John Clements <clements@brinckerhoff.org> wrote:
// the "issue-2185.rs" test was xfailed with a ref to #2263. Issue #2263 is now fixed, so I tried it again, and after adding some &self parameters, I got this error:
//
// Running /usr/local/bin/rustc:
// issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait
// issue-2185.rs:24 impl iterable<uint> for @fn(&fn(uint)) {
// issue-2185.rs:25 fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
// issue-2185.rs:26 }
// issue-2185.rs:20:0: 22:1 note: note conflicting implementation here
// issue-2185.rs:20 impl<A> iterable<A> for @fn(&fn(A)) {
// issue-2185.rs:21 fn iter(&self, blk: &fn(A)) { self(blk); }
// issue-2185.rs:22 }
//
// … so it looks like it's just not possible to implement both the generic iterable<uint> and iterable<A> for the type iterable<uint>. Is it okay if I just remove this test?
//
// but Niko responded:
// think it's fine to remove this test, just because it's old and cruft and not hard to reproduce. *However* it should eventually be possible to implement the same interface for the same type multiple times with different type parameters, it's just that our current trait implementation has accidental limitations.
// so I'm leaving it in.
// actually, it looks like this is related to bug #3429. I'll rename this bug.
// This test had to do with an outdated version of the iterable trait.
// However, the condition it was testing seemed complex enough to
// warrant still having a test, so I inlined the old definitions.
trait iterable<A> {
fn iter(blk: &fn(A));
fn iter(&self, blk: &fn(A));
}
impl<A> iterable<A> for @fn(&fn(A)) {
fn iter(blk: &fn(A)) { self(blk); }
fn iter(&self, blk: &fn(A)) { self(blk); }
}
impl iterable<uint> for @fn(&fn(uint)) {
fn iter(blk: &fn(&&v: uint)) { self( |i| blk(i) ) }
fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
}
fn filter<A,IA:iterable<A>>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) {
-19
View File
@@ -1,19 +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 <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.
// xfail-test
// aux-build:issue-2196-a.rs
// aux-build:issue-2196-b.rs
// aux-build:issue-2196-c.rc
use c(name = "issue2196c");
use c::t;
pub fn main() { }
-24
View File
@@ -1,24 +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 <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.
// xfail-test
enum pat { pat_ident(Option<uint>) }
fn f(pat: pat) -> bool { true }
fn num_bindings(pat: pat) -> uint {
match pat {
pat_ident(_) if f(pat) { 0 }
pat_ident(None) { 1 }
pat_ident(Some(sub)) { sub }
}
}
pub fn main() {}
-26
View File
@@ -1,26 +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 <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.
// xfail-test
type IMap<K:Copy,V:Copy> = ~[(K, V)];
trait ImmutableMap<K:Copy,V:Copy>
{
fn contains_key(key: K) -> bool;
}
impl<K:Copy,V:Copy> IMap<K, V> : ImmutableMap<K, V>
{
fn contains_key(key: K) -> bool {
vec::find(self, |e| {e.first() == key}).is_some()
}
}
pub fn main() {}
+1 -1
View File
@@ -32,7 +32,7 @@ fn X(&self) -> int {
}
}
impl Point: Movable<int, int>;
impl Movable<int, int> for Point;
pub fn main() {
let p = Point{ x: 1, y: 2};
+6 -6
View File
@@ -8,17 +8,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test -- #2378 unfixed
// aux-build:issue2378a.rs
// aux-build:issue2378b.rs
// xfail-fast - check-fast doesn't understand aux-build
use issue2378a;
use issue2378b;
extern mod issue2378a;
extern mod issue2378b;
use issue2378a::{just, methods};
use issue2378b::{methods};
use issue2378a::{just};
use issue2378b::{two_maybes};
pub fn main() {
let x = {a: just(3), b: just(5)};
let x = two_maybes{a: just(3), b: just(5)};
assert!(x[0u] == (3, 5));
}
+8 -6
View File
@@ -10,16 +10,18 @@
// xfail-test
// -*- rust -*-
extern mod std;
extern mod core;
use core::gc;
use core::gc::rustrt;
type cell = {c: @list};
struct cell {c: @list}
enum list { link(@mut cell), nil, }
pub fn main() {
let first: @cell = @mut {c: @nil()};
let second: @cell = @mut {c: @link(first)};
let first: @cell = @mut cell{c: @nil()};
let second: @cell = @mut cell{c: @link(first)};
first._0 = @link(second);
sys.rustrt.gc();
let third: @cell = @mut {c: @nil()};
rustrt::gc();
let third: @cell = @mut cell{c: @nil()};
}
+5 -3
View File
@@ -13,7 +13,7 @@
fn starve_main(alive: chan<int>) {
debug!("signalling main");
alive <| 1;
alive.recv(1);
debug!("starving main");
let i: int = 0;
loop { i += 1; }
@@ -22,10 +22,12 @@ fn starve_main(alive: chan<int>) {
pub fn main() {
let alive: port<int> = port();
debug!("main started");
let s: task = spawn starve_main(chan(alive));
let s: task = do task::spawn {
starve_main(chan(alive));
};
let i: int;
debug!("main waiting for alive signal");
alive |> i;
alive.send(i);
debug!("main got alive signal");
while i < 50 { debug!("main iterated"); i += 1; }
debug!("main completed");
+2 -4
View File
@@ -8,20 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
// Issue #2263.
// Here, `f` is a function that takes a pointer `x` and a function
// `g`, where `g` requires its argument `y` to be in the same region
// that `x` is in.
fn has_same_region(f: &fn(x: &a.int, g: &fn(y: &a.int))) {
fn has_same_region(f: &fn<'a>(x: &'a int, g: &fn(y: &'a int))) {
// `f` should be the type that `wants_same_region` wants, but
// right now the compiler complains that it isn't.
wants_same_region(f);
}
fn wants_same_region(_f: &fn(x: &b.int, g: &fn(y: &b.int))) {
fn wants_same_region(_f: &fn<'b>(x: &'b int, g: &fn(y: &'b int))) {
}
pub fn main() {
+9 -11
View File
@@ -8,27 +8,25 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
tag a_tag<A> {
a_tag(A);
enum a_tag<A> {
a_tag(A)
}
type t_rec = {
struct t_rec {
c8: u8,
t: a_tag<u64>
};
fn mk_rec() -> t_rec {
return { c8:0u8, t:a_tag(0u64) };
}
fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool {
fn mk_rec() -> t_rec {
return t_rec { c8:0u8, t:a_tag(0u64) };
}
fn is_8_byte_aligned(u: &a_tag<u64>) -> bool {
let p = ptr::to_unsafe_ptr(u) as uint;
return (p & 7u) == 0u;
}
pub fn main() {
let x = mk_rec();
assert!(is_8_byte_aligned(x.t));
assert!(is_8_byte_aligned(&x.t));
}
+32 -34
View File
@@ -8,64 +8,62 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
tag a_tag<A,B> {
varA(A);
varB(B);
enum a_tag<A,B> {
varA(A),
varB(B)
}
type t_rec<A,B> = {
struct t_rec<A,B> {
chA: u8,
tA: a_tag<A,B>,
chB: u8,
tB: a_tag<A,B>
};
fn mk_rec<A:copy,B:copy>(a: A, b: B) -> t_rec<A,B> {
return { chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
}
fn is_aligned<A>(amnt: uint, &&u: A) -> bool {
fn mk_rec<A:Copy,B:Copy>(a: A, b: B) -> t_rec<A,B> {
return t_rec{ chA:0u8, tA:varA(a), chB:1u8, tB:varB(b) };
}
fn is_aligned<A>(amnt: uint, u: &A) -> bool {
let p = ptr::to_unsafe_ptr(u) as uint;
return (p & (amnt-1u)) == 0u;
}
fn variant_data_is_aligned<A,B>(amnt: uint, &&u: a_tag<A,B>) -> bool {
fn variant_data_is_aligned<A,B>(amnt: uint, u: &a_tag<A,B>) -> bool {
match u {
varA(a) { is_aligned(amnt, a) }
varB(b) { is_aligned(amnt, b) }
&varA(ref a) => is_aligned(amnt, a),
&varB(ref b) => is_aligned(amnt, b)
}
}
pub fn main() {
let x = mk_rec(22u64, 23u64);
assert!(is_aligned(8u, x.tA));
assert!(variant_data_is_aligned(8u, x.tA));
assert!(is_aligned(8u, x.tB));
assert!(variant_data_is_aligned(8u, x.tB));
assert!(is_aligned(8u, &x.tA));
assert!(variant_data_is_aligned(8u, &x.tA));
assert!(is_aligned(8u, &x.tB));
assert!(variant_data_is_aligned(8u, &x.tB));
let x = mk_rec(22u64, 23u32);
assert!(is_aligned(8u, x.tA));
assert!(variant_data_is_aligned(8u, x.tA));
assert!(is_aligned(8u, x.tB));
assert!(variant_data_is_aligned(4u, x.tB));
assert!(is_aligned(8u, &x.tA));
assert!(variant_data_is_aligned(8u, &x.tA));
assert!(is_aligned(8u, &x.tB));
assert!(variant_data_is_aligned(4u, &x.tB));
let x = mk_rec(22u32, 23u64);
assert!(is_aligned(8u, x.tA));
assert!(variant_data_is_aligned(4u, x.tA));
assert!(is_aligned(8u, x.tB));
assert!(variant_data_is_aligned(8u, x.tB));
assert!(is_aligned(8u, &x.tA));
assert!(variant_data_is_aligned(4u, &x.tA));
assert!(is_aligned(8u, &x.tB));
assert!(variant_data_is_aligned(8u, &x.tB));
let x = mk_rec(22u32, 23u32);
assert!(is_aligned(4u, x.tA));
assert!(variant_data_is_aligned(4u, x.tA));
assert!(is_aligned(4u, x.tB));
assert!(variant_data_is_aligned(4u, x.tB));
assert!(is_aligned(4u, &x.tA));
assert!(variant_data_is_aligned(4u, &x.tA));
assert!(is_aligned(4u, &x.tB));
assert!(variant_data_is_aligned(4u, &x.tB));
let x = mk_rec(22f64, 23f64);
assert!(is_aligned(8u, x.tA));
assert!(variant_data_is_aligned(8u, x.tA));
assert!(is_aligned(8u, x.tB));
assert!(variant_data_is_aligned(8u, x.tB));
assert!(is_aligned(8u, &x.tA));
assert!(variant_data_is_aligned(8u, &x.tA));
assert!(is_aligned(8u, &x.tB));
assert!(variant_data_is_aligned(8u, &x.tB));
}
+6 -10
View File
@@ -8,22 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
//
// See issue #1535
tag a_tag {
a_tag(u64);
enum a_tag {
a_tag(u64)
}
type t_rec = {
struct t_rec {
c8: u8,
t: a_tag
};
}
pub fn main() {
let x = {c8: 22u8, t: a_tag(44u64)};
let x = t_rec {c8: 22u8, t: a_tag(44u64)};
let y = fmt!("%?", x);
debug!("y = %s", y);
assert!(y == "(22, a_tag(44))");
assert_eq!(y, ~"{c8: 22, t: a_tag(44)}");
}
+9 -10
View File
@@ -8,27 +8,26 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
tag a_tag {
a_tag(u64);
enum a_tag {
a_tag(u64)
}
type t_rec = {
struct t_rec {
c8: u8,
t: a_tag
};
fn mk_rec() -> t_rec {
return { c8:0u8, t:a_tag(0u64) };
}
fn is_8_byte_aligned(&&u: a_tag) -> bool {
fn mk_rec() -> t_rec {
return t_rec { c8:0u8, t:a_tag(0u64) };
}
fn is_8_byte_aligned(u: &a_tag) -> bool {
let p = ptr::to_unsafe_ptr(u) as u64;
return (p & 7u64) == 0u64;
}
pub fn main() {
let x = mk_rec();
assert!(is_8_byte_aligned(x.t));
assert!(is_8_byte_aligned(&x.t));
}
-27
View File
@@ -1,27 +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 <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.
// xfail-test
fn is_even(i: int) -> bool { (i%2) == 0 }
fn even(i: int) : is_even(i) -> int { i }
fn test() {
let v = 4;
loop {
check is_even(v);
break;
}
even(v);
}
pub fn main() {
test();
}
+16 -9
View File
@@ -8,9 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-test
use sys::rustrt::size_of;
extern mod std;
extern mod core;
use core::sys::size_of;
struct t {a: u8, b: i8}
struct u {a: u8, b: i8, c: u8}
struct v {a: u8, b: i8, c: v2, d: u32}
struct v2 {u: char, v: u8}
struct w {a: int, b: ()}
struct x {a: int, b: (), c: ()}
struct y {x: int}
pub fn main() {
assert!((size_of::<u8>() == 1 as uint));
@@ -18,14 +25,14 @@ pub fn main() {
assert!((size_of::<char>() == 4 as uint));
assert!((size_of::<i8>() == 1 as uint));
assert!((size_of::<i32>() == 4 as uint));
assert!((size_of::<{a: u8, b: i8}>() == 2 as uint));
assert!((size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint));
assert!((size_of::<t>() == 2 as uint));
assert!((size_of::<u>() == 3 as uint));
// Alignment causes padding before the char and the u32.
assert!(size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() ==
assert!(size_of::<v>() ==
16 as uint);
assert!((size_of::<int>() == size_of::<uint>()));
assert!((size_of::<{a: int, b: ()}>() == size_of::<int>()));
assert!((size_of::<{a: int, b: (), c: ()}>() == size_of::<int>()));
assert!((size_of::<int>() == size_of::<{x: int}>()));
assert!((size_of::<w>() == size_of::<int>()));
assert!((size_of::<x>() == size_of::<int>()));
assert!((size_of::<int>() == size_of::<y>()));
}