From 97f208bf766de90f86962262fca7fa4d929a1adf Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Fri, 22 Jun 2018 20:56:54 +0200 Subject: [PATCH 1/2] Add tests to show expected indentation interpretation --- parser/src/yaml.rs | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/parser/src/yaml.rs b/parser/src/yaml.rs index b7b2b7c..a7ed23c 100644 --- a/parser/src/yaml.rs +++ b/parser/src/yaml.rs @@ -638,4 +638,61 @@ c: ~ let first = out.into_iter().next().unwrap(); assert_eq!(first[0]["important"].as_bool().unwrap(), true); } + + #[test] + fn test_indentation_equality() { + + let four_spaces = YamlLoader::load_from_str(r#" +hash: + with: + indentations +"#).unwrap().into_iter().next().unwrap(); + + let two_spaces = YamlLoader::load_from_str(r#" +hash: + with: + indentations +"#).unwrap().into_iter().next().unwrap(); + + let one_space = YamlLoader::load_from_str(r#" +hash: + with: + indentations +"#).unwrap().into_iter().next().unwrap(); + + let mixed_spaces = YamlLoader::load_from_str(r#" +hash: + with: + indentations +"#).unwrap().into_iter().next().unwrap(); + + assert_eq!(four_spaces, two_spaces); + assert_eq!(two_spaces, one_space); + assert_eq!(four_spaces, mixed_spaces); + } + + #[test] + fn test_two_space_indentations() { + // https://github.com/kbknapp/clap-rs/issues/965 + + let s = r#" +subcommands: + - server: + about: server related commands +subcommands2: + - server: + about: server related commands +subcommands3: + - server: + about: server related commands + "#; + + let out = YamlLoader::load_from_str(&s).unwrap(); + let doc = &out.into_iter().next().unwrap(); + + println!("{:#?}", doc); + assert_eq!(doc["subcommands"][0]["server"], Yaml::Null); + assert!(doc["subcommands2"][0]["server"].as_hash().is_some()); + assert!(doc["subcommands3"][0]["server"].as_hash().is_some()); + } } From 39c212ba9376685d49b686fe555906d67b36f6f6 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sun, 2 Sep 2018 18:13:50 +0200 Subject: [PATCH 2/2] Update quickcheck to 0.7 --- parser/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/Cargo.toml b/parser/Cargo.toml index f00d0a9..545c20d 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -13,4 +13,4 @@ repository = "https://github.com/chyh1990/yaml-rust" linked-hash-map = ">=0.0.9, <0.6" [dev-dependencies] -quickcheck = "0.6" +quickcheck = "0.7"