Skip to content

Commit acb4668

Browse files
author
Igor Polevoy
committed
#209 Implement operators and two operands for IfTag
1 parent d8cae8e commit acb4668

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

javalite-templator/src/test/java/org/javalite/templator/TemplateSpec.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -302,26 +302,26 @@ public void shouldRejectWrongIncorrectOperator() {
302302
@Test
303303
public void shouldCompareNumbersWithLT() {
304304

305-
String source = "<html><#if two lt three> tada </#if></html>";
305+
String source = "<html><#if left lt right> tada </#if></html>";
306306
Template template = new Template(source);
307307
StringWriter w = new StringWriter();
308-
template.process(map("two", 2, "three", 3), w);
308+
template.process(map("left", 2, "right", 3), w);
309309
a(w.toString()).shouldBeEqual("<html> tada </html>");
310310

311-
source = "<html><#if three lt two> tada </#if></html>";
311+
source = "<html><#if left lt right> tada </#if></html>";
312312
template = new Template(source);
313313
w = new StringWriter();
314-
template.process(map("three", 3, "two", 2), w);
314+
template.process(map("left", 3, "right", 2), w);
315315
a(w.toString()).shouldBeEqual("<html></html>");
316316
}
317317

318318
@Test
319319
public void shouldCompareNumbersWithLTE() {
320320

321-
String source = "<html><#if three lt= three> tada </#if></html>";
321+
String source = "<html><#if left lt= right> tada </#if></html>";
322322
Template template = new Template(source);
323323
StringWriter w = new StringWriter();
324-
template.process(map("three", 3, "three", 3), w);
324+
template.process(map("left", 3, "right", 3), w);
325325
a(w.toString()).shouldBeEqual("<html> tada </html>");
326326
}
327327

@@ -343,74 +343,74 @@ public void shouldCompareNumbersWithGTE() {
343343
@Test
344344
public void shouldCompareNumbersWithGT() {
345345

346-
String source = "<html><#if three gt two> tada </#if></html>";
346+
String source = "<html><#if left gt right> tada </#if></html>";
347347
Template template = new Template(source);
348348
StringWriter w = new StringWriter();
349-
template.process(map("three", 3, "two", 2), w);
349+
template.process(map("left", 3, "right", 2), w);
350350
a(w.toString()).shouldBeEqual("<html> tada </html>");
351351

352-
source = "<html><#if two gt three> tada </#if></html>";
352+
source = "<html><#if left gt right> tada </#if></html>";
353353
template = new Template(source);
354354
w = new StringWriter();
355-
template.process(map("two", 2, "three", 3), w);
355+
template.process(map("left", 2, "right", 3), w);
356356
a(w.toString()).shouldBeEqual("<html></html>");
357357
}
358358

359359

360360
@Test
361361
public void shouldCompareObjectsWithEQ() {
362362

363-
String source = "<html><#if word1 == word2> tada </#if></html>";
363+
String source = "<html><#if left == right> tada </#if></html>";
364364
Template template = new Template(source);
365365
StringWriter w = new StringWriter();
366-
template.process(map("word1", "help", "word2", "help"), w);
366+
template.process(map("left", "help", "right", "help"), w);
367367
a(w.toString()).shouldBeEqual("<html> tada </html>");
368368

369369
w = new StringWriter();
370-
template.process(map("word1", "help!", "word2", "help?"), w);
370+
template.process(map("left", "help!", "right", "help?"), w);
371371
a(w.toString()).shouldBeEqual("<html></html>");
372372
}
373373

374374
@Test
375375
public void shouldCompareObjectsWithNEQ() {
376376

377-
String source = "<html><#if word1 != word2> tada </#if></html>";
377+
String source = "<html><#if left != right> tada </#if></html>";
378378
Template template = new Template(source);
379379
StringWriter w = new StringWriter();
380-
template.process(map("word1", "help!", "word2", "help?"), w);
380+
template.process(map("left", "help!", "right", "help?"), w);
381381
a(w.toString()).shouldBeEqual("<html> tada </html>");
382382

383383
w = new StringWriter();
384-
template.process(map("word1", "help", "word2", "help"), w);
384+
template.process(map("left", "help", "right", "help"), w);
385385
a(w.toString()).shouldBeEqual("<html></html>");
386386
}
387387

388388

389389
@Test
390390
public void shouldCompareBooleansWithOR() {
391391

392-
String source = "<html><#if cond1 || cond2> tada </#if></html>";
392+
String source = "<html><#if left || left> tada </#if></html>";
393393
Template template = new Template(source);
394394
StringWriter w = new StringWriter();
395-
template.process(map("cond1", true, "cond2", true), w);
395+
template.process(map("left", true, "left", true), w);
396396
a(w.toString()).shouldBeEqual("<html> tada </html>");
397397

398398
w = new StringWriter();
399-
template.process(map("cond1", true, "cond2", false), w);
399+
template.process(map("left", true, "right", false), w);
400400
a(w.toString()).shouldBeEqual("<html> tada </html>");
401401
}
402402

403403
@Test
404404
public void shouldCompareBooleansWithAND() {
405405

406-
String source = "<html><#if cond1 && cond2> tada </#if></html>";
406+
String source = "<html><#if left && right> tada </#if></html>";
407407
Template template = new Template(source);
408408
StringWriter w = new StringWriter();
409-
template.process(map("cond1", true, "cond2", true), w);
409+
template.process(map("left", true, "right", true), w);
410410
a(w.toString()).shouldBeEqual("<html> tada </html>");
411411

412412
w = new StringWriter();
413-
template.process(map("cond1", true, "cond2", false), w);
413+
template.process(map("left", true, "right", false), w);
414414
a(w.toString()).shouldBeEqual("<html></html>");
415415
}
416416

0 commit comments

Comments
 (0)