Skip to content

Commit

Permalink
this is better
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Nov 14, 2024
1 parent aa7da17 commit 1d0ab14
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
11 changes: 5 additions & 6 deletions v0.5/fastn-unresolved/src/parser/component_invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ 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);
Expand Down
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 1d0ab14

Please sign in to comment.