| | 165 | // without templates |
|---|
| | 166 | value = "foo"; |
|---|
| | 167 | expected = value; |
|---|
| | 168 | result = func(value); |
|---|
| | 169 | t.eq(result, expected, "(no template) preserves literal"); |
|---|
| | 170 | |
|---|
| | 171 | // with templates |
|---|
| | 172 | value = "${foo}" |
|---|
| | 173 | expected = "bar"; |
|---|
| | 174 | context = {foo: expected}; |
|---|
| | 175 | result = func(value, context); |
|---|
| | 176 | t.eq(result, expected, "(template) preserves literal"); |
|---|
| | 177 | |
|---|
| | 178 | expected = ""; |
|---|
| | 179 | context = {foo: expected}; |
|---|
| | 180 | result = func(value, context); |
|---|
| | 181 | t.eq(result, expected, "(template) preserves empty string"); |
|---|
| | 182 | |
|---|
| | 183 | expected = "16/03/2008"; |
|---|
| | 184 | context = {foo: expected}; |
|---|
| | 185 | result = func(value, context); |
|---|
| | 186 | t.eq(result, expected, "(template) preserves string with numbers"); |
|---|
| | 187 | |
|---|
| | 188 | expected = 16; |
|---|
| | 189 | context = {foo: expected + ""}; |
|---|
| | 190 | result = func(value, context); |
|---|
| | 191 | t.eq(result, expected, "(template) casts integer in a string"); |
|---|
| | 192 | |
|---|
| | 193 | expected = 16; |
|---|
| | 194 | context = {foo: " " + expected + " "}; |
|---|
| | 195 | result = func(value, context); |
|---|
| | 196 | t.eq(result, expected, "(template) casts integer in a space padded string"); |
|---|
| | 197 | |
|---|
| | 198 | } |
|---|
| | 199 | |
|---|