aboutsummaryrefslogtreecommitdiff
path: root/test-suite/tests/valid.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test-suite/tests/valid.rs')
-rw-r--r--test-suite/tests/valid.rs196
1 files changed, 98 insertions, 98 deletions
diff --git a/test-suite/tests/valid.rs b/test-suite/tests/valid.rs
index 0745cc8..ddbaf1b 100644
--- a/test-suite/tests/valid.rs
+++ b/test-suite/tests/valid.rs
@@ -1,12 +1,12 @@
extern crate serde;
extern crate serde_json;
-extern crate toml;
+extern crate milf;
use serde::ser::Serialize;
use serde_json::Value as Json;
-use toml::{to_string_pretty, Value as Toml};
+use milf::{to_string_pretty, Value as Milf};
-fn to_json(toml: toml::Value) -> Json {
+fn to_json(milf: milf::Value) -> Json {
fn doit(s: &str, json: Json) -> Json {
let mut map = serde_json::Map::new();
map.insert("type".to_string(), Json::String(s.to_string()));
@@ -14,10 +14,10 @@ fn to_json(toml: toml::Value) -> Json {
Json::Object(map)
}
- match toml {
- Toml::String(s) => doit("string", Json::String(s)),
- Toml::Integer(i) => doit("integer", Json::String(i.to_string())),
- Toml::Float(f) => doit(
+ match milf {
+ Milf::String(s) => doit("string", Json::String(s)),
+ Milf::Integer(i) => doit("integer", Json::String(i.to_string())),
+ Milf::Float(f) => doit(
"float",
Json::String({
let s = format!("{:.15}", f);
@@ -29,11 +29,11 @@ fn to_json(toml: toml::Value) -> Json {
}
}),
),
- Toml::Boolean(b) => doit("bool", Json::String(format!("{}", b))),
- Toml::Datetime(s) => doit("datetime", Json::String(s.to_string())),
- Toml::Array(arr) => {
+ Milf::Boolean(b) => doit("bool", Json::String(format!("{}", b))),
+ Milf::Datetime(s) => doit("datetime", Json::String(s.to_string())),
+ Milf::Array(arr) => {
let is_table = match arr.first() {
- Some(&Toml::Table(..)) => true,
+ Some(&Milf::Table(..)) => true,
_ => false,
};
let json = Json::Array(arr.into_iter().map(to_json).collect());
@@ -43,7 +43,7 @@ fn to_json(toml: toml::Value) -> Json {
doit("array", json)
}
}
- Toml::Table(table) => {
+ Milf::Table(table) => {
let mut map = serde_json::Map::new();
for (k, v) in table {
map.insert(k, to_json(v));
@@ -53,345 +53,345 @@ fn to_json(toml: toml::Value) -> Json {
}
}
-fn run_pretty(toml: Toml) {
- // Assert toml == json
+fn run_pretty(milf: Milf) {
+ // Assert milf == json
println!("### pretty round trip parse.");
// standard pretty
- let toml_raw = to_string_pretty(&toml).expect("to string");
- let toml2 = toml_raw.parse().expect("from string");
- assert_eq!(toml, toml2);
+ let milf_raw = to_string_pretty(&milf).expect("to string");
+ let milf2 = milf_raw.parse().expect("from string");
+ assert_eq!(milf, milf2);
// pretty with indent 2
let mut result = String::with_capacity(128);
{
- let mut serializer = toml::Serializer::pretty(&mut result);
+ let mut serializer = milf::Serializer::pretty(&mut result);
serializer.pretty_array_indent(2);
- toml.serialize(&mut serializer).expect("to string");
+ milf.serialize(&mut serializer).expect("to string");
}
- assert_eq!(toml, result.parse().expect("from str"));
+ assert_eq!(milf, result.parse().expect("from str"));
result.clear();
{
- let mut serializer = toml::Serializer::new(&mut result);
+ let mut serializer = milf::Serializer::new(&mut result);
serializer.pretty_array_trailing_comma(false);
- toml.serialize(&mut serializer).expect("to string");
+ milf.serialize(&mut serializer).expect("to string");
}
- assert_eq!(toml, result.parse().expect("from str"));
+ assert_eq!(milf, result.parse().expect("from str"));
result.clear();
{
- let mut serializer = toml::Serializer::pretty(&mut result);
+ let mut serializer = milf::Serializer::pretty(&mut result);
serializer.pretty_string(false);
- toml.serialize(&mut serializer).expect("to string");
- assert_eq!(toml, toml2);
+ milf.serialize(&mut serializer).expect("to string");
+ assert_eq!(milf, milf2);
}
- assert_eq!(toml, result.parse().expect("from str"));
+ assert_eq!(milf, result.parse().expect("from str"));
result.clear();
{
- let mut serializer = toml::Serializer::pretty(&mut result);
+ let mut serializer = milf::Serializer::pretty(&mut result);
serializer.pretty_array(false);
- toml.serialize(&mut serializer).expect("to string");
- assert_eq!(toml, toml2);
+ milf.serialize(&mut serializer).expect("to string");
+ assert_eq!(milf, milf2);
}
- assert_eq!(toml, result.parse().expect("from str"));
+ assert_eq!(milf, result.parse().expect("from str"));
}
-fn run(toml_raw: &str, json_raw: &str) {
- println!("parsing:\n{}", toml_raw);
- let toml: Toml = toml_raw.parse().unwrap();
+fn run(milf_raw: &str, json_raw: &str) {
+ println!("parsing:\n{}", milf_raw);
+ let milf: Milf = milf_raw.parse().unwrap();
let json: Json = json_raw.parse().unwrap();
- // Assert toml == json
- let toml_json = to_json(toml.clone());
+ // Assert milf == json
+ let milf_json = to_json(milf.clone());
assert!(
- json == toml_json,
+ json == milf_json,
"expected\n{}\ngot\n{}\n",
serde_json::to_string_pretty(&json).unwrap(),
- serde_json::to_string_pretty(&toml_json).unwrap()
+ serde_json::to_string_pretty(&milf_json).unwrap()
);
// Assert round trip
- println!("round trip parse: {}", toml);
- let toml2 = toml.to_string().parse().unwrap();
- assert_eq!(toml, toml2);
- run_pretty(toml);
+ println!("round trip parse: {}", milf);
+ let milf2 = milf.to_string().parse().unwrap();
+ assert_eq!(milf, milf2);
+ run_pretty(milf);
}
-macro_rules! test( ($name:ident, $toml:expr, $json:expr) => (
+macro_rules! test( ($name:ident, $milf:expr, $json:expr) => (
#[test]
- fn $name() { run($toml, $json); }
+ fn $name() { run($milf, $json); }
) );
test!(
array_empty,
- include_str!("valid/array-empty.toml"),
+ include_str!("valid/array-empty.milf"),
include_str!("valid/array-empty.json")
);
test!(
array_nospaces,
- include_str!("valid/array-nospaces.toml"),
+ include_str!("valid/array-nospaces.milf"),
include_str!("valid/array-nospaces.json")
);
test!(
arrays_hetergeneous,
- include_str!("valid/arrays-hetergeneous.toml"),
+ include_str!("valid/arrays-hetergeneous.milf"),
include_str!("valid/arrays-hetergeneous.json")
);
test!(
arrays,
- include_str!("valid/arrays.toml"),
+ include_str!("valid/arrays.milf"),
include_str!("valid/arrays.json")
);
test!(
arrays_nested,
- include_str!("valid/arrays-nested.toml"),
+ include_str!("valid/arrays-nested.milf"),
include_str!("valid/arrays-nested.json")
);
test!(
array_mixed_types_ints_and_floats,
- include_str!("valid/array-mixed-types-ints-and-floats.toml"),
+ include_str!("valid/array-mixed-types-ints-and-floats.milf"),
include_str!("valid/array-mixed-types-ints-and-floats.json")
);
test!(
array_mixed_types_arrays_and_ints,
- include_str!("valid/array-mixed-types-arrays-and-ints.toml"),
+ include_str!("valid/array-mixed-types-arrays-and-ints.milf"),
include_str!("valid/array-mixed-types-arrays-and-ints.json")
);
test!(
array_mixed_types_strings_and_ints,
- include_str!("valid/array-mixed-types-strings-and-ints.toml"),
+ include_str!("valid/array-mixed-types-strings-and-ints.milf"),
include_str!("valid/array-mixed-types-strings-and-ints.json")
);
test!(
empty,
- include_str!("valid/empty.toml"),
+ include_str!("valid/empty.milf"),
include_str!("valid/empty.json")
);
test!(
bool,
- include_str!("valid/bool.toml"),
+ include_str!("valid/bool.milf"),
include_str!("valid/bool.json")
);
test!(
comments_everywhere,
- include_str!("valid/comments-everywhere.toml"),
+ include_str!("valid/comments-everywhere.milf"),
include_str!("valid/comments-everywhere.json")
);
test!(
datetime,
- include_str!("valid/datetime.toml"),
+ include_str!("valid/datetime.milf"),
include_str!("valid/datetime.json")
);
test!(
example,
- include_str!("valid/example.toml"),
+ include_str!("valid/example.milf"),
include_str!("valid/example.json")
);
test!(
float,
- include_str!("valid/float.toml"),
+ include_str!("valid/float.milf"),
include_str!("valid/float.json")
);
test!(
implicit_and_explicit_after,
- include_str!("valid/implicit-and-explicit-after.toml"),
+ include_str!("valid/implicit-and-explicit-after.milf"),
include_str!("valid/implicit-and-explicit-after.json")
);
test!(
implicit_and_explicit_before,
- include_str!("valid/implicit-and-explicit-before.toml"),
+ include_str!("valid/implicit-and-explicit-before.milf"),
include_str!("valid/implicit-and-explicit-before.json")
);
test!(
implicit_groups,
- include_str!("valid/implicit-groups.toml"),
+ include_str!("valid/implicit-groups.milf"),
include_str!("valid/implicit-groups.json")
);
test!(
integer,
- include_str!("valid/integer.toml"),
+ include_str!("valid/integer.milf"),
include_str!("valid/integer.json")
);
test!(
key_equals_nospace,
- include_str!("valid/key-equals-nospace.toml"),
+ include_str!("valid/key-equals-nospace.milf"),
include_str!("valid/key-equals-nospace.json")
);
test!(
key_space,
- include_str!("valid/key-space.toml"),
+ include_str!("valid/key-space.milf"),
include_str!("valid/key-space.json")
);
test!(
key_special_chars,
- include_str!("valid/key-special-chars.toml"),
+ include_str!("valid/key-special-chars.milf"),
include_str!("valid/key-special-chars.json")
);
test!(
key_with_pound,
- include_str!("valid/key-with-pound.toml"),
+ include_str!("valid/key-with-pound.milf"),
include_str!("valid/key-with-pound.json")
);
test!(
long_float,
- include_str!("valid/long-float.toml"),
+ include_str!("valid/long-float.milf"),
include_str!("valid/long-float.json")
);
test!(
long_integer,
- include_str!("valid/long-integer.toml"),
+ include_str!("valid/long-integer.milf"),
include_str!("valid/long-integer.json")
);
test!(
multiline_string,
- include_str!("valid/multiline-string.toml"),
+ include_str!("valid/multiline-string.milf"),
include_str!("valid/multiline-string.json")
);
test!(
raw_multiline_string,
- include_str!("valid/raw-multiline-string.toml"),
+ include_str!("valid/raw-multiline-string.milf"),
include_str!("valid/raw-multiline-string.json")
);
test!(
raw_string,
- include_str!("valid/raw-string.toml"),
+ include_str!("valid/raw-string.milf"),
include_str!("valid/raw-string.json")
);
test!(
string_empty,
- include_str!("valid/string-empty.toml"),
+ include_str!("valid/string-empty.milf"),
include_str!("valid/string-empty.json")
);
test!(
string_escapes,
- include_str!("valid/string-escapes.toml"),
+ include_str!("valid/string-escapes.milf"),
include_str!("valid/string-escapes.json")
);
test!(
string_simple,
- include_str!("valid/string-simple.toml"),
+ include_str!("valid/string-simple.milf"),
include_str!("valid/string-simple.json")
);
test!(
string_with_pound,
- include_str!("valid/string-with-pound.toml"),
+ include_str!("valid/string-with-pound.milf"),
include_str!("valid/string-with-pound.json")
);
test!(
table_array_implicit,
- include_str!("valid/table-array-implicit.toml"),
+ include_str!("valid/table-array-implicit.milf"),
include_str!("valid/table-array-implicit.json")
);
test!(
table_array_many,
- include_str!("valid/table-array-many.toml"),
+ include_str!("valid/table-array-many.milf"),
include_str!("valid/table-array-many.json")
);
test!(
table_array_nest,
- include_str!("valid/table-array-nest.toml"),
+ include_str!("valid/table-array-nest.milf"),
include_str!("valid/table-array-nest.json")
);
test!(
table_array_one,
- include_str!("valid/table-array-one.toml"),
+ include_str!("valid/table-array-one.milf"),
include_str!("valid/table-array-one.json")
);
test!(
table_empty,
- include_str!("valid/table-empty.toml"),
+ include_str!("valid/table-empty.milf"),
include_str!("valid/table-empty.json")
);
test!(
table_sub_empty,
- include_str!("valid/table-sub-empty.toml"),
+ include_str!("valid/table-sub-empty.milf"),
include_str!("valid/table-sub-empty.json")
);
test!(
table_multi_empty,
- include_str!("valid/table-multi-empty.toml"),
+ include_str!("valid/table-multi-empty.milf"),
include_str!("valid/table-multi-empty.json")
);
test!(
table_whitespace,
- include_str!("valid/table-whitespace.toml"),
+ include_str!("valid/table-whitespace.milf"),
include_str!("valid/table-whitespace.json")
);
test!(
table_with_pound,
- include_str!("valid/table-with-pound.toml"),
+ include_str!("valid/table-with-pound.milf"),
include_str!("valid/table-with-pound.json")
);
test!(
unicode_escape,
- include_str!("valid/unicode-escape.toml"),
+ include_str!("valid/unicode-escape.milf"),
include_str!("valid/unicode-escape.json")
);
test!(
unicode_literal,
- include_str!("valid/unicode-literal.toml"),
+ include_str!("valid/unicode-literal.milf"),
include_str!("valid/unicode-literal.json")
);
test!(
hard_example,
- include_str!("valid/hard_example.toml"),
+ include_str!("valid/hard_example.milf"),
include_str!("valid/hard_example.json")
);
test!(
example2,
- include_str!("valid/example2.toml"),
+ include_str!("valid/example2.milf"),
include_str!("valid/example2.json")
);
test!(
example3,
- include_str!("valid/example-v0.3.0.toml"),
+ include_str!("valid/example-v0.3.0.milf"),
include_str!("valid/example-v0.3.0.json")
);
test!(
example4,
- include_str!("valid/example-v0.4.0.toml"),
+ include_str!("valid/example-v0.4.0.milf"),
include_str!("valid/example-v0.4.0.json")
);
test!(
example_bom,
- include_str!("valid/example-bom.toml"),
+ include_str!("valid/example-bom.milf"),
include_str!("valid/example.json")
);
test!(
datetime_truncate,
- include_str!("valid/datetime-truncate.toml"),
+ include_str!("valid/datetime-truncate.milf"),
include_str!("valid/datetime-truncate.json")
);
test!(
key_quote_newline,
- include_str!("valid/key-quote-newline.toml"),
+ include_str!("valid/key-quote-newline.milf"),
include_str!("valid/key-quote-newline.json")
);
test!(
table_array_nest_no_keys,
- include_str!("valid/table-array-nest-no-keys.toml"),
+ include_str!("valid/table-array-nest-no-keys.milf"),
include_str!("valid/table-array-nest-no-keys.json")
);
test!(
dotted_keys,
- include_str!("valid/dotted-keys.toml"),
+ include_str!("valid/dotted-keys.milf"),
include_str!("valid/dotted-keys.json")
);
test!(
quote_surrounded_value,
- include_str!("valid/quote-surrounded-value.toml"),
+ include_str!("valid/quote-surrounded-value.milf"),
include_str!("valid/quote-surrounded-value.json")
);
test!(
float_exponent,
- include_str!("valid/float-exponent.toml"),
+ include_str!("valid/float-exponent.milf"),
include_str!("valid/float-exponent.json")
);
test!(
string_delim_end,
- include_str!("valid/string-delim-end.toml"),
+ include_str!("valid/string-delim-end.milf"),
include_str!("valid/string-delim-end.json")
);