6
6
import java .util .Map ;
7
7
import static org .javalite .common .Collections .*;
8
8
import static org .javalite .test .jspec .JSpec .*;
9
+ import org .junit .Ignore ;
9
10
10
11
/**
11
12
* @author Eric Nielsen
@@ -47,23 +48,23 @@ public void shouldParseBuiltIn() throws Exception {
47
48
}
48
49
49
50
@ Test
50
- public void shouldParseExpressionWithEq () throws Exception {
51
+ public void shouldParseIfTagWithEq () throws Exception {
51
52
ParentNode node = (ParentNode ) new TemplateParser ("<b><<#if(left==right)>tada</#if>></b>" ).parse ();
52
53
the (node .children .size ()).shouldBeEqual (3 );
53
54
the (process (node , map ("left" , "help!" , "right" , "help!" ))).shouldBeEqual ("<b><tada></b>" );
54
55
the (process (node , map ("left" , "help!" , "right" , "help?" ))).shouldBeEqual ("<b><></b>" );
55
56
}
56
57
57
58
@ Test
58
- public void shouldParseExpressionWithNotNeq () throws Exception {
59
+ public void shouldParseIfTagWithNotNeq () throws Exception {
59
60
ParentNode node = (ParentNode ) new TemplateParser ("<#if(!left!=right)>tada</#if>" ).parse ();
60
61
the (node .children .size ()).shouldBeEqual (1 );
61
62
the (process (node , map ("left" , 0 , "right" , 0 ))).shouldBeEqual ("tada" );
62
63
the (process (node , map ("left" , 0 , "right" , 1 ))).shouldBeEqual ("" );
63
64
}
64
65
65
66
@ Test
66
- public void shouldParseExpressionWithAndParensOr () throws Exception {
67
+ public void shouldParseIfTagWithAndParensOr () throws Exception {
67
68
ParentNode node = (ParentNode ) new TemplateParser (
68
69
"<#if (first > second && (first > third || third <= second))><b>%{first}</b></#if>" ).parse ();
69
70
the (node .children .size ()).shouldBeEqual (1 );
@@ -73,11 +74,26 @@ public void shouldParseExpressionWithAndParensOr() throws Exception {
73
74
}
74
75
75
76
@ Test
76
- public void shouldParseExpressionWithBoolean () throws Exception {
77
+ public void shouldParseIfTagWithBoolean () throws Exception {
77
78
ParentNode node = (ParentNode ) new TemplateParser ("<#if (foo)>bar</#if>" ).parse ();
78
79
the (node .children .size ()).shouldBeEqual (1 );
79
80
the (process (node , map ("foo" , true ))).shouldBeEqual ("bar" );
80
81
the (process (node , map ("foo" , false ))).shouldBeEqual ("" );
81
82
}
82
83
84
+ @ Test
85
+ public void shouldNotParseInvalidIfTagWithBoolean () throws Exception {
86
+ String source = "<#if (foo=)>bar</#if>" ;
87
+ ParentNode node = (ParentNode ) new TemplateParser (source ).parse ();
88
+ the (node .children .size ()).shouldBeEqual (1 );
89
+ the (process (node , map ())).shouldBeEqual (source );
90
+ }
91
+
92
+ @ Ignore
93
+ @ Test
94
+ public void shouldParseForTag () throws Exception {
95
+ ParentNode node = (ParentNode ) new TemplateParser ("<#for item:list> %{item} </#for>" ).parse ();
96
+ the (node .children .size ()).shouldBeEqual (1 );
97
+ the (process (node , map ("list" , list (1 , 2 , 3 )))).shouldBeEqual (" 1 2 3 " );
98
+ }
83
99
}
0 commit comments