Skip to content

Commit

Permalink
tests: remove uses of Gc.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Oct 2, 2014
1 parent aa59693 commit 58bea31
Show file tree
Hide file tree
Showing 206 changed files with 322 additions and 3,702 deletions.
8 changes: 0 additions & 8 deletions src/liballoc/rc.rs
Expand Up @@ -541,14 +541,6 @@ mod tests {
assert!(y.upgrade().is_none());
}

#[test]
fn gc_inside() {
// see issue #11532
use std::gc::GC;
let a = Rc::new(RefCell::new(box(GC) 1i));
assert!(a.try_borrow_mut().is_some());
}

#[test]
fn weak_self_cyclic() {
struct Cycle {
Expand Down
44 changes: 0 additions & 44 deletions src/libcollections/ringbuf.rs
Expand Up @@ -532,7 +532,6 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
mod tests {
use std::fmt::Show;
use std::prelude::*;
use std::gc::{GC, Gc};
use std::hash;
use test::Bencher;
use test;
Expand Down Expand Up @@ -587,43 +586,6 @@ mod tests {
assert_eq!(*d.get(3), 4);
}

#[test]
#[allow(deprecated)]
fn test_boxes() {
let a: Gc<int> = box(GC) 5;
let b: Gc<int> = box(GC) 72;
let c: Gc<int> = box(GC) 64;
let d: Gc<int> = box(GC) 175;

let mut deq = RingBuf::new();
assert_eq!(deq.len(), 0);
deq.push_front(a);
deq.push_front(b);
deq.push(c);
assert_eq!(deq.len(), 3);
deq.push(d);
assert_eq!(deq.len(), 4);
assert_eq!(deq.front(), Some(&b));
assert_eq!(deq.back(), Some(&d));
assert_eq!(deq.pop_front(), Some(b));
assert_eq!(deq.pop(), Some(d));
assert_eq!(deq.pop(), Some(c));
assert_eq!(deq.pop(), Some(a));
assert_eq!(deq.len(), 0);
deq.push(c);
assert_eq!(deq.len(), 1);
deq.push_front(b);
assert_eq!(deq.len(), 2);
deq.push(d);
assert_eq!(deq.len(), 3);
deq.push_front(a);
assert_eq!(deq.len(), 4);
assert_eq!(*deq.get(0), a);
assert_eq!(*deq.get(1), b);
assert_eq!(*deq.get(2), c);
assert_eq!(*deq.get(3), d);
}

#[cfg(test)]
fn test_parameterized<T:Clone + PartialEq + Show>(a: T, b: T, c: T, d: T) {
let mut deq = RingBuf::new();
Expand Down Expand Up @@ -755,12 +717,6 @@ mod tests {
test_parameterized::<int>(5, 72, 64, 175);
}

#[test]
fn test_param_at_int() {
test_parameterized::<Gc<int>>(box(GC) 5, box(GC) 72,
box(GC) 64, box(GC) 175);
}

#[test]
fn test_param_taggy() {
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
Expand Down
5 changes: 2 additions & 3 deletions src/libcoretest/iter.rs
Expand Up @@ -529,9 +529,8 @@ fn test_rposition() {
#[test]
#[should_fail]
fn test_rposition_fail() {
use std::gc::GC;
let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i),
(box 0i, box(GC) 0i), (box 0i, box(GC) 0i)];
let v = [(box 0i, box 0i), (box 0i, box 0i),
(box 0i, box 0i), (box 0i, box 0i)];
let mut i = 0i;
v.iter().rposition(|_elt| {
if i == 2 {
Expand Down
4 changes: 0 additions & 4 deletions src/libdebug/repr.rs
Expand Up @@ -572,7 +572,6 @@ fn test_repr() {
use std::io::stdio::println;
use std::char::is_alphabetic;
use std::mem::swap;
use std::gc::GC;

fn exact_test<T>(t: &T, e:&str) {
let mut m = io::MemWriter::new();
Expand All @@ -587,7 +586,6 @@ fn test_repr() {
exact_test(&1.234f64, "1.234f64");
exact_test(&("hello"), "\"hello\"");

exact_test(&(box(GC) 10i), "box(GC) 10");
exact_test(&(box 10i), "box 10");
exact_test(&(&10i), "&10");
let mut x = 10i;
Expand All @@ -601,8 +599,6 @@ fn test_repr() {
"&[\"hi\", \"there\"]");
exact_test(&(P{a:10, b:1.234}),
"repr::P{a: 10, b: 1.234f64}");
exact_test(&(box(GC) P{a:10, b:1.234}),
"box(GC) repr::P{a: 10, b: 1.234f64}");
exact_test(&(box P{a:10, b:1.234}),
"box repr::P{a: 10, b: 1.234f64}");

Expand Down
17 changes: 8 additions & 9 deletions src/librustrt/local_data.rs
Expand Up @@ -411,7 +411,6 @@ mod tests {
extern crate test;

use std::prelude::*;
use std::gc::{Gc, GC};
use super::*;
use std::task;

Expand Down Expand Up @@ -467,25 +466,25 @@ mod tests {
#[test]
fn test_tls_multiple_types() {
static str_key: Key<String> = &KeyValueKey;
static box_key: Key<Gc<()>> = &KeyValueKey;
static box_key: Key<Box<int>> = &KeyValueKey;
static int_key: Key<int> = &KeyValueKey;
task::spawn(proc() {
str_key.replace(Some("string data".to_string()));
box_key.replace(Some(box(GC) ()));
box_key.replace(Some(box 0));
int_key.replace(Some(42));
});
}

#[test]
fn test_tls_overwrite_multiple_types() {
static str_key: Key<String> = &KeyValueKey;
static box_key: Key<Gc<()>> = &KeyValueKey;
static box_key: Key<Box<int>> = &KeyValueKey;
static int_key: Key<int> = &KeyValueKey;
task::spawn(proc() {
str_key.replace(Some("string data".to_string()));
str_key.replace(Some("string data 2".to_string()));
box_key.replace(Some(box(GC) ()));
box_key.replace(Some(box(GC) ()));
box_key.replace(Some(box 0));
box_key.replace(Some(box 1));
int_key.replace(Some(42));
// This could cause a segfault if overwriting-destruction is done
// with the crazy polymorphic transmute rather than the provided
Expand All @@ -498,13 +497,13 @@ mod tests {
#[should_fail]
fn test_tls_cleanup_on_failure() {
static str_key: Key<String> = &KeyValueKey;
static box_key: Key<Gc<()>> = &KeyValueKey;
static box_key: Key<Box<int>> = &KeyValueKey;
static int_key: Key<int> = &KeyValueKey;
str_key.replace(Some("parent data".to_string()));
box_key.replace(Some(box(GC) ()));
box_key.replace(Some(box 0));
task::spawn(proc() {
str_key.replace(Some("string data".to_string()));
box_key.replace(Some(box(GC) ()));
box_key.replace(Some(box 2));
int_key.replace(Some(42));
fail!();
});
Expand Down
34 changes: 4 additions & 30 deletions src/librustrt/task.rs
Expand Up @@ -554,23 +554,14 @@ mod test {
use super::*;
use std::prelude::*;
use std::task;
use std::gc::{Gc, GC};

#[test]
fn local_heap() {
let a = box(GC) 5i;
let b = a;
assert!(*a == 5);
assert!(*b == 5);
}

#[test]
fn tls() {
local_data_key!(key: Gc<String>)
key.replace(Some(box(GC) "data".to_string()));
local_data_key!(key: String)
key.replace(Some("data".to_string()));
assert_eq!(key.get().unwrap().as_slice(), "data");
local_data_key!(key2: Gc<String>)
key2.replace(Some(box(GC) "data".to_string()));
local_data_key!(key2: String)
key2.replace(Some("data".to_string()));
assert_eq!(key2.get().unwrap().as_slice(), "data");
}

Expand Down Expand Up @@ -605,23 +596,6 @@ mod test {
assert!(rx.recv() == 10);
}

#[test]
fn heap_cycles() {
use std::cell::RefCell;

struct List {
next: Option<Gc<RefCell<List>>>,
}

let a = box(GC) RefCell::new(List { next: None });
let b = box(GC) RefCell::new(List { next: Some(a) });

{
let mut a = a.borrow_mut();
a.next = Some(b);
}
}

#[test]
#[should_fail]
fn test_begin_unwind() {
Expand Down
7 changes: 3 additions & 4 deletions src/test/auxiliary/cci_nested_lib.rs
Expand Up @@ -10,7 +10,6 @@


use std::cell::RefCell;
use std::gc::{Gc, GC};

pub struct Entry<A,B> {
key: A,
Expand All @@ -19,7 +18,7 @@ pub struct Entry<A,B> {

pub struct alist<A,B> {
eq_fn: extern "Rust" fn(A,A) -> bool,
data: Gc<RefCell<Vec<Entry<A,B>>>>,
data: Box<RefCell<Vec<Entry<A,B>>>>,
}

pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
Expand Down Expand Up @@ -47,7 +46,7 @@ pub fn new_int_alist<B:'static>() -> alist<int, B> {
fn eq_int(a: int, b: int) -> bool { a == b }
return alist {
eq_fn: eq_int,
data: box(GC) RefCell::new(Vec::new()),
data: box RefCell::new(Vec::new()),
};
}

Expand All @@ -57,6 +56,6 @@ pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
fn eq_int(a: int, b: int) -> bool { a == b }
return alist {
eq_fn: eq_int,
data: box(GC) RefCell::new(Vec::new()),
data: box RefCell::new(Vec::new()),
};
}
3 changes: 1 addition & 2 deletions src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs
Expand Up @@ -27,9 +27,8 @@ pub mod name_pool {

pub mod rust {
pub use name_pool::add;
use std::gc::Gc;

pub type rt = Gc<()>;
pub type rt = Box<()>;

pub trait cx {
fn cx(&self);
Expand Down
4 changes: 2 additions & 2 deletions src/test/auxiliary/issue-2631-a.rs
Expand Up @@ -13,9 +13,9 @@

use std::cell::RefCell;
use std::collections::HashMap;
use std::gc::Gc;
use std::rc::Rc;

pub type header_map = HashMap<String, Gc<RefCell<Vec<Gc<String>>>>>;
pub type header_map = HashMap<String, Rc<RefCell<Vec<Rc<String>>>>>;

// the unused ty param is necessary so this gets monomorphized
pub fn request<T>(req: &header_map) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/auxiliary/issue-5521.rs
Expand Up @@ -10,7 +10,6 @@


use std::collections::HashMap;
use std::gc::Gc;

pub type map = Gc<HashMap<uint, uint>>;
pub type map = Box<HashMap<uint, uint>>;

2 changes: 0 additions & 2 deletions src/test/auxiliary/issue13507.rs
Expand Up @@ -56,8 +56,6 @@ pub mod testtypes {
VarB(uint, uint)
}

// Skipping ty_box

// Tests ty_uniq (of u8)
pub type FooUniq = Box<u8>;

Expand Down
28 changes: 9 additions & 19 deletions src/test/bench/task-perf-alloc-unwind.rs
Expand Up @@ -10,18 +10,15 @@

#![feature(unsafe_destructor)]

extern crate collections;
extern crate time;

use time::precise_time_s;
use std::os;
use std::task;
use std::vec;
use std::gc::{Gc, GC};

#[deriving(Clone)]
enum List<T> {
Nil, Cons(T, Gc<List<T>>)
Nil, Cons(T, Box<List<T>>)
}

enum UniqueList {
Expand Down Expand Up @@ -53,23 +50,21 @@ type nillist = List<()>;
// Filled with things that have to be unwound

struct State {
managed: Gc<nillist>,
unique: Box<nillist>,
tuple: (Gc<nillist>, Box<nillist>),
vec: Vec<Gc<nillist>>,
vec: Vec<Box<nillist>>,
res: r
}

struct r {
_l: Gc<nillist>,
_l: Box<nillist>,
}

#[unsafe_destructor]
impl Drop for r {
fn drop(&mut self) {}
}

fn r(l: Gc<nillist>) -> r {
fn r(l: Box<nillist>) -> r {
r {
_l: l
}
Expand All @@ -85,22 +80,17 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
let st = match st {
None => {
State {
managed: box(GC) Nil,
unique: box Nil,
tuple: (box(GC) Nil, box Nil),
vec: vec!(box(GC) Nil),
res: r(box(GC) Nil)
vec: vec!(box Nil),
res: r(box Nil)
}
}
Some(st) => {
State {
managed: box(GC) Cons((), st.managed),
unique: box Cons((), box(GC) *st.unique),
tuple: (box(GC) Cons((), st.tuple.ref0().clone()),
box Cons((), box(GC) *st.tuple.ref1().clone())),
unique: box Cons((), box *st.unique),
vec: st.vec.clone().append(
&[box(GC) Cons((), *st.vec.last().unwrap())]),
res: r(box(GC) Cons((), st.res._l))
&[box Cons((), *st.vec.last().unwrap())]),
res: r(box Cons((), st.res._l))
}
}
};
Expand Down

0 comments on commit 58bea31

Please sign in to comment.