Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/__tests__/gcode-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@
describe('parseCommand tokenizing', () => {
const parse = (line: string) => new Parser().parseCommand(line) as GCodeCommand;

// FAILING ON PURPOSE -- see #368.
// The tokenizer splits a word at every letter, so the `e` in an exponent is read as a
// separate E parameter. That is not merely lossy: Interpreter derives the path type
// from `e` (`e ? Extrusion : Travel`), so a travel move silently renders as extruded
// filament and inflates extrusionDistance.
//
// The expectation below is the fix in option 3 of #368 (recognize exponent notation in
// the tokenizer). If the team picks option 2 instead (reject a word whose value is
// followed by a valueless letter), change this to expect x to be absent. Either way the
// fabricated `e` must go.
test('reads exponent notation as a single value, not a value plus an E parameter', () => {
const cmd = parse('G1 X12e5 Y5');
expect(cmd.params).toEqual({ x: 1200000, y: 5 });

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.181.2, 0.181.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.173.0, 0.173.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.176.0, 0.176.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.179.1, 0.179.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.167.1, 0.167.2)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.183.2, 0.183.1)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.168.0, 0.168.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.178.0, 0.178.1)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.166.1, 0.166.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.184.0, 0.184.1)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.169.0, 0.169.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.174.0, 0.174.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.175.0, 0.175.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.171.0, 0.171.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.185.1, 0.185.4)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.182.0, 0.182.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.177.0, 0.177.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.170.0, 0.170.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.180.0, 0.180.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24

Check failure on line 155 in src/__tests__/gcode-parser.ts

View workflow job for this annotation

GitHub Actions / build (0.172.0, 0.172.0)

src/__tests__/gcode-parser.ts > parseCommand tokenizing > reads exponent notation as a single value, not a value plus an E parameter

AssertionError: expected { x: 12, e: 5, y: 5 } to deeply equal { x: 1200000, y: 5 } - Expected + Received { - "x": 1200000, + "e": 5, + "x": 12, "y": 5, } ❯ src/__tests__/gcode-parser.ts:155:24
});

test('reads a command and its parameters', () => {
const cmd = parse('G1 X100.5 Y-20 E0.04 F1200');
expect(cmd.gcode).toEqual('g1');
Expand Down
Loading