diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/ron/tests/129_indexmap.rs | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/ron/tests/129_indexmap.rs')
-rw-r--r-- | third_party/rust/ron/tests/129_indexmap.rs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/third_party/rust/ron/tests/129_indexmap.rs b/third_party/rust/ron/tests/129_indexmap.rs new file mode 100644 index 0000000000..a10a11e27e --- /dev/null +++ b/third_party/rust/ron/tests/129_indexmap.rs @@ -0,0 +1,76 @@ +#[cfg(feature = "indexmap")] +use ron::{de::from_str, Value}; + +#[test] +#[cfg(feature = "indexmap")] +fn test_order_preserved() { + let file = r#"( +tasks: { + "debug message": Dbg( + msg: "test message. some text after it." + ), + "shell command": Shell( + command: "ls", + args: Some([ + "-l", + "-h", + ]), + ch_dir: Some("/"), + ), +}, +) +"#; + + let value: Value = from_str(file).unwrap(); + match value { + Value::Map(map) => match &map[&Value::String("tasks".to_owned())] { + Value::Map(map) => { + assert_eq!( + *map.keys().next().unwrap(), + Value::String("debug message".to_string()) + ); + assert_eq!( + *map.keys().skip(1).next().unwrap(), + Value::String("shell command".to_string()) + ); + } + _ => panic!(), + }, + _ => panic!(), + } + + let file = r#"( +tasks: { + "shell command": Shell( + command: "ls", + args: Some([ + "-l", + "-h", + ]), + ch_dir: Some("/") + ), + "debug message": Dbg( + msg: "test message. some text after it." + ), +} +) +"#; + + let value: Value = from_str(file).unwrap(); + match value { + Value::Map(map) => match &map[&Value::String("tasks".to_owned())] { + Value::Map(map) => { + assert_eq!( + *map.keys().next().unwrap(), + Value::String("shell command".to_string()) + ); + assert_eq!( + *map.keys().skip(1).next().unwrap(), + Value::String("debug message".to_string()) + ); + } + _ => panic!(), + }, + _ => panic!(), + } +} |