Skip to content

Commit 85c79f2

Browse files
committed
test: - Show the behaviour with self-referencing includes
1 parent 84331f8 commit 85c79f2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/Scripting/Includes.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,45 @@ describe('include - error messages', () => {
317317
`);
318318
});
319319
});
320+
321+
describe('infinite recursion of instruction', () => {
322+
const includes = makeIncludes(
323+
['self_reference_1', '{{includes.self_reference_1}}'],
324+
['self_reference_2', 'include self_reference_2'],
325+
);
326+
327+
it('includes placeholder should give meaningful error message about self-referencing instructions BUT DOES NOT', () => {
328+
const query = createQuery('{{includes.self_reference_1}}', includes);
329+
expect(query.error).toMatchInlineSnapshot(`
330+
"Could not interpret the following instruction as a Boolean combination:
331+
{{includes.self_reference_1}}
332+
333+
The error message is:
334+
couldn't parse sub-expression 'includes.self_reference_1'
335+
336+
The instruction was converted to the following simplified line:
337+
((f1))
338+
339+
Where the sub-expressions in the simplified line are:
340+
'f1': 'includes.self_reference_1'
341+
=> ERROR:
342+
do not understand query
343+
344+
For help, see:
345+
https://publish.obsidian.md/tasks/Queries/Combining+Filters
346+
347+
Problem line: "{{includes.self_reference_1}}""
348+
`);
349+
});
350+
351+
it('include instruction should give meaningful error message about self-referencing instructions BUT DOES NOT', () => {
352+
const query = createQuery('include self_reference_2', includes);
353+
expect(query.error).toMatchInlineSnapshot(`
354+
"Maximum call stack size exceeded
355+
Problem line: "include self_reference_2""
356+
`);
357+
});
358+
});
320359
});
321360

322361
describe('include settings tests', () => {

0 commit comments

Comments
 (0)