|
| 1 | +unit Sempare.Template.TestSupport; |
| 2 | +(*%************************************************************************************************* |
| 3 | + * ___ * |
| 4 | + * / __| ___ _ __ _ __ __ _ _ _ ___ * |
| 5 | + * \__ \ / -_) | ' \ | '_ \ / _` | | '_| / -_) * |
| 6 | + * |___/ \___| |_|_|_| | .__/ \__,_| |_| \___| * |
| 7 | + * |_| * |
| 8 | + **************************************************************************************************** |
| 9 | + * * |
| 10 | + * Sempare Template Engine * |
| 11 | + * * |
| 12 | + * * |
| 13 | + * https://github.com/sempare/sempare-delphi-template-engine * |
| 14 | + **************************************************************************************************** |
| 15 | + * * |
| 16 | + * Copyright (c) 2019-2025 Sempare Limited * |
| 17 | + * * |
| 18 | + * Contact: info@sempare.ltd * |
| 19 | + * * |
| 20 | + * Licensed under the Apache Version 2.0 or the Sempare Commercial License * |
| 21 | + * You may not use this file except in compliance with one of these Licenses. * |
| 22 | + * You may obtain a copy of the Licenses at * |
| 23 | + * * |
| 24 | + * https://www.apache.org/licenses/LICENSE-2.0 * |
| 25 | + * https://github.com/sempare/sempare-delphi-template-engine/blob/master/docs/commercial.license.md * |
| 26 | + * * |
| 27 | + * Unless required by applicable law or agreed to in writing, software * |
| 28 | + * distributed under the Licenses is distributed on an "AS IS" BASIS, * |
| 29 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * |
| 30 | + * See the License for the specific language governing permissions and * |
| 31 | + * limitations under the License. * |
| 32 | + * * |
| 33 | + *************************************************************************************************%*) |
| 34 | + |
| 35 | +interface |
| 36 | + |
| 37 | +uses |
| 38 | + DUnitX.TestFramework; |
| 39 | + |
| 40 | +type |
| 41 | + |
| 42 | + [TestFixture] |
| 43 | + TTestSupport = class |
| 44 | + public |
| 45 | + |
| 46 | + [Test] |
| 47 | + procedure TestSuspectedArrayNumbersNotHandledGHIssue219; |
| 48 | + |
| 49 | + end; |
| 50 | + |
| 51 | +implementation |
| 52 | + |
| 53 | +uses |
| 54 | + System.SysUtils, |
| 55 | + Sempare.Template; |
| 56 | + |
| 57 | +{ TTestSupport } |
| 58 | + |
| 59 | +procedure TTestSupport.TestSuspectedArrayNumbersNotHandledGHIssue219; |
| 60 | +var |
| 61 | + LTemplate: string; |
| 62 | + LResult: string; |
| 63 | + LExpected: string; |
| 64 | +begin |
| 65 | + LTemplate := // |
| 66 | + '<% arr := [4,5,6] %>' + sLineBreak + // |
| 67 | + sLineBreak + // |
| 68 | + '<%- for x of arr %>' + sLineBreak + // |
| 69 | + '<% x %>' + sLineBreak + // |
| 70 | + '<% end %>'; |
| 71 | + |
| 72 | + LExpected := // |
| 73 | + sLineBreak + // |
| 74 | + sLineBreak + // |
| 75 | + '4' + sLineBreak + // |
| 76 | + '5' + sLineBreak + // |
| 77 | + '6' + sLineBreak; // |
| 78 | + |
| 79 | + LResult := Template.Eval(LTemplate); |
| 80 | + |
| 81 | + Assert.AreEqual(LExpected, LResult); |
| 82 | + |
| 83 | + LTemplate := // |
| 84 | + '<% arr := [''4'',''5'',''6''] %>' + sLineBreak + // |
| 85 | + sLineBreak + // |
| 86 | + '<%- for x of arr %>' + sLineBreak + // |
| 87 | + '<% x %>' + sLineBreak + // |
| 88 | + '<% end %>'; |
| 89 | + |
| 90 | + LResult := Template.Eval(LTemplate); |
| 91 | + |
| 92 | + Assert.AreEqual(LExpected, LResult); |
| 93 | + |
| 94 | +end; |
| 95 | + |
| 96 | +initialization |
| 97 | + |
| 98 | +TDUnitX.RegisterTestFixture(TTestSupport); |
| 99 | + |
| 100 | +end. |
0 commit comments