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

Refacto predicate on Value.rs #3614

Open
jcamiel opened this issue Jan 20, 2025 · 0 comments
Open

Refacto predicate on Value.rs #3614

jcamiel opened this issue Jan 20, 2025 · 0 comments
Assignees
Milestone

Comments

@jcamiel
Copy link
Collaborator

jcamiel commented Jan 20, 2025

Every predicate on Value are implemented in runner/predicate.rs and runner/predicate_value.rs:

fn eval_start_with(
expected: &PredicateValue,
variables: &VariableSet,
actual: &Value,
context_dir: &ContextDir,
) -> Result<AssertResult, RunnerError> {
let expected = eval_predicate_value(expected, variables, context_dir)?;
let expected_display = format!("starts with {}", expected.repr());
let actual_display = actual.repr();
match (expected, actual) {
(Value::String(expected), Value::String(actual)) => Ok(AssertResult {
success: actual.as_str().starts_with(expected.as_str()),
actual: actual_display,
expected: expected_display,
type_mismatch: false,
}),
(Value::Bytes(expected), Value::Bytes(actual)) => Ok(AssertResult {
success: actual.starts_with(&expected),
actual: actual_display,
expected: expected_display,
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: false,
actual: actual_display,
expected: expected_display,
type_mismatch: true,
}),
}
}

The code should be move to Value.rs by implemeting eq, start_with on directly Value + test unit are simpler

@jcamiel jcamiel added the enhancement New feature or request label Jan 20, 2025
@jcamiel jcamiel added refactoring and removed enhancement New feature or request labels Jan 24, 2025
@jcamiel jcamiel added this to the 6.1.0 milestone Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants