| 1 | #[cfg(feature = "indexmap")] |
| 2 | use ronrust-analyzer cargo ron 0.12.0 crate/::{derust-analyzer cargo ron 0.12.0 de/::from_strrust-analyzer cargo ron 0.12.0 de/from_str()., Valuerust-analyzer cargo ron 0.12.0 value/Value#}; |
| 3 | |
| 4 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 5 | #[cfg(feature = "indexmap")] |
| 6 | fn test_order_preservedrust-analyzer cargo ron 0.12.0 test_order_preserved().() { |
| 7 | let file = r#"( |
| 8 | tasks: { |
| 9 | "debug message": Dbg( |
| 10 | msg: "test message. some text after it." |
| 11 | ), |
| 12 | "shell command": Shell( |
| 13 | command: "ls", |
| 14 | args: Some([ |
| 15 | "-l", |
| 16 | "-h", |
| 17 | ]), |
| 18 | ch_dir: Some("/"), |
| 19 | ), |
| 20 | }, |
| 21 | ) |
| 22 | "#; |
| 23 | |
| 24 | let value: Valuerust-analyzer cargo ron 0.12.0 value/Value# = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 25 | match value { |
| 26 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Maprust-analyzer cargo ron 0.12.0 value/Value#Map#(map) => match &map[rust-analyzer cargo ron 0.12.0 value/map/impl#[Map][`Index<&Value>`]index().&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("tasks".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())]rust-analyzer cargo ron 0.12.0 value/map/impl#[Map][`Index<&Value>`]index(). { |
| 27 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Maprust-analyzer cargo ron 0.12.0 value/Value#Map#(map) => { |
| 28 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 29 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().map.keysrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]keys().().nextrust-analyzer cargo indexmap 2.5.0 map/iter/impl#[`Keys<'a, K, V>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 30 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("debug message".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 31 | ); |
| 32 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 33 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().map.keysrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]keys().().nthrust-analyzer cargo indexmap 2.5.0 map/iter/impl#[`Keys<'a, K, V>`][Iterator]nth().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 34 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("shell command".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 35 | ); |
| 36 | } |
| 37 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(), // GRCOV_EXCL_LINE |
| 38 | }, |
| 39 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(), // GRCOV_EXCL_LINE |
| 40 | } |
| 41 | |
| 42 | let file = r#"( |
| 43 | tasks: { |
| 44 | "shell command": Shell( |
| 45 | command: "ls", |
| 46 | args: Some([ |
| 47 | "-l", |
| 48 | "-h", |
| 49 | ]), |
| 50 | ch_dir: Some("/") |
| 51 | ), |
| 52 | "debug message": Dbg( |
| 53 | msg: "test message. some text after it." |
| 54 | ), |
| 55 | } |
| 56 | ) |
| 57 | "#; |
| 58 | |
| 59 | let value: Valuerust-analyzer cargo ron 0.12.0 value/Value# = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 60 | match value { |
| 61 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Maprust-analyzer cargo ron 0.12.0 value/Value#Map#(map) => match &map[rust-analyzer cargo ron 0.12.0 value/map/impl#[Map][`Index<&Value>`]index().&Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("tasks".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())]rust-analyzer cargo ron 0.12.0 value/map/impl#[Map][`Index<&Value>`]index(). { |
| 62 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Maprust-analyzer cargo ron 0.12.0 value/Value#Map#(map) => { |
| 63 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 64 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().map.keysrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]keys().().nextrust-analyzer cargo indexmap 2.5.0 map/iter/impl#[`Keys<'a, K, V>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 65 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("shell command".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 66 | ); |
| 67 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 68 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().map.keysrust-analyzer cargo ron 0.12.0 value/map/impl#[Map]keys().().nthrust-analyzer cargo indexmap 2.5.0 map/iter/impl#[`Keys<'a, K, V>`][Iterator]nth().(1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 69 | Valuerust-analyzer cargo ron 0.12.0 value/Value#::Stringrust-analyzer cargo ron 0.12.0 value/Value#String#("debug message".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 70 | ); |
| 71 | } |
| 72 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(), // GRCOV_EXCL_LINE |
| 73 | }, |
| 74 | _ => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!(), // GRCOV_EXCL_LINE |
| 75 | } |
| 76 | } |