auto merge of #8305 : huonw/rust/triage-fixes, r=cmr
The two deletions are because the test cases are very old (still using `class` and modes!), and, as far as I can tell (since they are so old), the areas they test are well tested by other rpass tests.
This commit is contained in:
commit
597b3fd03f
@ -3304,19 +3304,22 @@ mod tests {
|
||||
fn test_add() {
|
||||
#[allow(unnecessary_allocation)];
|
||||
macro_rules! t (
|
||||
($s1:expr, $s2:expr, $e:expr) => {
|
||||
assert_eq!($s1 + $s2, $e);
|
||||
assert_eq!($s1.to_owned() + $s2, $e);
|
||||
assert_eq!($s1.to_managed() + $s2, $e);
|
||||
}
|
||||
($s1:expr, $s2:expr, $e:expr) => { {
|
||||
let s1 = $s1;
|
||||
let s2 = $s2;
|
||||
let e = $e;
|
||||
assert_eq!(s1 + s2, e.to_owned());
|
||||
assert_eq!(s1.to_owned() + s2, e.to_owned());
|
||||
assert_eq!(s1.to_managed() + s2, e.to_owned());
|
||||
} }
|
||||
);
|
||||
|
||||
t!("foo", "bar", ~"foobar");
|
||||
t!("foo", @"bar", ~"foobar");
|
||||
t!("foo", ~"bar", ~"foobar");
|
||||
t!("ศไทย中", "华Việt Nam", ~"ศไทย中华Việt Nam");
|
||||
t!("ศไทย中", @"华Việt Nam", ~"ศไทย中华Việt Nam");
|
||||
t!("ศไทย中", ~"华Việt Nam", ~"ศไทย中华Việt Nam");
|
||||
t!("foo", "bar", "foobar");
|
||||
t!("foo", @"bar", "foobar");
|
||||
t!("foo", ~"bar", "foobar");
|
||||
t!("ศไทย中", "华Việt Nam", "ศไทย中华Việt Nam");
|
||||
t!("ศไทย中", @"华Việt Nam", "ศไทย中华Việt Nam");
|
||||
t!("ศไทย中", ~"华Việt Nam", "ศไทย中华Việt Nam");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,83 +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 FIXME #7307
|
||||
// xfail-fast
|
||||
|
||||
extern mod extra;
|
||||
use extra::oldmap::*;
|
||||
|
||||
class cat : map<int, bool> {
|
||||
priv {
|
||||
// Yes, you can have negative meows
|
||||
let mut meows : int;
|
||||
fn meow() {
|
||||
self.meows += 1;
|
||||
error!("Meow %d", self.meows);
|
||||
if self.meows % 5 == 0 {
|
||||
self.how_hungry += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut how_hungry : int;
|
||||
let name : str;
|
||||
|
||||
new(in_x : int, in_y : int, in_name: str)
|
||||
{ self.meows = in_x; self.how_hungry = in_y; self.name = in_name; }
|
||||
|
||||
fn speak() { self.meow(); }
|
||||
|
||||
fn eat() -> bool {
|
||||
if self.how_hungry > 0 {
|
||||
error!("OM NOM NOM");
|
||||
self.how_hungry -= 2;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
error!("Not hungry!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
fn size() -> uint { self.meows as uint }
|
||||
fn insert(+k: int, +v: bool) -> bool {
|
||||
if v { self.meows += k; } else { self.meows -= k; };
|
||||
true
|
||||
}
|
||||
fn contains_key(&&k: int) -> bool { k <= self.meows }
|
||||
fn get(&&k:int) -> bool { k <= self.meows }
|
||||
fn [](&&k:int) -> bool { k <= self.meows }
|
||||
fn find(&&k:int) -> Option<bool> { Some(self.get(k)) }
|
||||
fn remove(&&k:int) -> Option<bool> { self.meows -= k; Some(true) }
|
||||
fn each(f: &fn(&&int, &&bool) -> bool) {
|
||||
let mut n = num::abs(self.meows);
|
||||
while n > 0 {
|
||||
if !f(n, true) { break; }
|
||||
n -= 1;
|
||||
}
|
||||
}
|
||||
fn each_key(&&f: &fn(&&int) -> bool) {
|
||||
for self.each |k, _v| { if !f(k) { break; } again;};
|
||||
}
|
||||
fn each_value(&&f: &fn(&&bool) -> bool) {
|
||||
for self.each |_k, v| { if !f(v) { break; } again;};
|
||||
}
|
||||
fn clear() { }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let nyan : cat = cat(0, 2, "nyan");
|
||||
for _ in range(1u, 5u) { nyan.speak(); }
|
||||
// cat returns true if uint input is greater than
|
||||
// the number of meows so far
|
||||
assert!((nyan.get(1)));
|
||||
assert!((!nyan.get(10)));
|
||||
}
|
@ -1,129 +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 FIXME #7305
|
||||
|
||||
extern mod extra;
|
||||
use extra::oldmap::*;
|
||||
use vec::*;
|
||||
use dvec::{dvec, extensions};
|
||||
|
||||
enum furniture { chair, couch, bed }
|
||||
enum body_part { finger, toe, nose, ear }
|
||||
|
||||
trait noisy {
|
||||
fn speak() -> int;
|
||||
}
|
||||
|
||||
trait scratchy {
|
||||
fn scratch() -> Option<furniture>;
|
||||
}
|
||||
|
||||
trait bitey {
|
||||
fn bite() -> body_part;
|
||||
}
|
||||
|
||||
fn vec_includes<T>(xs: ~[T], x: T) -> bool {
|
||||
for each(xs) |y| { if y == x { return true; }}
|
||||
return false;
|
||||
}
|
||||
|
||||
// vtables other than the 1st one don't seem to work
|
||||
class cat : noisy, scratchy, bitey {
|
||||
priv {
|
||||
let meows : @mut uint;
|
||||
let scratched : dvec<furniture>;
|
||||
let bite_counts : hashmap<body_part, uint>;
|
||||
|
||||
fn meow() -> uint {
|
||||
info!("Meow: %u", *self.meows);
|
||||
*self.meows += 1u;
|
||||
if *self.meows % 5u == 0u {
|
||||
*self.how_hungry += 1;
|
||||
}
|
||||
*self.meows
|
||||
}
|
||||
}
|
||||
|
||||
let how_hungry : @mut int;
|
||||
let name : str;
|
||||
|
||||
new(in_x : uint, in_y : int, in_name: str)
|
||||
{ self.meows = @mut in_x; self.how_hungry = @mut in_y;
|
||||
self.name = in_name; self.scratched = dvec();
|
||||
let hsher: hashfn<body_part> = |p| int::hash(p as int);
|
||||
let eqer : eqfn<body_part> = |p, q| p == q;
|
||||
let t : hashmap<body_part, uint> =
|
||||
hashmap::<body_part, uint>(hsher, eqer);
|
||||
self.bite_counts = t;
|
||||
do iter(~[finger, toe, nose, ear]) |p| {
|
||||
self.bite_counts.insert(p, 0u);
|
||||
};
|
||||
}
|
||||
|
||||
fn speak() -> int { self.meow() as int }
|
||||
fn meow_count() -> uint { *self.meows }
|
||||
fn scratch() -> Option<furniture> {
|
||||
let all = ~[chair, couch, bed];
|
||||
log(error, self.scratched);
|
||||
let mut rslt = None;
|
||||
for each(all) |thing| { if !self.scratched.contains(thing) {
|
||||
self.scratched.push(thing);
|
||||
return Some(thing); }}
|
||||
rslt
|
||||
}
|
||||
fn bite() -> body_part {
|
||||
error!("In bite()");
|
||||
let all = ~[toe, nose, ear];
|
||||
let mut min = finger;
|
||||
do iter(all) |next| {
|
||||
info!("min = %?", min);
|
||||
if self.bite_counts.get(next) < self.bite_counts.get(min) {
|
||||
min = next;
|
||||
}};
|
||||
self.bite_counts.insert(min, self.bite_counts.get(min) + 1u);
|
||||
info!("Bit %?", min);
|
||||
min
|
||||
}
|
||||
}
|
||||
|
||||
fn annoy_neighbors<T:noisy>(critter: T) {
|
||||
for i in range(0u, 10u) {
|
||||
let what = critter.speak();
|
||||
info!("%u %d", i, what);
|
||||
}
|
||||
}
|
||||
|
||||
fn bite_everything<T:bitey>(critter: T) -> bool {
|
||||
let mut left : ~[body_part] = ~[finger, toe, nose, ear];
|
||||
while left.len() > 0u {
|
||||
let part = critter.bite();
|
||||
info!("%? %?", left, part);
|
||||
if vec_includes(left, part) {
|
||||
left = vec::filter(left, |p| p != part );
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn scratched_something<T:scratchy>(critter: T) -> bool {
|
||||
option::is_some(critter.scratch())
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let nyan : cat = cat(0u, 2, "nyan");
|
||||
annoy_neighbors(nyan as noisy);
|
||||
assert_eq!(nyan.meow_count(), 10u);
|
||||
assert!((bite_everything(nyan as bitey)));
|
||||
assert!((scratched_something(nyan as scratchy)));
|
||||
}
|
@ -12,10 +12,4 @@ fn sum_imm(y: &[int]) -> int {
|
||||
sum(y)
|
||||
}
|
||||
|
||||
/* FIXME #7304
|
||||
fn sum_const(y: &const [int]) -> int {
|
||||
sum(y)
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -1,9 +1,3 @@
|
||||
/* FIXME #7302
|
||||
fn foo(v: &const [uint]) -> ~[uint] {
|
||||
v.to_owned()
|
||||
}
|
||||
*/
|
||||
|
||||
fn bar(v: &mut [uint]) -> ~[uint] {
|
||||
v.to_owned()
|
||||
}
|
||||
@ -14,7 +8,6 @@ fn bip(v: &[uint]) -> ~[uint] {
|
||||
|
||||
pub fn main() {
|
||||
let mut the_vec = ~[1u, 2, 3, 100];
|
||||
// assert_eq!(the_vec.clone(), foo(the_vec));
|
||||
assert_eq!(the_vec.clone(), bar(the_vec));
|
||||
assert_eq!(the_vec.clone(), bip(the_vec));
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ trait get {
|
||||
fn get(self) -> int;
|
||||
}
|
||||
|
||||
// FIXME #7302: Note: impl on a slice
|
||||
// Note: impl on a slice; we're checking that the pointers below
|
||||
// correctly get borrowed to `&`. (similar to impling for `int`, with
|
||||
// `&self` instead of `self`.)
|
||||
impl<'self> get for &'self int {
|
||||
fn get(self) -> int {
|
||||
return *self;
|
||||
@ -34,11 +36,6 @@ pub fn main() {
|
||||
info!("y=%d", y);
|
||||
assert_eq!(y, 6);
|
||||
|
||||
let x = ~6;
|
||||
let y = x.get();
|
||||
info!("y=%d", y);
|
||||
assert_eq!(y, 6);
|
||||
|
||||
let x = &6;
|
||||
let y = x.get();
|
||||
info!("y=%d", y);
|
||||
|
Loading…
Reference in New Issue
Block a user