This commit is contained in:
JT 2021-09-06 06:44:18 +12:00
parent 6f17695891
commit 57677a50b5
3 changed files with 22 additions and 32 deletions

View File

@ -27,6 +27,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --all
- uses: actions-rs/cargo@v1
with:

View File

@ -18,7 +18,17 @@ fn convert_span_to_diag(
}
}
panic!("internal error: can't find span in parser state")
if span.start == working_set.next_span_start() {
// We're trying to highlight the space after the end
if let Some((file_id, (_, _, end))) = working_set.files().enumerate().last() {
return Ok((file_id, *end..(*end + 1)));
}
}
panic!(
"internal error: can't find span in parser state: {:?}",
span
)
}
pub fn report_parsing_error(

View File

@ -302,37 +302,6 @@ mod range {
}
}
#[test]
fn parse_left_unbounded_range() {
let engine_state = EngineState::new();
let mut working_set = StateWorkingSet::new(&engine_state);
let (block, err) = parse_source(&mut working_set, b"..10", true);
assert!(err.is_none());
assert!(block.len() == 1);
match &block[0] {
Statement::Pipeline(Pipeline { expressions }) => {
assert!(expressions.len() == 1);
assert!(matches!(
expressions[0],
Expression {
expr: Expr::Range(
None,
Some(_),
RangeOperator {
inclusion: RangeInclusion::Inclusive,
..
}
),
..
}
))
}
_ => panic!("No match"),
}
}
#[test]
fn parse_right_unbounded_range() {
let engine_state = EngineState::new();
@ -394,4 +363,14 @@ mod range {
_ => panic!("No match"),
}
}
#[test]
fn bad_parse_does_crash() {
let engine_state = EngineState::new();
let mut working_set = StateWorkingSet::new(&engine_state);
let (_, err) = parse_source(&mut working_set, b"(0)..\"a\"", true);
assert!(err.is_some());
}
}