Skip to content

Commit

Permalink
Add reproduction for secondary bad behavior observed in #322. A `miss…
Browse files Browse the repository at this point in the history
…ing END-IF` should result in only the `Incomplete IF/END-IF statement` error, but it currently also erroneously results in the `Unterminated FOR-loop ('FOR __if_0')` error.
  • Loading branch information
jjhbw committed Aug 3, 2023
1 parent 5b76f27 commit 15e006d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/__tests__/__snapshots__/error_handling.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Incomplete conditional statement: missing END-IF 1`] = `
[
[Error: Incomplete IF/END-IF statement. Make sure each IF-statement has a corresponding END-IF command.],
[Error: Unterminated FOR-loop ('FOR __if_0'). Make sure each FOR loop has a corresponding END-FOR command.],
]
`;

exports[`Incomplete conditional statement: missing END-IF 2`] = `
[
[Error: Incomplete IF/END-IF statement. Make sure each IF-statement has a corresponding END-IF command.],
[Error: Unterminated FOR-loop ('FOR __if_0'). Make sure each FOR loop has a corresponding END-FOR command.],
]
`;

exports[`noSandbox custom ErrorHandler allows graceful handling of NullishCommandResultError 1`] = `
"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:cx2="http://schemas.microsoft.com/office/drawing/2015/10/21/chartex" xmlns:cx3="http://schemas.microsoft.com/office/drawing/2016/5/9/chartex" xmlns:cx4="http://schemas.microsoft.com/office/drawing/2016/5/10/chartex" xmlns:cx5="http://schemas.microsoft.com/office/drawing/2016/5/11/chartex" xmlns:cx6="http://schemas.microsoft.com/office/drawing/2016/5/12/chartex" xmlns:cx7="http://schemas.microsoft.com/office/drawing/2016/5/13/chartex" xmlns:cx8="http://schemas.microsoft.com/office/drawing/2016/5/14/chartex" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:aink="http://schemas.microsoft.com/office/drawing/2016/ink" xmlns:am3d="http://schemas.microsoft.com/office/drawing/2017/model3d" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 w15 w16se w16cid wp14">
Expand Down
7 changes: 4 additions & 3 deletions src/__tests__/error_handling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,11 @@ if (process.env.DEBUG) setDebugLogSink(console.log);
template,
data: {},
rejectNullish: true,

// We use failFast:false to ensure the error handling of a missing END-IF and missing END-FOR are not accidentally mixed, see Github issue #322.
failFast: false,
})
).rejects.toThrow(
'Incomplete IF/END-IF statement. Make sure each IF-statement has a corresponding END-IF command.'
);
).rejects.toMatchSnapshot();
});

it('Incomplete conditional statement: missing IF statement', async () => {
Expand Down

0 comments on commit 15e006d

Please sign in to comment.