mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 06:05:24 +00:00
Remove maplit dependency and stop using a macro for hashmaps (#982)
This commit is contained in:
@@ -304,7 +304,6 @@ mod test {
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use maplit::hashmap;
|
||||
use rbx_dom_weak::types::Variant;
|
||||
|
||||
use super::super::PatchAdd;
|
||||
@@ -322,9 +321,7 @@ mod test {
|
||||
metadata: Default::default(),
|
||||
name: Cow::Borrowed("Foo"),
|
||||
class_name: Cow::Borrowed("Bar"),
|
||||
properties: hashmap! {
|
||||
"Baz".to_owned() => Variant::Int32(5),
|
||||
},
|
||||
properties: [("Baz".to_owned(), Variant::Int32(5))].into(),
|
||||
children: Vec::new(),
|
||||
};
|
||||
|
||||
@@ -367,16 +364,15 @@ mod test {
|
||||
id: root_id,
|
||||
changed_name: Some("Foo".to_owned()),
|
||||
changed_class_name: Some("NewClassName".to_owned()),
|
||||
changed_properties: hashmap! {
|
||||
changed_properties: [
|
||||
// The value of Foo has changed
|
||||
"Foo".to_owned() => Some(Variant::Int32(8)),
|
||||
|
||||
("Foo".to_owned(), Some(Variant::Int32(8))),
|
||||
// Bar has been deleted
|
||||
"Bar".to_owned() => None,
|
||||
|
||||
("Bar".to_owned(), None),
|
||||
// Baz has been added
|
||||
"Baz".to_owned() => Some(Variant::Int32(10)),
|
||||
},
|
||||
("Baz".to_owned(), Some(Variant::Int32(10))),
|
||||
]
|
||||
.into(),
|
||||
changed_metadata: None,
|
||||
};
|
||||
|
||||
@@ -387,11 +383,12 @@ mod test {
|
||||
|
||||
apply_patch_set(&mut tree, patch_set);
|
||||
|
||||
let expected_properties = hashmap! {
|
||||
"Foo".to_owned() => Variant::Int32(8),
|
||||
"Baz".to_owned() => Variant::Int32(10),
|
||||
"Unchanged".to_owned() => Variant::Int32(-5),
|
||||
};
|
||||
let expected_properties = [
|
||||
("Foo".to_owned(), Variant::Int32(8)),
|
||||
("Baz".to_owned(), Variant::Int32(10)),
|
||||
("Unchanged".to_owned(), Variant::Int32(-5)),
|
||||
]
|
||||
.into();
|
||||
|
||||
let root_instance = tree.get_instance(root_id).unwrap();
|
||||
assert_eq!(root_instance.name(), "Foo");
|
||||
|
||||
@@ -299,8 +299,6 @@ mod test {
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use maplit::hashmap;
|
||||
|
||||
/// This test makes sure that rewriting refs in instance update patches to
|
||||
/// instances that already exists works. We should be able to correlate the
|
||||
/// snapshot ID and instance ID during patch computation and replace the
|
||||
@@ -316,9 +314,7 @@ mod test {
|
||||
let snapshot_id = Ref::new();
|
||||
let snapshot = InstanceSnapshot {
|
||||
snapshot_id: snapshot_id,
|
||||
properties: hashmap! {
|
||||
"Self".to_owned() => Variant::Ref(snapshot_id),
|
||||
},
|
||||
properties: [("Self".to_owned(), Variant::Ref(snapshot_id))].into(),
|
||||
|
||||
metadata: Default::default(),
|
||||
name: Cow::Borrowed("foo"),
|
||||
@@ -333,9 +329,7 @@ mod test {
|
||||
id: root_id,
|
||||
changed_name: None,
|
||||
changed_class_name: None,
|
||||
changed_properties: hashmap! {
|
||||
"Self".to_owned() => Some(Variant::Ref(root_id)),
|
||||
},
|
||||
changed_properties: [("Self".to_owned(), Some(Variant::Ref(root_id)))].into(),
|
||||
changed_metadata: None,
|
||||
}],
|
||||
added_instances: Vec::new(),
|
||||
@@ -359,9 +353,7 @@ mod test {
|
||||
let snapshot = InstanceSnapshot {
|
||||
snapshot_id: snapshot_id,
|
||||
children: vec![InstanceSnapshot {
|
||||
properties: hashmap! {
|
||||
"Self".to_owned() => Variant::Ref(snapshot_id),
|
||||
},
|
||||
properties: [("Self".to_owned(), Variant::Ref(snapshot_id))].into(),
|
||||
|
||||
snapshot_id: Ref::none(),
|
||||
metadata: Default::default(),
|
||||
@@ -384,9 +376,7 @@ mod test {
|
||||
instance: InstanceSnapshot {
|
||||
snapshot_id: Ref::none(),
|
||||
metadata: Default::default(),
|
||||
properties: hashmap! {
|
||||
"Self".to_owned() => Variant::Ref(root_id),
|
||||
},
|
||||
properties: [("Self".to_owned(), Variant::Ref(root_id))].into(),
|
||||
name: Cow::Borrowed("child"),
|
||||
class_name: Cow::Borrowed("child"),
|
||||
children: Vec::new(),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use insta::assert_yaml_snapshot;
|
||||
use maplit::hashmap;
|
||||
|
||||
use rojo_insta_ext::RedactionMap;
|
||||
|
||||
@@ -47,9 +46,7 @@ fn add_property() {
|
||||
id: tree.get_root_id(),
|
||||
changed_name: None,
|
||||
changed_class_name: None,
|
||||
changed_properties: hashmap! {
|
||||
"Foo".to_owned() => Some("Value of Foo".into()),
|
||||
},
|
||||
changed_properties: [("Foo".to_owned(), Some("Value of Foo".into()))].into(),
|
||||
changed_metadata: None,
|
||||
}],
|
||||
..Default::default()
|
||||
@@ -88,9 +85,7 @@ fn remove_property() {
|
||||
id: tree.get_root_id(),
|
||||
changed_name: None,
|
||||
changed_class_name: None,
|
||||
changed_properties: hashmap! {
|
||||
"Foo".to_owned() => None,
|
||||
},
|
||||
changed_properties: [("Foo".to_owned(), None).into()].into(),
|
||||
changed_metadata: None,
|
||||
}],
|
||||
..Default::default()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use insta::assert_yaml_snapshot;
|
||||
use maplit::hashmap;
|
||||
|
||||
use rbx_dom_weak::types::Ref;
|
||||
use rojo_insta_ext::RedactionMap;
|
||||
@@ -42,9 +41,7 @@ fn set_property() {
|
||||
metadata: Default::default(),
|
||||
name: Cow::Borrowed("ROOT"),
|
||||
class_name: Cow::Borrowed("ROOT"),
|
||||
properties: hashmap! {
|
||||
"PropertyName".to_owned() => "Hello, world!".into(),
|
||||
},
|
||||
properties: [("PropertyName".into(), "Hello, world!".into())].into(),
|
||||
children: Vec::new(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user