Skip to content

Commit 63d9232

Browse files
committed
---
yaml --- r: 14835 b: refs/heads/try c: 9086c6f h: refs/heads/master i: 14833: 6f1aa9d 14831: 2012b5e v: v3
1 parent 10b1231 commit 63d9232

File tree

8 files changed

+99
-152
lines changed

8 files changed

+99
-152
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: b30cb8e43a57f8f16065c37a664b26db0891f134
5+
refs/heads/try: 9086c6f5a2ac3e09c358d05700bfbcb18378bdf6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/test/auxiliary/auto_serialize_lib.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
use std;
2+
3+
// These tests used to be separate files, but I wanted to refactor all
4+
// the common code.
5+
6+
import std::ebml;
7+
import io::writer;
8+
import std::prettyprint::serializer;
9+
import std::ebml::serializer;
10+
import std::ebml::deserializer;
11+
12+
fn test_ser_and_deser<A>(a1: A,
13+
expected: str,
14+
ebml_ser_fn: fn(ebml::writer, A),
15+
ebml_deser_fn: fn(ebml::ebml_deserializer) -> A,
16+
io_ser_fn: fn(io::writer, A)) {
17+
18+
// check the pretty printer:
19+
io_ser_fn(io::stdout(), a1);
20+
let s = io::with_str_writer {|w| io_ser_fn(w, a1) };
21+
#debug["s == %?", s];
22+
assert s == expected;
23+
24+
// check the EBML serializer:
25+
let buf = io::mem_buffer();
26+
let w = ebml::writer(buf as io::writer);
27+
ebml_ser_fn(w, a1);
28+
let d = ebml::new_doc(@io::mem_buffer_buf(buf));
29+
let a2 = ebml_deser_fn(ebml::ebml_deserializer(d));
30+
io::print("\na1 = ");
31+
io_ser_fn(io::stdout(), a1);
32+
io::print("\na2 = ");
33+
io_ser_fn(io::stdout(), a2);
34+
io::print("\n");
35+
assert a1 == a2;
36+
37+
}
38+
39+
#[auto_serialize]
40+
enum expr {
41+
val(uint),
42+
plus(@expr, @expr),
43+
minus(@expr, @expr)
44+
}
45+
46+
47+
#[auto_serialize]
48+
type spanned<T> = {lo: uint, hi: uint, node: T};
49+
50+
#[auto_serialize]
51+
type spanned_uint = spanned<uint>;
52+
53+
#[auto_serialize]
54+
type some_rec = {v: uint_vec};
55+
56+
#[auto_serialize]
57+
enum an_enum = some_rec;
58+
59+
#[auto_serialize]
60+
type uint_vec = [uint];
61+
62+
#[auto_serialize]
63+
type point = {x: uint, y: uint};
64+
65+
fn main() {
66+
67+
test_ser_and_deser(plus(@minus(@val(3u), @val(10u)),
68+
@plus(@val(22u), @val(5u))),
69+
"plus(@minus(@val(3u), @val(10u)), \
70+
@plus(@val(22u), @val(5u)))",
71+
expr::serialize(_, _),
72+
expr::deserialize(_),
73+
expr::serialize(_, _));
74+
75+
test_ser_and_deser({lo: 0u, hi: 5u, node: 22u},
76+
"{lo: 0u, hi: 5u, node: 22u}",
77+
spanned_uint::serialize(_, _),
78+
spanned_uint::deserialize(_),
79+
spanned_uint::serialize(_, _));
80+
81+
test_ser_and_deser(an_enum({v: [1u, 2u, 3u]}),
82+
"an_enum({v: [1u, 2u, 3u]})",
83+
an_enum::serialize(_, _),
84+
an_enum::deserialize(_),
85+
an_enum::serialize(_, _));
86+
87+
test_ser_and_deser({x: 3u, y: 5u},
88+
"{x: 3u, y: 5u}",
89+
point::serialize(_, _),
90+
point::deserialize(_),
91+
point::serialize(_, _));
92+
93+
test_ser_and_deser([1u, 2u, 3u],
94+
"[1u, 2u, 3u]",
95+
uint_vec::serialize(_, _),
96+
uint_vec::deserialize(_),
97+
uint_vec::serialize(_, _));
98+
}

branches/try/src/test/run-pass/auto_serialize_enum.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

branches/try/src/test/run-pass/auto_serialize_gen.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

branches/try/src/test/run-pass/auto_serialize_link.rs

Lines changed: 0 additions & 28 deletions
This file was deleted.

branches/try/src/test/run-pass/auto_serialize_rec.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

branches/try/src/test/run-pass/auto_serialize_vec.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)