mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Fix #15
This commit is contained in:
parent
6f17695891
commit
57677a50b5
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -27,6 +27,7 @@ jobs:
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all
|
||||
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
|
@ -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(
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user