From faa9f2764ee5ec6c296a62b05b7e3a1b0f9e1d3b Mon Sep 17 00:00:00 2001 From: s9105947 <80697868+s9105947@users.noreply.github.com> Date: Tue, 22 Mar 2022 08:36:44 +0000 Subject: add test: comment content colliding with variable Currently, an implementation treating comments as undefined variables successfully passes all tests, because both undefined variables and comments render to empty string. This clarifies the behavior: A comment MUST NOT render into anything, under any circumstances. This includes the case where a variable with the same name as the comment content is defined. The test data is designed in a way to trigger any possible name collision, including white spaces, a leading exclamation mark (!). --- specs/comments.json | 12 ++++++++++++ specs/comments.yml | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/specs/comments.json b/specs/comments.json index 60a4929..924ed46 100644 --- a/specs/comments.json +++ b/specs/comments.json @@ -89,6 +89,18 @@ }, "template": "12345 {{! Comment Block! }} 67890", "expected": "12345 67890" + }, + { + "name": "Variable Name Collision", + "desc": "Comments must never render, even if variable with same name exists.", + "data": { + "! comment": 1, + "! comment ": 2, + "!comment": 3, + "comment": 4 + }, + "template": "comments never show: >{{! comment }}<", + "expected": "comments never show: ><" } ] } diff --git a/specs/comments.yml b/specs/comments.yml index 7b14c7f..3bad09f 100644 --- a/specs/comments.yml +++ b/specs/comments.yml @@ -101,3 +101,9 @@ tests: data: { } template: '12345 {{! Comment Block! }} 67890' expected: '12345 67890' + + - name: Variable Name Collision + desc: Comments must never render, even if variable with same name exists. + data: { '! comment': 1, '! comment ': 2, '!comment': 3, 'comment': 4} + template: 'comments never show: >{{! comment }}<' + expected: 'comments never show: ><' -- cgit v1.2.1