Deprecate word predicate when operator is available

This commit is contained in:
Fabrice Reix 2023-06-18 19:36:02 +02:00
parent 4500ad170a
commit 7587fdb013
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
4 changed files with 23 additions and 4 deletions

View File

@ -1,3 +1,4 @@
'equals' predicate is now deprecated. Use '==' instead
error: Parsing escape character
--> tests_error_parser/invalid_escape.hurl:4:25
|

View File

@ -1,7 +1,7 @@
error: Parsing predicate value
--> tests_error_parser/predicate_equal_value.hurl:4:22
--> tests_error_parser/predicate_equal_value.hurl:4:18
|
4 | header "toto" equals xx
| ^ invalid predicate value
4 | header "toto" == xx
| ^ invalid predicate value
|

View File

@ -1,4 +1,4 @@
GET http://localhost:8000/hello
HTTP 200
[Asserts]
header "toto" equals xx
header "toto" == xx

View File

@ -122,6 +122,9 @@ impl PredicateValue {
fn equal_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValue> {
let operator = try_literals("equals", "==", reader)? == "==";
if !operator {
eprintln!("'equals' predicate is now deprecated. Use '==' instead");
}
let space0 = if operator {
zero_or_more_spaces(reader)?
} else {
@ -137,6 +140,9 @@ fn equal_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncVal
fn not_equal_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValue> {
let operator = try_literals("notEquals", "!=", reader)? == "!=";
if !operator {
eprintln!("'notEquals' predicate is now deprecated. Use '!=' instead");
}
let space0 = if operator {
zero_or_more_spaces(reader)?
} else {
@ -152,6 +158,9 @@ fn not_equal_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFun
fn greater_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValue> {
let operator = try_literals("greaterThan", ">", reader)? == ">";
if !operator {
eprintln!("'greaterThan' predicate is now deprecated. Use '>' instead");
}
let space0 = if operator {
zero_or_more_spaces(reader)?
} else {
@ -176,6 +185,9 @@ fn greater_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncV
fn greater_or_equal_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValue> {
let operator = try_literals("greaterThanOrEquals", ">=", reader)? == ">=";
if !operator {
eprintln!("'greaterThanOrEquals' predicate is now deprecated. Use '>=' instead");
}
let space0 = if operator {
zero_or_more_spaces(reader)?
} else {
@ -200,6 +212,9 @@ fn greater_or_equal_predicate(reader: &mut Reader) -> ParseResult<'static, Predi
fn less_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValue> {
let operator = try_literals("lessThan", "<", reader)? == "<";
if !operator {
eprintln!("'lessThan' predicate is now deprecated. Use '<' instead");
}
let space0 = if operator {
zero_or_more_spaces(reader)?
} else {
@ -224,6 +239,9 @@ fn less_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValu
fn less_or_equal_predicate(reader: &mut Reader) -> ParseResult<'static, PredicateFuncValue> {
let operator = try_literals("lessThanOrEquals", "<=", reader)? == "<=";
if !operator {
eprintln!("'lessThanOrEquals' predicate is now deprecated. Use '<=' instead");
}
let space0 = if operator {
zero_or_more_spaces(reader)?
} else {