diff options
| author | bors <bors@rust-lang.org> | 2013-05-02 20:39:36 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-02 20:39:36 -0700 |
| commit | b37a685958a99ae37eef4e8bf7e8498ea7b698c1 (patch) | |
| tree | 0500311b3c436c860a5fe622a9b8e171963d2e07 /src/test | |
| parent | baa1c1834f608c8c789db6d2495626ff9d28dd96 (diff) | |
| parent | dc5df61bc1914224d50d92cdd5599b6337ac68f2 (diff) | |
auto merge of #6201 : pcwalton/rust/inhtwama-serializer, r=graydon
This PR removes mutable fields from the serializer and makes the encoder and decoder use INHTWAMA properly (i.e. `&mut self`). r? @graydon
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/bench/shootout-binarytrees.rs | 23 | ||||
| -rw-r--r-- | src/test/run-pass/auto-encode.rs | 7 | ||||
| -rw-r--r-- | src/test/run-pass/issue-4036.rs | 3 | ||||
| -rw-r--r-- | src/test/run-pass/placement-new-arena.rs | 3 | ||||
| -rw-r--r-- | src/test/run-pass/regions-mock-trans-impls.rs | 28 |
5 files changed, 36 insertions, 28 deletions
diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 8d0675d0884..c420e0cbb2f 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -1,3 +1,7 @@ +// xfail-test + +// Broken due to arena API problems. + // 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. @@ -10,7 +14,6 @@ extern mod std; use std::arena; -use methods = std::arena::Arena; enum tree<'self> { nil, @@ -26,9 +29,7 @@ fn item_check(t: &tree) -> int { } } -fn bottom_up_tree<'r>(arena: &'r arena::Arena, - item: int, - depth: int) +fn bottom_up_tree<'r>(arena: &'r mut arena::Arena, item: int, depth: int) -> &'r tree<'r> { if depth > 0 { return arena.alloc( @@ -58,25 +59,25 @@ fn main() { max_depth = n; } - let stretch_arena = arena::Arena(); + let mut stretch_arena = arena::Arena(); let stretch_depth = max_depth + 1; - let stretch_tree = bottom_up_tree(&stretch_arena, 0, stretch_depth); + let stretch_tree = bottom_up_tree(&mut stretch_arena, 0, stretch_depth); io::println(fmt!("stretch tree of depth %d\t check: %d", stretch_depth, item_check(stretch_tree))); - let long_lived_arena = arena::Arena(); - let long_lived_tree = bottom_up_tree(&long_lived_arena, 0, max_depth); + let mut long_lived_arena = arena::Arena(); + let long_lived_tree = bottom_up_tree(&mut long_lived_arena, 0, max_depth); let mut depth = min_depth; while depth <= max_depth { let iterations = int::pow(2, (max_depth - depth + min_depth) as uint); let mut chk = 0; let mut i = 1; while i <= iterations { - let mut temp_tree = bottom_up_tree(&long_lived_arena, i, depth); + let mut temp_tree = bottom_up_tree(&mut long_lived_arena, i, depth); chk += item_check(temp_tree); - temp_tree = bottom_up_tree(&long_lived_arena, -i, depth); + temp_tree = bottom_up_tree(&mut long_lived_arena, -i, depth); chk += item_check(temp_tree); i += 1; } @@ -87,5 +88,5 @@ fn main() { } io::println(fmt!("long lived trees of depth %d\t check: %d", max_depth, - item_check(long_lived_tree))); + item_check(long_lived_tree))); } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index bfc15acaa76..cfac8e8cd06 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -31,11 +31,12 @@ fn test_ebml<A: Decodable<EBReader::Decoder> >(a1: &A) { let bytes = do io::with_bytes_writer |wr| { - let ebml_w = &EBWriter::Encoder(wr); - a1.encode(ebml_w) + let mut ebml_w = EBWriter::Encoder(wr); + a1.encode(&mut ebml_w) }; let d = EBReader::Doc(@bytes); - let a2: A = Decodable::decode(&EBReader::Decoder(d)); + let mut decoder = EBReader::Decoder(d); + let a2: A = Decodable::decode(&mut decoder); assert!(*a1 == a2); } diff --git a/src/test/run-pass/issue-4036.rs b/src/test/run-pass/issue-4036.rs index f24875cbf8e..8b514b11625 100644 --- a/src/test/run-pass/issue-4036.rs +++ b/src/test/run-pass/issue-4036.rs @@ -17,5 +17,6 @@ use self::std::serialize; pub fn main() { let json = json::from_str("[1]").unwrap(); - let _x: ~[int] = serialize::Decodable::decode(&json::Decoder(json)); + let mut decoder = json::Decoder(json); + let _x: ~[int] = serialize::Decodable::decode(&mut decoder); } diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 12c80421932..166435cbc3d 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -14,7 +14,8 @@ extern mod std; use std::arena; pub fn main() { - let p = &arena::Arena(); + let mut arena = arena::Arena(); + let p = &mut arena; let x = p.alloc(|| 4u); io::print(fmt!("%u", *x)); assert!(*x == 4u); diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index c1f7a713ca6..e9163505748 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -21,7 +21,7 @@ struct Bcx<'self> { } struct Fcx<'self> { - arena: &'self Arena, + arena: &'self mut Arena, ccx: &'self Ccx } @@ -29,23 +29,27 @@ struct Ccx { x: int } -fn h<'r>(bcx : &'r Bcx<'r>) -> &'r Bcx<'r> { - return bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx }); +fn h<'r>(bcx : &'r mut Bcx<'r>) -> &'r mut Bcx<'r> { + // XXX: Arena has a bad interface here; it should return mutable pointers. + // But this patch is too big to roll that in. + unsafe { + cast::transmute(bcx.fcx.arena.alloc(|| Bcx { fcx: bcx.fcx })) + } } -fn g(fcx : &Fcx) { - let bcx = Bcx { fcx: fcx }; - h(&bcx); +fn g(fcx: &mut Fcx) { + let mut bcx = Bcx { fcx: fcx }; + h(&mut bcx); } -fn f(ccx : &Ccx) { - let a = Arena(); - let fcx = &Fcx { arena: &a, ccx: ccx }; - return g(fcx); +fn f(ccx: &mut Ccx) { + let mut a = Arena(); + let mut fcx = Fcx { arena: &mut a, ccx: ccx }; + return g(&mut fcx); } pub fn main() { - let ccx = Ccx { x: 0 }; - f(&ccx); + let mut ccx = Ccx { x: 0 }; + f(&mut ccx); } |
