-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
TL;DR:
/// For some reason we were parsing the G90, then an empty G01 and the
/// actual G01.
#[test]
fn funny_bug_in_crate_example() {
let src = "G90 \n G01 X50.0 Y-10";
let expected = vec![
GCode::new(Mnemonic::General, 90.0, Span::PLACEHOLDER),
GCode::new(Mnemonic::General, 1.0, Span::PLACEHOLDER)
.with_argument(Word::new('X', 50.0, Span::PLACEHOLDER))
.with_argument(Word::new('Y', -10.0, Span::PLACEHOLDER)),
];
let got: Vec<_> = crate::parse(src).collect();
assert_eq!(got, expected);
}
Fails with
thread 'parser::tests::funny_bug_in_crate_example' panicked at 'assertion failed: `(left == right)`
left: `[GCode { mnemonic: General, number: 90.0, arguments: [], span: Span { start: 0, end: 3, line: 0 } }, GCode { mnemonic: General, number: 1.0, arguments: [], span: Span { start: 6, end: 9, line: 1 } }, GCode { mnemonic: General, number: 1.0, arguments: [Word { letter: 'X', value: 50.0, span: Span { start: 10, end: 15, line: 1 } }, Word { letter: 'Y', value: -10.0, span: Span { start: 16, end: 20, line: 1 } }], span: Span { start: 6, end: 9, line: 1 } }]`,
right: `[GCode { mnemonic: General, number: 90.0, arguments: [], span: <placeholder> }, GCode { mnemonic: General, number: 1.0, arguments: [Word { letter: 'X', value: 50.0, span: <placeholder> }, Word { letter: 'Y', value: -10.0, span: <placeholder> }], span: <placeholder> }]`', gcode/src/parser.rs:437:9
(note the G01 with no arguments in the middle)
Metadata
Metadata
Assignees
Labels
No labels