Skip to content

Update and un-xfail auto-encode test #11000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 16, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 34 additions & 42 deletions src/test/run-pass/auto-encode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// xfail-fast

// 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.
//
Expand All @@ -10,14 +10,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// xfail-test #6122
#[feature(managed_boxes)];

extern mod extra;

// These tests used to be separate files, but I wanted to refactor all
// the common code.

use std::hashmap::{HashMap, HashSet};
use std::io::Decorator;

use EBReader = extra::ebml::reader;
use EBWriter = extra::ebml::writer;
Expand All @@ -32,17 +33,14 @@ fn test_ebml<A:
Encodable<EBWriter::Encoder> +
Decodable<EBReader::Decoder>
>(a1: &A) {
let bytes = do io::with_bytes_writer |wr| {
let mut ebml_w = EBWriter::Encoder(wr);
a1.encode(&mut ebml_w)
};
let mut wr = @mut std::io::mem::MemWriter::new();
let mut ebml_w = EBWriter::Encoder(wr);
a1.encode(&mut ebml_w);
let bytes = wr.inner_ref().to_owned();

let d = EBReader::Doc(@bytes);
let mut decoder = EBReader::Decoder(d);
let a2: A = Decodable::decode(&mut decoder);
if !(*a1 == a2) {
::std::sys::FailWithCause::fail_with(~"explicit failure" + "foo",
"auto-encode.rs", 43u);
}
assert!(*a1 == a2);
}

Expand Down Expand Up @@ -139,47 +137,41 @@ pub fn main() {
let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
test_ebml(a);

// let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
// test_ebml(a);
let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
test_ebml(a);

// let a = &Point {x: 3u, y: 5u};
// test_ebml(a);
//
// let a = &@[1u, 2u, 3u];
// test_ebml(a);
//
// let a = &Top(22u);
// test_ebml(a);
//
// let a = &Bottom(222u);
// test_ebml(a);
//
// let a = &A;
// test_ebml(a);
//
// let a = &B;
// test_ebml(a);
let a = &Point {x: 3u, y: 5u};
test_ebml(a);

let a = &@[1u, 2u, 3u];
test_ebml(a);

let a = &Top(22u);
test_ebml(a);

let a = &Bottom(222u);
test_ebml(a);

let a = &A;
test_ebml(a);

let a = &B;
test_ebml(a);

println("Hi1");
let a = &time::now();
test_ebml(a);

println("Hi2");
// test_ebml(&1.0f32);
// test_ebml(&1.0f64);
test_ebml(&1.0f);
// println("Hi3");
// test_ebml(&'a');
test_ebml(&1.0f32);
test_ebml(&1.0f64);
test_ebml(&'a');

println("Hi4");
let mut a = HashMap::new();
test_ebml(&a);
a.insert(1, 2);
println("Hi4");
test_ebml(&a);

// let mut a = HashSet::new();
// test_ebml(&a);
// a.insert(1);
// test_ebml(&a);
let mut a = HashSet::new();
test_ebml(&a);
a.insert(1);
test_ebml(&a);
}