Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Sempare.Template.Tester.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ uses
Sempare.Template.TestLexer in 'tests\Sempare.Template.TestLexer.pas',
Sempare.Template.TestFunctions in 'tests\Sempare.Template.TestFunctions.pas',
Sempare.Template.TestVirtualMethods in 'tests\Sempare.Template.TestVirtualMethods.pas',
Sempare.Template.TestMap in 'tests\Sempare.Template.TestMap.pas';
Sempare.Template.TestMap in 'tests\Sempare.Template.TestMap.pas',
Sempare.Template.TestSupport in 'tests\Sempare.Template.TestSupport.pas';

var
runner: ITestRunner;
Expand Down
2 changes: 2 additions & 0 deletions Sempare.Template.Tester.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<DCCReference Include="tests\Sempare.Template.TestFunctions.pas"/>
<DCCReference Include="tests\Sempare.Template.TestVirtualMethods.pas"/>
<DCCReference Include="tests\Sempare.Template.TestMap.pas"/>
<DCCReference Include="tests\Sempare.Template.TestSupport.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
Expand Down Expand Up @@ -187,6 +188,7 @@
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64x" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Android">False</Platform>
Expand Down
100 changes: 100 additions & 0 deletions tests/Sempare.Template.TestSupport.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
unit Sempare.Template.TestSupport;
(*%*************************************************************************************************
* ___ *
* / __| ___ _ __ _ __ __ _ _ _ ___ *
* \__ \ / -_) | ' \ | '_ \ / _` | | '_| / -_) *
* |___/ \___| |_|_|_| | .__/ \__,_| |_| \___| *
* |_| *
****************************************************************************************************
* *
* Sempare Template Engine *
* *
* *
* https://github.com/sempare/sempare-delphi-template-engine *
****************************************************************************************************
* *
* Copyright (c) 2019-2025 Sempare Limited *
* *
* Contact: [email protected] *
* *
* Licensed under the Apache Version 2.0 or the Sempare Commercial License *
* You may not use this file except in compliance with one of these Licenses. *
* You may obtain a copy of the Licenses at *
* *
* https://www.apache.org/licenses/LICENSE-2.0 *
* https://github.com/sempare/sempare-delphi-template-engine/blob/master/docs/commercial.license.md *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the Licenses is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
* *
*************************************************************************************************%*)

interface

uses
DUnitX.TestFramework;

type

[TestFixture]
TTestSupport = class
public

[Test]
procedure TestSuspectedArrayNumbersNotHandledGHIssue219;

end;

implementation

uses
System.SysUtils,
Sempare.Template;

{ TTestSupport }

procedure TTestSupport.TestSuspectedArrayNumbersNotHandledGHIssue219;
var
LTemplate: string;
LResult: string;
LExpected: string;
begin
LTemplate := //
'<% arr := [4,5,6] %>' + sLineBreak + //
sLineBreak + //
'<%- for x of arr %>' + sLineBreak + //
'<% x %>' + sLineBreak + //
'<% end %>';

LExpected := //
sLineBreak + //
sLineBreak + //
'4' + sLineBreak + //
'5' + sLineBreak + //
'6' + sLineBreak; //

LResult := Template.Eval(LTemplate);

Assert.AreEqual(LExpected, LResult);

LTemplate := //
'<% arr := [''4'',''5'',''6''] %>' + sLineBreak + //
sLineBreak + //
'<%- for x of arr %>' + sLineBreak + //
'<% x %>' + sLineBreak + //
'<% end %>';

LResult := Template.Eval(LTemplate);

Assert.AreEqual(LExpected, LResult);

end;

initialization

TDUnitX.RegisterTestFixture(TTestSupport);

end.