tidy
This commit is contained in:
parent
fe82374328
commit
394f8eeb7e
@ -121,21 +121,21 @@ pub impl Encoder: serialize::Encoder {
|
||||
fn emit_owned(&self, f: fn()) { f() }
|
||||
fn emit_managed(&self, f: fn()) { f() }
|
||||
|
||||
fn emit_enum(&self, name: &str, f: fn()) {
|
||||
fn emit_enum(&self, _name: &str, f: fn()) {
|
||||
f()
|
||||
}
|
||||
|
||||
fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) {
|
||||
|
||||
fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: fn()) {
|
||||
// emitting enums as arrays where the first
|
||||
// element provides the enum variant name
|
||||
self.wr.write_char('[');
|
||||
self.wr.write_str(escape_str(_name));
|
||||
self.wr.write_str(escape_str(name));
|
||||
self.wr.write_char(',');
|
||||
f();
|
||||
self.wr.write_char(']');
|
||||
}
|
||||
fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) {
|
||||
if _idx != 0 {self.wr.write_char(',');}
|
||||
fn emit_enum_variant_arg(&self, idx: uint, f: fn()) {
|
||||
if idx != 0 {self.wr.write_char(',');}
|
||||
f();
|
||||
}
|
||||
|
||||
|
@ -1160,8 +1160,7 @@ mod test {
|
||||
use core::io;
|
||||
use core::str;
|
||||
use std;
|
||||
|
||||
|
||||
|
||||
#[auto_decode]
|
||||
#[auto_encode]
|
||||
struct Node {id: uint}
|
||||
@ -1171,9 +1170,11 @@ mod test {
|
||||
val.encode(~std::json::Encoder(bw as io::Writer));
|
||||
str::from_bytes(bw.bytes.data)
|
||||
}
|
||||
|
||||
|
||||
#[test] fn encode_test () {
|
||||
check_equal (to_json_str(Node{id:34} as Encodable::<std::json::Encoder>),~"{\"id\":34}");
|
||||
check_equal (to_json_str(Node{id:34}
|
||||
as Encodable::<std::json::Encoder>),
|
||||
~"{\"id\":34}");
|
||||
}
|
||||
|
||||
#[auto_encode]
|
||||
@ -1185,7 +1186,8 @@ mod test {
|
||||
#[test] fn json_enum_encode_test () {
|
||||
check_equal (to_json_str(Book(9) as Encodable::<std::json::Encoder>),
|
||||
~"[\"Book\",9]");
|
||||
check_equal (to_json_str(Magazine(~"Paris Match") as Encodable::<std::json::Encoder>),
|
||||
check_equal (to_json_str(Magazine(~"Paris Match")
|
||||
as Encodable::<std::json::Encoder>),
|
||||
~"[\"Magazine\",\"Paris Match\"]");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user