Finish compare glue for classes
This tests == and !=. I don't know what <, >, etc. should do. Closes #2601
This commit is contained in:
parent
95feaee353
commit
25b8b35c57
@ -356,7 +356,7 @@ cmp::walk_struct2(const uint8_t *end_sp) {
|
||||
|
||||
void
|
||||
cmp::walk_res2(const rust_fn *dtor, const uint8_t *end_sp) {
|
||||
abort(); // TODO
|
||||
return cmp_two_pointers();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -334,7 +334,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] {
|
||||
let mut s = if option::is_some(m_dtor_did) {
|
||||
[shape_res]
|
||||
}
|
||||
else { [shape_struct] };
|
||||
else { [shape_struct] }, sub = [];
|
||||
option::iter(m_dtor_did) {|dtor_did|
|
||||
let ri = @{did: dtor_did, parent_id: some(did), tps: tps};
|
||||
let id = interner::intern(ccx.shape_cx.resources, ri);
|
||||
@ -345,8 +345,9 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> [u8] {
|
||||
add_u16(s, 0_u16);
|
||||
};
|
||||
for ty::class_items_as_mutable_fields(ccx.tcx, did, substs).each {|f|
|
||||
add_substr(s, shape_of(ccx, f.mt.ty));
|
||||
sub += shape_of(ccx, f.mt.ty);
|
||||
}
|
||||
add_substr(s, sub);
|
||||
s
|
||||
}
|
||||
ty::ty_rptr(_, mt) {
|
||||
|
@ -60,14 +60,11 @@ fn test_box() {
|
||||
}
|
||||
|
||||
fn test_port() {
|
||||
// FIXME: Re-enable this once we can compare resources. (#2601)
|
||||
/*
|
||||
let p1 = comm::port::<int>();
|
||||
let p2 = comm::port::<int>();
|
||||
|
||||
assert (p1 == p1);
|
||||
assert (p1 != p2);
|
||||
*/
|
||||
}
|
||||
|
||||
fn test_chan() {
|
||||
@ -98,7 +95,7 @@ fn test_ptr() unsafe {
|
||||
fn test_fn() {
|
||||
fn f() { }
|
||||
fn g() { }
|
||||
fn h(i: int) { }
|
||||
fn h(_i: int) { }
|
||||
let f1 = f;
|
||||
let f2 = f;
|
||||
let g1 = g;
|
||||
@ -128,6 +125,28 @@ fn test_native_fn() {
|
||||
assert test::unsupervise == test::unsupervise;
|
||||
}
|
||||
|
||||
class p {
|
||||
let mut x: int;
|
||||
let mut y: int;
|
||||
new(x: int, y: int) { self.x = x; self.y = y; }
|
||||
}
|
||||
|
||||
fn test_class() {
|
||||
let q = p(1, 2);
|
||||
let r = p(1, 2);
|
||||
|
||||
unsafe {
|
||||
#error("q = %x, r = %x",
|
||||
(unsafe::reinterpret_cast::<*p, uint>(ptr::addr_of(q))),
|
||||
(unsafe::reinterpret_cast::<*p, uint>(ptr::addr_of(r))));
|
||||
}
|
||||
assert(q == r);
|
||||
r.y = 17;
|
||||
assert(r.y != q.y);
|
||||
assert(r.y == 17);
|
||||
assert(q != r);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_nil();
|
||||
test_bool();
|
||||
@ -138,4 +157,5 @@ fn main() {
|
||||
test_ptr();
|
||||
test_fn();
|
||||
test_native_fn();
|
||||
test_class();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user