Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Report user value #117

Merged
merged 3 commits into from Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 36 additions & 6 deletions src/iter.rs
Expand Up @@ -79,7 +79,12 @@ where
}

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -92,7 +97,12 @@ where
}

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<reflection::Case<'b>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand Down Expand Up @@ -187,7 +197,12 @@ where
}

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -200,7 +215,12 @@ where
}

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<reflection::Case<'b>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand Down Expand Up @@ -256,7 +276,12 @@ where
}

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -269,7 +294,12 @@ where
}

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<reflection::Case<'b>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand Down
40 changes: 32 additions & 8 deletions src/ord.rs
Expand Up @@ -55,7 +55,12 @@ where
}

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -71,7 +76,12 @@ where
}

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<reflection::Case<'b>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -85,10 +95,12 @@ where
let palette = crate::Palette::current();
write!(
f,
"{} {} {:?}",
"{} {} {}",
palette.var.paint("var"),
palette.description.paint(self.op),
self.constant
palette
.expected
.paint(utils::DebugAdapter::new(&self.constant)),
)
}
}
Expand Down Expand Up @@ -188,7 +200,12 @@ where
}

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -206,7 +223,12 @@ where
}

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<reflection::Case<'b>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
utils::DebugAdapter::new(variable).to_string(),
))
})
}
}

Expand All @@ -220,10 +242,12 @@ where
let palette = crate::Palette::current();
write!(
f,
"{} {} {:?}",
"{} {} {}",
palette.var.paint("var"),
palette.description.paint(self.op),
self.constant
palette
.expected
.paint(utils::DebugAdapter::new(&self.constant)),
)
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/path/existence.rs
Expand Up @@ -31,7 +31,12 @@ impl Predicate<path::Path> for ExistencePredicate {
expected: bool,
variable: &path::Path,
) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
utils::default_find_case(self, expected, variable).map(|case| {
case.add_product(reflection::Product::new(
"var",
variable.display().to_string(),
))
})
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/path/fc.rs
Expand Up @@ -75,13 +75,19 @@ where
) -> Option<reflection::Case<'a>> {
let buffer = read_file(variable);
match (expected, buffer) {
(_, Ok(buffer)) => self
.p
.find_case(expected, &buffer)
.map(|child| reflection::Case::new(Some(self), expected).add_child(child)),
(_, Ok(buffer)) => self.p.find_case(expected, &buffer).map(|case| {
case.add_product(reflection::Product::new(
"var",
variable.display().to_string(),
))
}),
(true, Err(_)) => None,
(false, Err(err)) => Some(
reflection::Case::new(Some(self), false)
.add_product(reflection::Product::new(
"var",
variable.display().to_string(),
))
.add_product(reflection::Product::new("error", err)),
),
}
Expand Down
5 changes: 5 additions & 0 deletions src/str/basics.rs
Expand Up @@ -25,6 +25,7 @@ impl Predicate<str> for IsEmptyPredicate {

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
.map(|case| case.add_product(reflection::Product::new("var", variable.to_owned())))
}
}

Expand Down Expand Up @@ -72,6 +73,7 @@ impl Predicate<str> for StartsWithPredicate {

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
.map(|case| case.add_product(reflection::Product::new("var", variable.to_owned())))
}
}

Expand Down Expand Up @@ -125,6 +127,7 @@ impl Predicate<str> for EndsWithPredicate {

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
.map(|case| case.add_product(reflection::Product::new("var", variable.to_owned())))
}
}

Expand Down Expand Up @@ -198,6 +201,7 @@ impl Predicate<str> for ContainsPredicate {

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
.map(|case| case.add_product(reflection::Product::new("var", variable.to_owned())))
}
}

Expand Down Expand Up @@ -236,6 +240,7 @@ impl Predicate<str> for MatchesPredicate {
if result == expected {
Some(
reflection::Case::new(Some(self), result)
.add_product(reflection::Product::new("var", variable.to_owned()))
.add_product(reflection::Product::new("actual count", actual_count)),
)
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/str/regex.rs
Expand Up @@ -47,6 +47,7 @@ impl Predicate<str> for RegexPredicate {

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
.map(|case| case.add_product(reflection::Product::new("var", variable.to_owned())))
}
}

Expand Down Expand Up @@ -85,6 +86,7 @@ impl Predicate<str> for RegexMatchesPredicate {
if result == expected {
Some(
reflection::Case::new(Some(self), result)
.add_product(reflection::Product::new("var", variable.to_owned()))
.add_product(reflection::Product::new("actual count", actual_count)),
)
} else {
Expand Down