update to rust HEAD, fix the tests
This commit is contained in:
parent
ed6d64ad6d
commit
246396fdb4
@ -2,6 +2,7 @@
|
|||||||
name = "serde"
|
name = "serde"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||||
|
license = "MIT/Apache-2.0"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
|
@ -35,7 +35,7 @@ struct Http {
|
|||||||
request_uri: String,
|
request_uri: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Show, PartialEq, FromPrimitive)]
|
#[deriving(Copy, Show, PartialEq, FromPrimitive)]
|
||||||
enum HttpProtocol {
|
enum HttpProtocol {
|
||||||
HTTP_PROTOCOL_UNKNOWN,
|
HTTP_PROTOCOL_UNKNOWN,
|
||||||
HTTP10,
|
HTTP10,
|
||||||
@ -71,7 +71,7 @@ impl<D: de::Deserializer<E>, E> de::Deserialize<D, E> for HttpProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Show, PartialEq, FromPrimitive)]
|
#[deriving(Copy, Show, PartialEq, FromPrimitive)]
|
||||||
enum HttpMethod {
|
enum HttpMethod {
|
||||||
METHOD_UNKNOWN,
|
METHOD_UNKNOWN,
|
||||||
GET,
|
GET,
|
||||||
@ -115,7 +115,7 @@ impl<D: de::Deserializer<E>, E> de::Deserialize<D, E> for HttpMethod {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Show, PartialEq, FromPrimitive)]
|
#[deriving(Copy, Show, PartialEq, FromPrimitive)]
|
||||||
enum CacheStatus {
|
enum CacheStatus {
|
||||||
CACHESTATUS_UNKNOWN,
|
CACHESTATUS_UNKNOWN,
|
||||||
Miss,
|
Miss,
|
||||||
@ -162,7 +162,7 @@ struct Origin {
|
|||||||
protocol: OriginProtocol,
|
protocol: OriginProtocol,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Show, PartialEq, FromPrimitive)]
|
#[deriving(Copy, Show, PartialEq, FromPrimitive)]
|
||||||
enum OriginProtocol {
|
enum OriginProtocol {
|
||||||
ORIGIN_PROTOCOL_UNKNOWN,
|
ORIGIN_PROTOCOL_UNKNOWN,
|
||||||
HTTP,
|
HTTP,
|
||||||
@ -198,7 +198,7 @@ impl<D: de::Deserializer<E>, E> de::Deserialize<D, E> for OriginProtocol {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Show, PartialEq, FromPrimitive)]
|
#[deriving(Copy, Show, PartialEq, FromPrimitive)]
|
||||||
enum ZonePlan {
|
enum ZonePlan {
|
||||||
ZONEPLAN_UNKNOWN,
|
ZONEPLAN_UNKNOWN,
|
||||||
FREE,
|
FREE,
|
||||||
@ -236,7 +236,7 @@ impl<D: de::Deserializer<E>, E> de::Deserialize<D, E> for ZonePlan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Show, PartialEq, FromPrimitive)]
|
#[deriving(Copy, Show, PartialEq, FromPrimitive)]
|
||||||
enum Country {
|
enum Country {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
A1,
|
A1,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
name = "serde_macros"
|
name = "serde_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||||
|
license = "MIT/Apache-2.0"
|
||||||
|
|
||||||
[[lib]]
|
[[lib]]
|
||||||
name = "serde_macros"
|
name = "serde_macros"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#![crate_name = "serde_macros"]
|
#![crate_name = "serde_macros"]
|
||||||
#![crate_type = "dylib"]
|
#![crate_type = "dylib"]
|
||||||
#![license = "MIT/ASL2"]
|
|
||||||
|
|
||||||
#![feature(plugin_registrar, quote)]
|
#![feature(plugin_registrar, quote)]
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ impl Token {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq, Eq)]
|
#[deriving(Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum TokenKind {
|
pub enum TokenKind {
|
||||||
NullKind,
|
NullKind,
|
||||||
BoolKind,
|
BoolKind,
|
||||||
@ -854,6 +854,7 @@ impl_deserialize_tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
|
|||||||
|
|
||||||
/// Helper struct that will ignore tokens while taking in consideration
|
/// Helper struct that will ignore tokens while taking in consideration
|
||||||
/// recursive structures.
|
/// recursive structures.
|
||||||
|
#[deriving(Copy)]
|
||||||
pub struct IgnoreTokens;
|
pub struct IgnoreTokens;
|
||||||
|
|
||||||
impl<D: Deserializer<E>, E> Deserialize<D, E> for IgnoreTokens {
|
impl<D: Deserializer<E>, E> Deserialize<D, E> for IgnoreTokens {
|
||||||
|
@ -371,14 +371,14 @@ mod tests {
|
|||||||
Animal::Dog => {
|
Animal::Dog => {
|
||||||
Value::Object(
|
Value::Object(
|
||||||
treemap!(
|
treemap!(
|
||||||
"Dog".to_string() => Value::List(vec!())
|
"Dog".to_string() => Value::Array(vec!())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Animal::Frog(ref x0, ref x1) => {
|
Animal::Frog(ref x0, ref x1) => {
|
||||||
Value::Object(
|
Value::Object(
|
||||||
treemap!(
|
treemap!(
|
||||||
"Frog".to_string() => Value::List(vec!(x0.to_json(), x1.to_json()))
|
"Frog".to_string() => Value::Array(vec!(x0.to_json(), x1.to_json()))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -533,19 +533,19 @@ mod tests {
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let long_test_list = Value::List(vec![
|
let long_test_list = Value::Array(vec![
|
||||||
Value::Boolean(false),
|
Value::Boolean(false),
|
||||||
Value::Null,
|
Value::Null,
|
||||||
Value::List(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]);
|
Value::Array(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]);
|
||||||
|
|
||||||
test_encode_ok(&[
|
test_encode_ok(&[
|
||||||
(long_test_list, "[false,null,[\"foo\\nbar\",3.5]]"),
|
(long_test_list, "[false,null,[\"foo\\nbar\",3.5]]"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let long_test_list = Value::List(vec![
|
let long_test_list = Value::Array(vec![
|
||||||
Value::Boolean(false),
|
Value::Boolean(false),
|
||||||
Value::Null,
|
Value::Null,
|
||||||
Value::List(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]);
|
Value::Array(vec![Value::String("foo\nbar".to_string()), Value::Floating(3.5)])]);
|
||||||
|
|
||||||
test_pretty_encode_ok(&[
|
test_pretty_encode_ok(&[
|
||||||
(
|
(
|
||||||
@ -602,7 +602,7 @@ mod tests {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
let complex_obj = Value::Object(treemap!(
|
let complex_obj = Value::Object(treemap!(
|
||||||
"b".to_string() => Value::List(vec!(
|
"b".to_string() => Value::Array(vec!(
|
||||||
Value::Object(treemap!("c".to_string() => Value::String("\x0c\r".to_string()))),
|
Value::Object(treemap!("c".to_string() => Value::String("\x0c\r".to_string()))),
|
||||||
Value::Object(treemap!("d".to_string() => Value::String("".to_string())))
|
Value::Object(treemap!("d".to_string() => Value::String("".to_string())))
|
||||||
))
|
))
|
||||||
@ -920,8 +920,8 @@ mod tests {
|
|||||||
("\"\\n\"", "\n".to_string()),
|
("\"\\n\"", "\n".to_string()),
|
||||||
("\"\\r\"", "\r".to_string()),
|
("\"\\r\"", "\r".to_string()),
|
||||||
("\"\\t\"", "\t".to_string()),
|
("\"\\t\"", "\t".to_string()),
|
||||||
("\"\\u12ab\"", "\u12ab".to_string()),
|
("\"\\u12ab\"", "\u{12ab}".to_string()),
|
||||||
("\"\\uAB12\"", "\uAB12".to_string()),
|
("\"\\uAB12\"", "\u{AB12}".to_string()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,8 +935,8 @@ mod tests {
|
|||||||
"\n".to_string(),
|
"\n".to_string(),
|
||||||
"\r".to_string(),
|
"\r".to_string(),
|
||||||
"\t".to_string(),
|
"\t".to_string(),
|
||||||
"\u12ab".to_string(),
|
"\u{12ab}".to_string(),
|
||||||
"\uAB12".to_string(),
|
"\u{AB12}".to_string(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1272,15 +1272,15 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_is_list() {
|
fn test_is_array() {
|
||||||
let json_value: Value = from_str("[1, 2, 3]").unwrap();
|
let json_value: Value = from_str("[1, 2, 3]").unwrap();
|
||||||
assert!(json_value.is_list());
|
assert!(json_value.is_array());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_as_list() {
|
fn test_as_array() {
|
||||||
let json_value: Value = from_str("[1, 2, 3]").unwrap();
|
let json_value: Value = from_str("[1, 2, 3]").unwrap();
|
||||||
let json_list = json_value.as_list();
|
let json_list = json_value.as_array();
|
||||||
let expected_length = 3;
|
let expected_length = 3;
|
||||||
assert!(json_list.is_some() && json_list.unwrap().len() == expected_length);
|
assert!(json_list.is_some() && json_list.unwrap().len() == expected_length);
|
||||||
}
|
}
|
||||||
@ -1776,7 +1776,7 @@ mod bench {
|
|||||||
"b".to_string() => Value::Null,
|
"b".to_string() => Value::Null,
|
||||||
"c".to_string() => Value::Floating(3.1415),
|
"c".to_string() => Value::Floating(3.1415),
|
||||||
"d".to_string() => Value::String("Hello world".to_string()),
|
"d".to_string() => Value::String("Hello world".to_string()),
|
||||||
"e".to_string() => Value::List(vec!(
|
"e".to_string() => Value::Array(vec!(
|
||||||
Value::Integer(1),
|
Value::Integer(1),
|
||||||
Value::Integer(2),
|
Value::Integer(2),
|
||||||
Value::Integer(3)
|
Value::Integer(3)
|
||||||
@ -1784,7 +1784,7 @@ mod bench {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
list.push(Value::Object(TreeMap::new()));
|
list.push(Value::Object(TreeMap::new()));
|
||||||
Value::List(list)
|
Value::Array(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bench_encoder(b: &mut Bencher, count: uint) {
|
fn bench_encoder(b: &mut Bencher, count: uint) {
|
||||||
|
@ -3,7 +3,6 @@ use std::fmt;
|
|||||||
use std::io::{ByRefWriter, IoResult};
|
use std::io::{ByRefWriter, IoResult};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::string;
|
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
use de::{mod, Token, TokenKind};
|
use de::{mod, Token, TokenKind};
|
||||||
|
Loading…
Reference in New Issue
Block a user