Skip to content

Commit 8d7dfa8

Browse files
committed
Add test for two commands in a row
1 parent b579d9d commit 8d7dfa8

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

gcode/src/parser.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,8 @@ mod tests {
429429

430430
#[test]
431431
fn implicit_command_after_newline() {
432-
let src = "G90 \n G01 X1.0 Y2.0\n X3.0 Y4.0";
432+
let src = "G01 X1.0 Y2.0\n X3.0 Y4.0";
433433
let expected = vec![
434-
GCode::new(Mnemonic::General, 90.0, Span::PLACEHOLDER),
435434
GCode::new(Mnemonic::General, 1.0, Span::PLACEHOLDER)
436435
.with_argument(Word::new('X', 1.0, Span::PLACEHOLDER))
437436
.with_argument(Word::new('Y', 2.0, Span::PLACEHOLDER)),
@@ -444,4 +443,23 @@ mod tests {
444443
assert_eq!(got, expected);
445444
}
446445

446+
#[test]
447+
// This test focuses on the G90 and M7 on the same line.
448+
fn two_commands_in_a_row() {
449+
let src = "G90 M7\nG01 X1.0 Y2.0\nX3.0 Y4.0";
450+
let expected = vec![
451+
GCode::new(Mnemonic::General, 90.0, Span::PLACEHOLDER),
452+
GCode::new(Mnemonic::Miscellaneous, 7.0, Span::PLACEHOLDER),
453+
GCode::new(Mnemonic::General, 1.0, Span::PLACEHOLDER)
454+
.with_argument(Word::new('X', 1.0, Span::PLACEHOLDER))
455+
.with_argument(Word::new('Y', 2.0, Span::PLACEHOLDER)),
456+
GCode::new(Mnemonic::General, 1.0, Span::PLACEHOLDER)
457+
.with_argument(Word::new('X', 3.0, Span::PLACEHOLDER))
458+
.with_argument(Word::new('Y', 4.0, Span::PLACEHOLDER)),
459+
];
460+
461+
let got: Vec<_> = crate::parse(src).collect();
462+
dbg!(&got);
463+
assert_eq!(got, expected);
464+
}
447465
}

0 commit comments

Comments
 (0)