mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-23 11:02:43 +03:00
Report error on missing closing quote for quoted String
This commit is contained in:
parent
47170ee4d5
commit
165e79054e
6
integration/tests_error_parser/missing_quote.err
Normal file
6
integration/tests_error_parser/missing_quote.err
Normal file
@ -0,0 +1,6 @@
|
||||
error: Parsing literal
|
||||
--> tests_error_parser/missing_quote.hurl:4:41
|
||||
|
|
||||
4 | jsonpath "$.error.message" == "not found
|
||||
| ^ expecting '"'
|
||||
|
|
1
integration/tests_error_parser/missing_quote.exit
Normal file
1
integration/tests_error_parser/missing_quote.exit
Normal file
@ -0,0 +1 @@
|
||||
2
|
4
integration/tests_error_parser/missing_quote.hurl
Normal file
4
integration/tests_error_parser/missing_quote.hurl
Normal file
@ -0,0 +1,4 @@
|
||||
POST http://localhost:8000/not-found
|
||||
HTTP/1.1 404
|
||||
[Asserts]
|
||||
jsonpath "$.error.message" == "not found
|
@ -117,4 +117,24 @@ mod tests {
|
||||
assert_eq!(error.inner, ParseError::PredicateValue {});
|
||||
assert!(!error.recoverable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_predicate_value_error_missing_quote() {
|
||||
let mut reader = Reader::init("\"not_found");
|
||||
let error = predicate_value(&mut reader).err().unwrap();
|
||||
assert_eq!(
|
||||
error.pos,
|
||||
Pos {
|
||||
line: 1,
|
||||
column: 11
|
||||
}
|
||||
);
|
||||
assert_eq!(
|
||||
error.inner,
|
||||
ParseError::Expecting {
|
||||
value: "\"".to_string()
|
||||
}
|
||||
);
|
||||
assert!(!error.recoverable);
|
||||
}
|
||||
}
|
||||
|
@ -152,23 +152,23 @@ pub fn quoted_template(reader: &mut Reader) -> ParseResult<'static, Template> {
|
||||
let mut chars = vec![];
|
||||
loop {
|
||||
let pos = reader.state.pos.clone();
|
||||
let save = reader.state.clone();
|
||||
match any_char(vec!['"'], reader) {
|
||||
Err(e) => {
|
||||
if e.recoverable {
|
||||
reader.state = save;
|
||||
break;
|
||||
} else {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
Ok((c, s)) => {
|
||||
if s == "\"" {
|
||||
break;
|
||||
}
|
||||
chars.push((c, s, pos));
|
||||
end = reader.state.clone().pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
literal("\"", reader)?;
|
||||
let encoded_string = template::EncodedString {
|
||||
source_info: SourceInfo {
|
||||
start: start.clone(),
|
||||
@ -524,6 +524,20 @@ mod tests {
|
||||
assert_eq!(reader.state.cursor, 8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_quoted_template_error_missing_closing_quote() {
|
||||
let mut reader = Reader::init("\"not found");
|
||||
let error = quoted_template(&mut reader).err().unwrap();
|
||||
assert_eq!(
|
||||
error.pos,
|
||||
Pos {
|
||||
line: 1,
|
||||
column: 11
|
||||
}
|
||||
);
|
||||
assert!(!error.recoverable);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_quoted_string() {
|
||||
let mut reader = Reader::init("\"\"");
|
||||
|
Loading…
Reference in New Issue
Block a user