Skip to content

Commit

Permalink
Merge branch 'main' into fix-ci-globs
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Upadhyay <[email protected]>
  • Loading branch information
amitu authored Nov 14, 2024
2 parents 56c88fc + 7f68494 commit c3b7a59
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
13 changes: 6 additions & 7 deletions v0.5/fastn-unresolved/src/parser/component_invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ pub(super) fn component_invocation(

#[cfg(test)]
mod tests {
fn tester(
mut d: fastn_unresolved::Document,
source: &str,
expected: serde_json::Value,
) -> bool {
fn tester(mut d: fastn_unresolved::Document, source: &str, expected: serde_json::Value) {
assert!(d.imports.is_empty());
assert!(d.definitions.is_empty());
assert_eq!(d.content.len(), 1);

fastn_section::JDebug::debug(&d.content.pop().unwrap(), source) == expected
assert_eq!(
fastn_section::JDebug::debug(&d.content.pop().unwrap(), source),
expected
)
}

fastn_unresolved::tt!(super::component_invocation, tester);

#[test]
fn component_invocation() {
t!("-- import: foo", { "import": "foo" });
t!("-- ftd.text: hello", { "content": "ftd.text", "caption": "hello" });
}
}
12 changes: 6 additions & 6 deletions v0.5/fastn-unresolved/src/parser/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ fn aliasable(s: &str) -> fastn_unresolved::AliasableIdentifier {

#[cfg(test)]
mod tests {
fn tester(
mut d: fastn_unresolved::Document,
source: &str,
expected: serde_json::Value,
) -> bool {
#[track_caller]
fn tester(mut d: fastn_unresolved::Document, source: &str, expected: serde_json::Value) {
assert!(d.content.is_empty());
assert!(d.definitions.is_empty());
assert_eq!(d.imports.len(), 1);

fastn_section::JDebug::debug(&d.imports.pop().unwrap(), source) == expected
assert_eq!(
fastn_section::JDebug::debug(&d.imports.pop().unwrap(), source),
expected
)
}

fastn_unresolved::tt!(super::import, tester);
Expand Down
4 changes: 2 additions & 2 deletions v0.5/fastn-unresolved/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn parse(_document_id: &str, source: &str) -> fastn_unresolved::Document {
fn t1<PARSER, TESTER>(source: &str, expected: serde_json::Value, parser: PARSER, tester: TESTER)
where
PARSER: Fn(&str, fastn_section::Section, &mut fastn_unresolved::Document),
TESTER: FnOnce(fastn_unresolved::Document, &str, serde_json::Value) -> bool,
TESTER: FnOnce(fastn_unresolved::Document, &str, serde_json::Value),
{
println!("--------- testing -----------\n{source}\n--------- source ------------");

Expand All @@ -60,7 +60,7 @@ where
// assert everything else is empty
parser(source, section, &mut document);

assert!(tester(document, source, expected));
tester(document, source, expected);
}

#[cfg(test)]
Expand Down

0 comments on commit c3b7a59

Please sign in to comment.