Remove the GetStandardProperties trait.
This was using dynamic dispatch to deal with enums to avoid the repetitive typing.
This commit is contained in:
@@ -211,7 +211,6 @@ mod tests {
|
||||
use crate::context::List;
|
||||
use crate::parser::element_parser::element;
|
||||
use crate::types::Element;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
#[test]
|
||||
@@ -227,10 +226,7 @@ mod tests {
|
||||
_ => panic!("Should be a paragraph!"),
|
||||
};
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"[cite:@foo]"
|
||||
);
|
||||
assert_eq!(first_paragraph.get_source(), "[cite:@foo]");
|
||||
assert_eq!(first_paragraph.children.len(), 1);
|
||||
|
||||
match first_paragraph
|
||||
|
||||
@@ -160,7 +160,7 @@ mod tests {
|
||||
use crate::context::Context;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
#[test]
|
||||
fn two_paragraphs() {
|
||||
@@ -181,17 +181,13 @@ line footnote.",
|
||||
footnote_definition_matcher(remaining).expect("Parse second footnote_definition.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
first_footnote_definition
|
||||
.get_standard_properties()
|
||||
.get_source(),
|
||||
first_footnote_definition.get_source(),
|
||||
"[fn:1] A footnote.
|
||||
|
||||
"
|
||||
);
|
||||
assert_eq!(
|
||||
second_footnote_definition
|
||||
.get_standard_properties()
|
||||
.get_source(),
|
||||
second_footnote_definition.get_source(),
|
||||
"[fn:2] A multi-
|
||||
|
||||
line footnote."
|
||||
@@ -216,9 +212,7 @@ not in the footnote.",
|
||||
footnote_definition_matcher(input).expect("Parse first footnote_definition");
|
||||
assert_eq!(Into::<&str>::into(remaining), "not in the footnote.");
|
||||
assert_eq!(
|
||||
first_footnote_definition
|
||||
.get_standard_properties()
|
||||
.get_source(),
|
||||
first_footnote_definition.get_source(),
|
||||
"[fn:2] A multi-
|
||||
|
||||
line footnote.
|
||||
|
||||
@@ -96,7 +96,7 @@ mod tests {
|
||||
use crate::context::List;
|
||||
use crate::parser::element_parser::element;
|
||||
use crate::parser::org_source::OrgSource;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
#[test]
|
||||
fn two_paragraphs() {
|
||||
@@ -109,13 +109,7 @@ mod tests {
|
||||
let (remaining, second_paragraph) =
|
||||
paragraph_matcher(remaining).expect("Parse second paragraph.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"foo bar baz\n\n"
|
||||
);
|
||||
assert_eq!(
|
||||
second_paragraph.get_standard_properties().get_source(),
|
||||
"lorem ipsum"
|
||||
);
|
||||
assert_eq!(first_paragraph.get_source(), "foo bar baz\n\n");
|
||||
assert_eq!(second_paragraph.get_source(), "lorem ipsum");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +629,7 @@ mod tests {
|
||||
use crate::context::Context;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
#[test]
|
||||
fn plain_list_item_empty() {
|
||||
@@ -640,7 +640,7 @@ mod tests {
|
||||
let plain_list_item_matcher = bind_context!(plain_list_item, &initial_context);
|
||||
let (remaining, (_, result)) = plain_list_item_matcher(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1.");
|
||||
assert_eq!(result.get_source(), "1.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -652,7 +652,7 @@ mod tests {
|
||||
let plain_list_item_matcher = bind_context!(plain_list_item, &initial_context);
|
||||
let (remaining, (_, result)) = plain_list_item_matcher(input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1. foo");
|
||||
assert_eq!(result.get_source(), "1. foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -664,7 +664,7 @@ mod tests {
|
||||
let (remaining, result) =
|
||||
plain_list(std::iter::empty(), input, &initial_context, input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1.");
|
||||
assert_eq!(result.get_source(), "1.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -676,7 +676,7 @@ mod tests {
|
||||
let (remaining, result) =
|
||||
plain_list(std::iter::empty(), input, &initial_context, input).unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(result.get_standard_properties().get_source(), "1. foo");
|
||||
assert_eq!(result.get_source(), "1. foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -721,7 +721,7 @@ mod tests {
|
||||
plain_list_matcher(input).expect("Should parse the plain list successfully.");
|
||||
assert_eq!(Into::<&str>::into(remaining), " ipsum\n");
|
||||
assert_eq!(
|
||||
result.get_standard_properties().get_source(),
|
||||
result.get_source(),
|
||||
r#"1. foo
|
||||
2. bar
|
||||
baz
|
||||
@@ -749,7 +749,7 @@ baz"#,
|
||||
plain_list_matcher(input).expect("Should parse the plain list successfully.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "baz");
|
||||
assert_eq!(
|
||||
result.get_standard_properties().get_source(),
|
||||
result.get_source(),
|
||||
r#"1. foo
|
||||
1. bar
|
||||
|
||||
@@ -782,7 +782,7 @@ dolar"#,
|
||||
plain_list_matcher(input).expect("Should parse the plain list successfully.");
|
||||
assert_eq!(Into::<&str>::into(remaining), "dolar");
|
||||
assert_eq!(
|
||||
result.get_standard_properties().get_source(),
|
||||
result.get_source(),
|
||||
r#"1. foo
|
||||
|
||||
bar
|
||||
|
||||
@@ -143,7 +143,7 @@ mod tests {
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::context::List;
|
||||
use crate::parser::object_parser::detect_standard_set_object_sans_plain_text;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
#[test]
|
||||
fn plain_text_simple() {
|
||||
@@ -160,9 +160,6 @@ mod tests {
|
||||
)(input)
|
||||
.unwrap();
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
result.get_standard_properties().get_source(),
|
||||
Into::<&str>::into(input)
|
||||
);
|
||||
assert_eq!(result.get_source(), Into::<&str>::into(input));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@ mod tests {
|
||||
use crate::parser::element_parser::element;
|
||||
use crate::types::Bold;
|
||||
use crate::types::Element;
|
||||
use crate::types::GetStandardProperties;
|
||||
use crate::types::PlainText;
|
||||
use crate::types::StandardProperties;
|
||||
|
||||
#[test]
|
||||
fn plain_text_radio_target() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -195,10 +195,7 @@ mod tests {
|
||||
_ => panic!("Should be a paragraph!"),
|
||||
};
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"foo bar baz"
|
||||
);
|
||||
assert_eq!(first_paragraph.get_source(), "foo bar baz");
|
||||
assert_eq!(first_paragraph.children.len(), 3);
|
||||
match first_paragraph
|
||||
.children
|
||||
@@ -206,7 +203,7 @@ mod tests {
|
||||
.expect("Len already asserted to be 3.")
|
||||
{
|
||||
Object::RadioLink(inner) => {
|
||||
assert_eq!(inner.get_standard_properties().get_source(), "bar ");
|
||||
assert_eq!(inner.get_source(), "bar ");
|
||||
assert_eq!(inner.path, "bar");
|
||||
assert_eq!(inner.children.len(), 1);
|
||||
let child = inner
|
||||
@@ -214,7 +211,7 @@ mod tests {
|
||||
.first()
|
||||
.expect("Length already asserted to be 1.");
|
||||
assert!(matches!(child, Object::PlainText(_)));
|
||||
assert_eq!(child.get_standard_properties().get_source(), "bar");
|
||||
assert_eq!(child.get_source(), "bar");
|
||||
}
|
||||
_ => {
|
||||
return Err("Child should be a radio link.".into());
|
||||
@@ -244,10 +241,7 @@ mod tests {
|
||||
_ => panic!("Should be a paragraph!"),
|
||||
};
|
||||
assert_eq!(Into::<&str>::into(remaining), "");
|
||||
assert_eq!(
|
||||
first_paragraph.get_standard_properties().get_source(),
|
||||
"foo *bar* baz"
|
||||
);
|
||||
assert_eq!(first_paragraph.get_source(), "foo *bar* baz");
|
||||
assert_eq!(first_paragraph.children.len(), 3);
|
||||
match first_paragraph
|
||||
.children
|
||||
@@ -255,7 +249,7 @@ mod tests {
|
||||
.expect("Len already asserted to be 3.")
|
||||
{
|
||||
Object::RadioLink(inner) => {
|
||||
assert_eq!(inner.get_standard_properties().get_source(), "*bar* ");
|
||||
assert_eq!(inner.get_source(), "*bar* ");
|
||||
assert_eq!(inner.path, "*bar* ");
|
||||
assert_eq!(inner.children.len(), 1);
|
||||
let child = inner
|
||||
@@ -263,7 +257,7 @@ mod tests {
|
||||
.first()
|
||||
.expect("Length already asserted to be 1.");
|
||||
assert!(matches!(child, Object::Bold(_)));
|
||||
assert_eq!(child.get_standard_properties().get_source(), "*bar* ");
|
||||
assert_eq!(child.get_source(), "*bar* ");
|
||||
}
|
||||
_ => {
|
||||
return Err("Child should be a radio link.".into());
|
||||
|
||||
Reference in New Issue
Block a user