http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/varargs.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/varargs.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/varargs.txt new file mode 100644 index 0000000..a310855 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/varargs.txt @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ + +0 == 0 +0 == 0 +11 == 11 +11 == 11 +1122 == 1122 +1122 == 1122 +112233 == 112233 +112233 == 112233 + +-22334411 == -22334411 +-223311 == -223311 +-2211 == -2211 +-11 == -11 + +0 == 0 +-11 == -11 +1122 == 1122 +-112233 == -112233 +-11223344 == -11223344 +-1122334455 == -1122334455 + +1122 == 1122 +-1122 == -1122 + +string, true, 123, 1000000 == string, true, 123, 1000000
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/variables.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/variables.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/variables.txt new file mode 100644 index 0000000..5365b07 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/variables.txt @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +<html> +<head> +<title>FreeMarker: Variable Test</title> +</head> +<body> + +<p>A simple test follows:</p> + +<p>Hello, world!</p> + +<p>Now get into variable nesting:</p> + +<p>My message.</p> +<p>My message.</p> +<p>My message.</p> +<p>My message.</p> +<p>My message.</p> +<p>My message.</p> +<p>My message.</p> +<p>My message.</p> + +<p>More deep nesting...</p> + +<p>My message.</p> +<p>one</p> +<p>one</p> + + +<p>Nesting inside nesting...</p> + +<p>two</p> +<p>two</p> +<p>two</p> +<p>two</p> + +<p>Test underscores...</p> + +<p>out</p> +<p>out</p> + +SAVE + +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/whitespace-trim.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/whitespace-trim.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/whitespace-trim.txt new file mode 100644 index 0000000..e74163a --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/whitespace-trim.txt @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +LB +LB +LB +LB + IB + IC1 IC2C1C2 ICS CS1 CS2 C3C1C2 +B +B +C1CB +C1 +C2 ICB + IC ICB + ICCB +-- +LB +LB +LB +LB + IB + IC1 IC2C1C2 ICS CS1 CS2 C3C1C2 +B +B +C1CB +C1 +C2 ICB + IC ICB + ICCB +-- + IB + IC1C2 IB +12 +--- +1 23 + 4 + 5 6 +--- +a +bc +--- +foo +--- +foo http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstrip-in-header.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstrip-in-header.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstrip-in-header.txt new file mode 100644 index 0000000..2cb2913 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstrip-in-header.txt @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +a + +b +a +b \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstripping.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstripping.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstripping.txt new file mode 100644 index 0000000..2aae297 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/wstripping.txt @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +a +b +c +d +e2 +f +g +x + x + x + y +y +x +y +x +y +a + x +b + x +c \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-fragment.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-fragment.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-fragment.txt new file mode 100644 index 0000000..cb0da5f --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-fragment.txt @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +b = b +@document = @document +@document = @document + +C<>&"']]> = C<>&"']]> + +<root xmlns:n="http://x"><a><b><n:c>C<>&"']]></n:c></b></a></root> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-ns_prefix-scope.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-ns_prefix-scope.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-ns_prefix-scope.txt new file mode 100644 index 0000000..bf8e6bd --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml-ns_prefix-scope.txt @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +//e: e in NS namespace-test, e in NS namespace-test +//n:e: e in NS foo, e in NS foo +//bar:e: e in NS bar, e in NS bar + +Included: +//n:e: e in NS foo, e in NS foo +//n:e: e in NS foo, e in NS foo + +Imported: +//n:e: e in NS bar, e in NS bar +//n:e: e in NS bar, e in NS bar http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml.txt new file mode 100644 index 0000000..718bba1 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xml.txt @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ + <?firstPi customKey="something"?> + firstPi + customKey="something" + <?secondPi secondPiData?> + secondPi + secondPiData +2 +p + customKey="something" + +<ns1:e11 xmlns:ns1="http://www.foo.com/ns1/">text1</ns1:e11><ns1:e11 xmlns:ns1="http://www.foo.com/ns1/">text2</ns1:e11> +<ns1:e12 xmlns:ns1="http://www.foo.com/ns1/"><![CDATA[cdata-section1]]></ns1:e12><ns1:e12 xmlns:ns1="http://www.foo.com/ns1/"><![CDATA[cdata-section2<&]]></ns1:e12> +<ns1:e1 xmlns:ns1="http://www.foo.com/ns1/" a1="v1" a2="v2"> + <ns1:e11>text1</ns1:e11> + <ns1:e12><![CDATA[cdata-section1]]></ns1:e12> + </ns1:e1> +<ns1:e11 xmlns:ns1="http://www.foo.com/ns1/">text1</ns1:e11><ns1:e11 xmlns:ns1="http://www.foo.com/ns1/">text2</ns1:e11> +a1 +v2 +rootroot +root + root + e1 + e11 + e12 + e2 + e11 + e12 + root + root + e1 + root + e1 + e11 + root + e1 + e12 + root + e2 + root + e2 + e11 + root + e2 + e12 +cdata-section2<& +cdata-section2<& http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns1.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns1.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns1.txt new file mode 100644 index 0000000..69af553 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns1.txt @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ + +<book xmlns="http://example.com/eBook"> + <title>Test Book</title> + <chapter> + <title>Ch1</title> + <para>p1.1</para> + <para>p1.2</para> + <para>p1.3</para> + </chapter> + <chapter> + <title>Ch2</title> + <para>p2.1</para> + <para>p2.2</para> + </chapter> +</book> + + <html> + <head> + <title>Test Book</title> + </head> + <body> + <h1>Test Book</h1> + + + <h2>Ch1</h2> + + + <p>p1.1 + + <p>p1.2 + + <p>p1.3 + + + <h2>Ch2</h2> + + + <p>p2.1 + + <p>p2.2 + + + </body> + </html> + http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns3.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns3.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns3.txt new file mode 100644 index 0000000..f028f0a --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns3.txt @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ + <html> + <head> + <title>Test Book</title> + </head> + <body> + <h1>Test Book</h1> + + + <h2>Ch1</h2> + + + <p>p1.1 + + <p>p1.2 + + <p>p1.3 + + + <h2>Ch2</h2> + + + <p>p2.1 + + <p>p2.2 + + + </body> + </html> + http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns4.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns4.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns4.txt new file mode 100644 index 0000000..f028f0a --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns4.txt @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ + <html> + <head> + <title>Test Book</title> + </head> + <body> + <h1>Test Book</h1> + + + <h2>Ch1</h2> + + + <p>p1.1 + + <p>p1.2 + + <p>p1.3 + + + <h2>Ch2</h2> + + + <p>p2.1 + + <p>p2.2 + + + </body> + </html> + http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns5.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns5.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns5.txt new file mode 100644 index 0000000..6e42b09 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/expected/xmlns5.txt @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License 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. + */ +No NS = No NS +x NS = x NS +y NS = y NS +x NS = x NS +No NS = No NS +- = - +- = - +- = - http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/BeansTestResources.properties ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/BeansTestResources.properties b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/BeansTestResources.properties new file mode 100644 index 0000000..609e20b --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/BeansTestResources.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License 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. + +message=Message +format={0,date,yyyy-MM-dd} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/defaultxmlns1.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/defaultxmlns1.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/defaultxmlns1.xml new file mode 100644 index 0000000..ed289bb --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/defaultxmlns1.xml @@ -0,0 +1,24 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<root xmlns:x="http://x.com" xmlns:y="http://y.com"> + <t1>No NS</t1> + <x:t2>x NS</x:t2> + <y:t3>y NS</y:t3> + <t4 xmlns="http://x.com">x NS</t4> +</root> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml-ns_prefix-scope.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml-ns_prefix-scope.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml-ns_prefix-scope.xml new file mode 100644 index 0000000..934acac --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml-ns_prefix-scope.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<root xmlns="http://freemarker.org/test/namespace-test" + xmlns:foo="http://freemarker.org/test/foo" + xmlns:bar="http://freemarker.org/test/bar"> + <e>e in NS namespace-test</e> + <foo:e>e in NS foo</foo:e> + <bar:e>e in NS bar</bar:e> +</root> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml.xml new file mode 100644 index 0000000..abf7e96 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xml.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<?firstPi customKey="something"?> +<?secondPi secondPiData?> +<ns1:root xmlns:ns1="http://www.foo.com/ns1/"> + <ns1:e1 a1="v1" a2="v2"> + <ns1:e11>text1</ns1:e11> + <ns1:e12><![CDATA[cdata-section1]]></ns1:e12> + </ns1:e1> + <ns1:e2> + <ns1:e11>text2</ns1:e11> + <ns1:e12><![CDATA[cdata-section2<&]]></ns1:e12> + </ns1:e2> +</ns1:root> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlfragment.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlfragment.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlfragment.xml new file mode 100644 index 0000000..b5578b6 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlfragment.xml @@ -0,0 +1,19 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<root><a><b><c xmlns="http://x">C<>&"']]></c></b></a></root> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns.xml new file mode 100644 index 0000000..6f6453e --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns.xml @@ -0,0 +1,32 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<book xmlns="http://example.com/eBook"> + <title>Test Book</title> + <chapter> + <title>Ch1</title> + <para>p1.1</para> + <para>p1.2</para> + <para>p1.3</para> + </chapter> + <chapter> + <title>Ch2</title> + <para>p2.1</para> + <para>p2.2</para> + </chapter> +</book> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns2.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns2.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns2.xml new file mode 100644 index 0000000..c8bfc9f --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns2.xml @@ -0,0 +1,32 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<eb:book xmlns:eb="http://example.com/eBook"> + <eb:title>Test Book</eb:title> + <eb:chapter> + <eb:title>Ch1</eb:title> + <eb:para>p1.1</eb:para> + <eb:para>p1.2</eb:para> + <eb:para>p1.3</eb:para> + </eb:chapter> + <eb:chapter> + <eb:title>Ch2</eb:title> + <eb:para>p2.1</eb:para> + <eb:para>p2.2</eb:para> + </eb:chapter> +</eb:book> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns3.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns3.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns3.xml new file mode 100644 index 0000000..8502ead --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/models/xmlns3.xml @@ -0,0 +1,32 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<book xmlns:x="http://x" xmlns:y="http://y"> + <x:title>Test Book</x:title> + <chapter> + <y:title>Ch1</y:title> + <para>p1.1</para> + <para>p1.2</para> + <para>p1.3</para> + </chapter> + <x:chapter> + <y:title>Ch2</y:title> + <x:para>p2.1</x:para> + <y:para>p2.2</y:para> + </x:chapter> +</book> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/api-builtins.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/api-builtins.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/api-builtins.ftl new file mode 100644 index 0000000..5a9e2d7 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/api-builtins.ftl @@ -0,0 +1,40 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<@assertEquals expected="b" actual=map?api.get(2?int) /> +<@assertEquals expected=2 actual=list?api.indexOf(3?int) /> +<@assert test=set?api.contains("b") /> +<@assert test=!set?api.contains("d") /> + +<#assign dump = ""> +<#list map?api.entrySet() as entry> + <#assign dump = dump + entry.key + ": " + entry.value> + <#if entry_has_next> + <#assign dump = dump + ", "> + </#if> +</#list> +<@assertEquals expected="1: a, 2: b, 3: c" actual=dump /> + +<@assert test=map?has_api /> +<@assert test=list?has_api /> +<@assert test=set?has_api /> +<@assert test=!s?has_api /> +<@assert test=!1?has_api /> +<@assert test=!""?has_api /> +<@assert test=!{}?has_api /> +<@assert test=!true?has_api /> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/arithmetic.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/arithmetic.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/arithmetic.ftl new file mode 100644 index 0000000..afd4c28 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/arithmetic.ftl @@ -0,0 +1,50 @@ +[#ftl] +[#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--] +<html> +<head> +<title>FreeMarker: Arithmetic Test</title> +</head> +<body> +[#assign foo = 1234, bar = 23.77] + +<p>A simple test follows:</p> + +<p>Perform a number assignment:</p> + +[#setting locale="en_US"][#assign x = 1.2345, y=2] + +#{ x+y ; m2M3} +#{ y ; m2M3} +#{ x/y ; m40M40} +#{y/x} +#{ y/x ; M4} + +<P>Display a number with at least 3 digits after the decimal point</P> + +#{foo ; m3} + +<p>Now use numbers in assignment</p> + +[#assign mynumber = foo + bar [#-- a comment --] ] + +#{mynumber} + +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/assignments.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/assignments.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/assignments.ftl new file mode 100644 index 0000000..f9f546d --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/assignments.ftl @@ -0,0 +1,108 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<#assign x = 1> +<@assertEquals expected=1 actual=x /> +<#assign x = x + 1> +<@assertEquals expected=2 actual=x /> +<#assign x += 1> +<@assertEquals expected=3 actual=x /> +<#assign x /= 2> +<@assertEquals expected=1.5 actual=x /> +<#assign x *= 2> +<@assertEquals expected=3 actual=x /> +<#assign x %= 2> +<@assertEquals expected=1 actual=x /> +<#assign x += x x += x x += x> +<@assertEquals expected=8 actual=x /> +<#assign x += x, x += x, x += x> +<@assertEquals expected=64 actual=x /> +<#assign x++> +<@assertEquals expected=65 actual=x /> +<#assign x--> +<@assertEquals expected=64 actual=x /> +<#assign x--, x--, x--, x++, x -= 60> +<@assertEquals expected=2 actual=x /> + +<#assign x = 'a'> +<#assign x += 1> +<@assertEquals expected='a1' actual=x /> + +<#assign x = 1> +<#assign x += 'a'> +<@assertEquals expected='1a' actual=x /> + +<#assign x = [11]> +<#assign x += [22]> +<@assertEquals expected=11 actual=x[0] /> +<@assertEquals expected=22 actual=x[1] /> +<@assertEquals expected=2 actual=x?size /> + +<#assign x = { 'a': 11 }> +<#assign x += { 'b': 22 }> +<@assertEquals expected=11 actual=x.a /> +<@assertEquals expected=22 actual=x.b /> +<@assertEquals expected=2 actual=x?size /> + +<#assign x = 1> +<#global g = 11> +<#global g -= x> +<@assertEquals expected=10 actual=g /> +<#global g *= 2> +<@assertEquals expected=20 actual=g /> +<#global g /= 2.5> +<@assertEquals expected=8 actual=g /> +<#global g += 2> +<@assertEquals expected=10 actual=g /> +<#global g++> +<@assertEquals expected=11 actual=g /> +<#global g--> +<@assertEquals expected=10 actual=g /> + +<#macro m> + <#local v = x + g> + <@assertEquals expected=11 actual=v /> + <#local v -= x> + <@assertEquals expected=10 actual=v /> + <#local v *= 2> + <@assertEquals expected=20 actual=v /> + <#local v /= 2.5> + <@assertEquals expected=8 actual=v /> + <#local v += 2> + <@assertEquals expected=10 actual=v /> + <#local v++> + <@assertEquals expected=11 actual=v /> + <#local v--> + <@assertEquals expected=10 actual=v /> +</#macro> +<@m /> + +<#assign foo = 'a'> +<@assertFails messageRegexp=r".*expected.*number.*assignment.*foo.*string.*"><#assign foo -= 1></@> +<@assertFails messageRegexp=r".*expected.*number.*assignment.*foo.*string.*"><#assign foo++></@> +<@assertFails messageRegexp=r".*expected.*number.*assignment.*foo.*string.*"><#assign foo--></@> +<#assign x = 1> +<@assertFails messageRegexp=r"(?s).*expected.*number.*string.*'a'.*"><#assign x -= 'a'></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*-=.*"><#assign noSuchVar -= 1></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*\+=.*"><#assign noSuchVar += 1></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*\*=.*"><#assign noSuchVar *= 1></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*/=.*"><#assign noSuchVar /= 1></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*%=.*"><#assign noSuchVar %= 1></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*\+\+.*"><#assign noSuchVar++></@> +<@assertFails messageRegexp=r"(?s).*assignment.*noSuchVar.*missing.*--.*"><#assign noSuchVar--></@> +<@assertFails messageRegexp=r'(?s).*assignment.*noSuchVar.*missing.*\+=.*"\$".*'><#assign $noSuchVar += 1></@> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean-formatting.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean-formatting.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean-formatting.ftl new file mode 100644 index 0000000..a521fe8 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean-formatting.ftl @@ -0,0 +1,82 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<#assign suppress> +<@assertFails message="true,false">${true}</@> +<@assertFails message="true,false">${false}</@> +<@assertFails message="true,false">${"" + true}</@> +<@assertFails message="true,false">${"" + false}</@> +<@assertFails message="true,false">${true?upper_case}</@> +<@assertFails message="true,false">${false?upper_case}</@> +<@assertEquals expected="true" actual=true?string /> +<@assertEquals expected="false" actual=false?string /> +<@assertEquals expected="true" actual=true?c /> +<@assertEquals expected="false" actual=false?c /> +<@assertEquals expected="t" actual=true?string('t', 'f') /> +<@assertEquals expected="f" actual=false?string('t', 'f') /> +<#setting boolean_format = 'true,false'> +<@assertFails message="true,false">${true}</@> + +<#setting boolean_format = 'ja,nein'> +<@assertEquals expected="ja" actual="" + true /> +<@assertEquals expected="nein" actual="" + false /> +<@assertEquals expected="JA" actual=true?upper_case /> +<@assertEquals expected="NEIN" actual=false?upper_case /> +<@assertEquals expected="ja" actual=true?string /> +<@assertEquals expected="nein" actual=false?string /> +<@assertEquals expected="true" actual=true?c /> +<@assertEquals expected="false" actual=false?c /> +<@assertEquals expected="t" actual=true?string('t', 'f') /> +<@assertEquals expected="f" actual=false?string('t', 'f') /> + +<#setting boolean_format = 'y,n'> +<#assign x = false> +<#assign n = 123><#assign m = { x: 'foo', n: 'bar' }><@assertEquals actual=m['n'] + m['123'] expected='foobar' /> +<@assertFails exception="UnexpectedTypeException">${m[false]}</@> +<@assertFails message="can't compare">${x == 'false'}</@> +<@assertFails message="can't compare">${x != 'false'}</@> +<@assertFails message="can't convert">${booleanVsStringMethods.expectsString(x)}</@> +<@assertEquals actual=booleanVsStringMethods.expectsString(booleanAndString) expected="theStringValue" /> +<@assertEquals actual=booleanVsStringMethods.expectsBoolean(x) expected=false /> +<@assertEquals actual=booleanVsStringMethods.expectsBoolean(booleanAndString) expected=true /> +<@assertEquals actual=booleanVsStringMethods.overloaded(x) expected="boolean false" /> +<@assertEquals actual=123?upper_case expected="123" /> +<@assertEquals actual=true?upper_case expected="Y" /> + +</#assign> +<#escape x as x?upper_case> +<#assign x = true>${x} ${true} ${true?string} +<#assign x = false>${x} ${false} ${false?string} +<#noescape><#assign x = true>${x} ${true} ${true?string}</#noescape> +</#escape> +<#assign x = false>${x} ${false} ${false?string} +<#assign x = true>${x} ${true} ${true?string} +<#assign x = false>${x} ${false} ${false?string} +${'str:' + x} ${'str:' + false} +${x?string('ja', 'nein')} ${true?string('ja', 'nein')} +${booleanAndString} ${booleanAndString?string} + +<#setting boolean_format = 'y,n'> +<@assertEquals actual='true'?boolean expected=true /> +<@assertEquals actual='false'?boolean expected=false /> +<@assertEquals actual='y'?boolean expected=true /> +<@assertEquals actual='n'?boolean expected=false /> +<@assertFails message="can't convert">${'N'?boolean}</@> +<@assertFails message="can't convert">${'True'?boolean}</@> +<@assertFails message="can't convert">${0?boolean}</@> +<@assertFails message="sequence">${[]?boolean}</@> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean.ftl new file mode 100644 index 0000000..ab11c64 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/boolean.ftl @@ -0,0 +1,142 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<html> +<head> +<title>FreeMarker: Boolean Values Test</title> +</head> +<body> + +<p>A simple test follows:</p> + +<p>${message}</p> + +<#assign b=true> + +<p>Now perform scalar boolean tests:</p> + +<p><#if b> + b is true.<br /> +<#else> + b is false.<br /> +</#if></p> + +<p><#if false> + This can't be!<br /> +<#else> + This makes sense.<br /> +</#if></p> + +<p><#if boolean3> + boolean3 succeeded.<br /> +<#else> + boolean3 failed.<br /> +</#if></p> + +<p><#if boolean4> + boolean4 succeeded.<br /> +<#else> + boolean4 failed.<br /> +</#if></p> + +<p><#if boolean4 || boolean5> + boolean4 || boolean5 succeeded.<br /> +<#else> + boolean4 || boolean5 failed.<br /> +</#if></p> + +<p><#if boolean5 || boolean4 || boolean5> + boolean5 || boolean4 || boolean5 succeeded.<br /> +<#else> + boolean5 || boolean4 || boolean5 failed.<br /> +</#if></p> + +<p><#if boolean4 && boolean5> + boolean4 && boolean5 succeeded.<br /> +<#else> + boolean4 && boolean5 failed.<br /> +</#if></p> + +<p>Now test list models:</p> + +<p><#if list1?exists> + list1 succeeded.<br /> +<#else> + list1 failed.<br /> +</#if></p> + +<p><#if list2?exists> + list2 succeeded.<br /> +<#else> + list2 failed.<br /> +</#if></p> + +<p>Test hash models:</p> + +<p><#if hash1?exists> + hash1 succeeded: ${hash1.temp}<br /> +<#else> + hash1 failed: ${hash1.temp}<br /> +</#if></p> + +<p><#if hash2?exists> + hash2 succeeded.<br /> +<#else> + hash2 failed.<br /> +</#if></p> + +<p>Test not operator:</p> + +<p><#if ! boolean1> + Not boolean1 succeeded +<#else> + Not boolean1 failed +</#if></p> + +<p><#if !boolean1> + Not boolean1 succeeded +<#else> + Not boolean1 failed +</#if></p> + +<p><#if ! boolean2> + Not boolean2 succeeded +<#else> + Not boolean2 failed +</#if></p> + +<p><#if !boolean2> + Not boolean2 succeeded +<#else> + Not boolean2 failed +</#if></p> + +<p><#if message == "Hello, world!"> + Message is "Hello, world!" +<#else> + Message is something else (${message}) +</#if></p> + +<p><#if message != "Hello, world!"> + Message is not "Hello, world!" -- it's ${message} +<#else> + Message is "Hello, world!" +</#if></p> + +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header.ftl new file mode 100644 index 0000000..638f4b9 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header.ftl @@ -0,0 +1,27 @@ +<#ftl encoding="ISO-8859-2"> +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<head> + <meta http-equiv="Content-type" content="text/html; charset=UTF-8"> +</head> +<body> +���� +<#include "charset-in-header_inc1.ftl"> +<#include "charset-in-header_inc2.ftl"> +</body> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc1.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc1.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc1.ftl new file mode 100644 index 0000000..b8dc608 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc1.ftl @@ -0,0 +1,20 @@ +<#ftl encoding="ISO-8859-1"> +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +���� http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc2.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc2.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc2.ftl new file mode 100644 index 0000000..66100ec --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/charset-in-header_inc2.ftl @@ -0,0 +1,19 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +ÅÅűŰ http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comment.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comment.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comment.ftl new file mode 100644 index 0000000..9c47168 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comment.ftl @@ -0,0 +1,50 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<html> +<head> +<title>FreeMarker: Comment Test</title> +</head> +<body> +<#-- + +A simple test follows: + +${message} + +A more rigorous test, showing that we're not faking it: + +${message@#$%&} + +--><#-- > --><#-- -> --><#-- -- --><#-- -- > --> +<#if message?exists> + <p>Message exists! + <#-- + ...and even generates output! + --> + </p> +</#if> + +a <#-- < --> b +a <#-- </#noparse> - -- --> b + +${1 + 2 + [#-- c --] <#-- c --> <!-- c --> 3} +${<!-- > -> -- #> #] --> 7} +${<#-- glitch... --] 8} +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comparisons.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comparisons.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comparisons.ftl new file mode 100644 index 0000000..a711d4d --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/comparisons.ftl @@ -0,0 +1,218 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<html> +<head> +<title>FreeMarker: Numeric Operations Test</title> +</head> +<body> + +<p>A simple test follows:</p> + +<p>${message}</p> + +<p>Start with the increment operator:</p> +<#assign a1 = 0> +<p>a1 = ${a1}</p> +<#assign a1 = a1 + 1> +<p>a1 = ${a1}</p> +<#assign a1 = a1 + 1> +<p>a1 = ${a1}</p> + +<p>Now the decrement operator:</p> +<#assign a2 = 5> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> +<p>a2 = ${a2}</p> +<#assign a2 = a2 - 1> + +<p>Now the add operator:</p> +<#assign op1 = 5> +<#assign op2 = 3> +<#assign op3 = op1 + op2> +<p>op1 = ${op1}, op2 = ${op2}, op3 = ${op3}</p> +<#assign op3 = op3 + op2> +<p>op3 = ${op3}</p> + +<p>And the subtract operator:</p> +<#assign op3 = op1 - op2 > +<p>op1 = ${op1}, op2 = ${op2}, op3 = ${op3}</p> +<#assign op3 = op3 - op2 > +<p>op3 = ${op3}</p> + +<p>The comparison operators:</p> +<#assign list1 = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]> +<#list list1 as item> + <p>Item is: ${item}</p> + <#if item lt 5> + <p>Item is less than five.</p> + </#if> + <#if item <= 7> + <p>Item is less than or equals to seven.</p> + </#if> + <#if item gt 2> + <p>Item is greater than two.</p> + </#if> + <#if (item >= 10)> + <p>Item is greater than or equal to ten.</p> + </#if> +</#list> + +<#-- Signum-based optimization test, all 9 permutations: --> +<#-- 1 --> +<@assert test= !(0 != 0) /> +<@assert test= (0 == 0) /> +<@assert test= !(0 > 0) /> +<@assert test= (0 >= 0) /> +<@assert test= !(0 < 0) /> +<@assert test= (0 <= 0) /> +<#-- 2 --> +<@assert test= !(3 != 3) /> +<@assert test= (3 == 3) /> +<@assert test= !(3 > 3) /> +<@assert test= (3 >= 3) /> +<@assert test= !(3 < 3) /> +<@assert test= (3 <= 3) /> +<#-- 3 --> +<@assert test= !(-3 != -3) /> +<@assert test= (-3 == -3) /> +<@assert test= !(-3 > -3) /> +<@assert test= (-3 >= -3) /> +<@assert test= !(-3 < -3) /> +<@assert test= (-3 <= -3) /> +<#-- 4 --> +<@assert test= (3 != 0) /> +<@assert test= !(3 == 0) /> +<@assert test= (3 > 0) /> +<@assert test= (3 >= 0) /> +<@assert test= !(3 < 0) /> +<@assert test= !(3 <= 0) /> +<#-- 5 --> +<@assert test= (0 != 3) /> +<@assert test= !(0 == 3) /> +<@assert test= !(0 > 3) /> +<@assert test= !(0 >= 3) /> +<@assert test= (0 < 3) /> +<@assert test= (0 <= 3) /> +<#-- 6 --> +<@assert test= (-3 != 0) /> +<@assert test= !(-3 == 0) /> +<@assert test= !(-3 > 0) /> +<@assert test= !(-3 >= 0) /> +<@assert test= (-3 < 0) /> +<@assert test= (-3 <= 0) /> +<#-- 7 --> +<@assert test= (0 != -3) /> +<@assert test= !(0 == -3) /> +<@assert test= (0 > -3) /> +<@assert test= (0 >= -3) /> +<@assert test= !(0 < -3) /> +<@assert test= !(0 <= -3) /> +<#-- 8 --> +<@assert test= (-3 != 3) /> +<@assert test= !(-3 == 3) /> +<@assert test= !(-3 > 3) /> +<@assert test= !(-3 >= 3) /> +<@assert test= (-3 < 3) /> +<@assert test= (-3 <= 3) /> +<#-- 9 --> +<@assert test= (3 != -3) /> +<@assert test= !(3 == -3) /> +<@assert test= (3 > -3) /> +<@assert test= (3 >= -3) /> +<@assert test= !(3 < -3) /> +<@assert test= !(3 <= -3) /> +<#-- Again, now on runtime: --> +<#assign m3 = -3> +<#assign p3 = 3> +<#assign z = 0> +<#-- 1 --> +<@assert test= !(z != z) /> +<@assert test= (z == z) /> +<@assert test= !(z > z) /> +<@assert test= (z >= z) /> +<@assert test= !(z < z) /> +<@assert test= (z <= z) /> +<#-- 2 --> +<@assert test= !(p3 != p3) /> +<@assert test= (p3 == p3) /> +<@assert test= !(p3 > p3) /> +<@assert test= (p3 >= p3) /> +<@assert test= !(p3 < p3) /> +<@assert test= (p3 <= p3) /> +<#-- 3 --> +<@assert test= !(m3 != m3) /> +<@assert test= (m3 == m3) /> +<@assert test= !(m3 > m3) /> +<@assert test= (m3 >= m3) /> +<@assert test= !(m3 < m3) /> +<@assert test= (m3 <= m3) /> +<#-- 4 --> +<@assert test= (p3 != z) /> +<@assert test= !(p3 == z) /> +<@assert test= (p3 > z) /> +<@assert test= (p3 >= z) /> +<@assert test= !(p3 < z) /> +<@assert test= !(p3 <= z) /> +<#-- 5 --> +<@assert test= (z != p3) /> +<@assert test= !(z == p3) /> +<@assert test= !(z > p3) /> +<@assert test= !(z >= p3) /> +<@assert test= (z < p3) /> +<@assert test= (z <= p3) /> +<#-- 6 --> +<@assert test= (m3 != z) /> +<@assert test= !(m3 == z) /> +<@assert test= !(m3 > z) /> +<@assert test= !(m3 >= z) /> +<@assert test= (m3 < z) /> +<@assert test= (m3 <= z) /> +<#-- 7 --> +<@assert test= (z != m3) /> +<@assert test= !(z == m3) /> +<@assert test= (z > m3) /> +<@assert test= (z >= m3) /> +<@assert test= !(z < m3) /> +<@assert test= !(z <= m3) /> +<#-- 8 --> +<@assert test= (m3 != p3) /> +<@assert test= !(m3 == p3) /> +<@assert test= !(m3 > p3) /> +<@assert test= !(m3 >= p3) /> +<@assert test= (m3 < p3) /> +<@assert test= (m3 <= p3) /> +<#-- 9 --> +<@assert test= (p3 != m3) /> +<@assert test= !(p3 == m3) /> +<@assert test= (p3 > m3) /> +<@assert test= (p3 >= m3) /> +<@assert test= !(p3 < m3) /> +<@assert test= !(p3 <= m3) /> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/compress.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/compress.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/compress.ftl new file mode 100644 index 0000000..faf4ad6 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/compress.ftl @@ -0,0 +1,59 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<html> +<head> +<title>FreeMarker: Compress Test</title> +</head> +<body> + +<#assign utility={'standardCompress': "org.apache.freemarker.core.util.StandardCompress"?new()}> +<p>A simple test follows:</p> + +<p>${message}</p> + +<#compress> + + <p>This is the same message, using the "compress" tag:</p> + + +<p>${message}</p> +</#compress> + +<@utility.standardCompress buffer_size=8> + + <p>This is the same message, using the "StandardCompress" transform model:</p> + + +<p>${message}</p> +</@> + +<@utility.standardCompress single_line=true> + +<p>This + multi-line message + should +be compressed + to a single line.</p></@> + +<p>An example where the first character is not whitespace but the second character is:</p> +<p><#compress>x y</#compress></p> + +<p>The end.</p> +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/date-type-builtins.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/date-type-builtins.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/date-type-builtins.ftl new file mode 100644 index 0000000..f05654b --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/date-type-builtins.ftl @@ -0,0 +1,47 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<#setting time_zone = "UTC"> + +<@assert test=unknown?is_unknown_date_like /> +<@assert test=!timeOnly?is_unknown_date_like /> +<@assert test=!dateOnly?is_unknown_date_like /> +<@assert test=!dateTime?is_unknown_date_like /> + +<@assert test=!unknown?is_date_only /> +<@assert test=!timeOnly?is_date_only /> +<@assert test=dateOnly?is_date_only /> +<@assert test=!dateTime?is_date_only /> + +<@assert test=!unknown?is_time /> +<@assert test=timeOnly?is_time /> +<@assert test=!dateOnly?is_time /> +<@assert test=!dateTime?is_time /> + +<@assert test=!unknown?is_datetime /> +<@assert test=!timeOnly?is_datetime /> +<@assert test=!dateOnly?is_datetime /> +<@assert test=dateTime?is_datetime /> + +<@assertFails message="isn't known if">${unknown?string.xs}</@> +<@assertEquals expected="2003-04-05T06:07:08Z" actual=unknown?datetime_if_unknown?string.xs /> +<@assertEquals expected="2003-04-05Z" actual=unknown?date_if_unknown?string.xs /> +<@assertEquals expected="06:07:08Z" actual=unknown?time_if_unknown?string.xs /> +<@assertEquals expected="2003-04-05T06:07:08Z" actual=dateTime?date_if_unknown?string.xs /> +<@assertEquals expected="2003-04-05" actual=dateOnly?time_if_unknown?string.xs /> +<@assertEquals expected="06:07:08" actual=timeOnly?date_if_unknown?string.xs /> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4b75ea93/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/dateformat-iso-bi.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/dateformat-iso-bi.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/dateformat-iso-bi.ftl new file mode 100644 index 0000000..85fb028 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/dateformat-iso-bi.ftl @@ -0,0 +1,163 @@ +<#-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License 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. +--> +<#assign d = "2010-05-15 22:38:05:23 +0200"?datetime("yyyy-MM-dd HH:mm:ss:S Z")> +<#setting time_zone="GMT+02"> +<@assertEquals actual=d?iso_utc expected="2010-05-15T20:38:05Z" /> +<@assertEquals actual=d?iso_utc_ms expected="2010-05-15T20:38:05.023Z" /> +<@assertEquals actual=d?iso_utc_m expected="2010-05-15T20:38Z" /> +<@assertEquals actual=d?iso_utc_h expected="2010-05-15T20Z" /> +<@assertEquals actual=d?iso_utc_nz expected="2010-05-15T20:38:05" /> +<@assertEquals actual=d?iso_utc_ms_nz expected="2010-05-15T20:38:05.023" /> +<@assertEquals actual=d?iso_utc_m_nz expected="2010-05-15T20:38" /> +<@assertEquals actual=d?iso_utc_h_nz expected="2010-05-15T20" /> +<@assertEquals actual=d?iso_local expected="2010-05-15T22:38:05+02:00" /> +<@assertEquals actual=d?iso_local_ms expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?iso_local_m expected="2010-05-15T22:38+02:00" /> +<@assertEquals actual=d?iso_local_h expected="2010-05-15T22+02:00" /> +<@assertEquals actual=d?iso_local_nz expected="2010-05-15T22:38:05" /> +<@assertEquals actual=d?iso_local_ms_nz expected="2010-05-15T22:38:05.023" /> +<@assertEquals actual=d?iso_local_m_nz expected="2010-05-15T22:38" /> +<@assertEquals actual=d?iso_local_h_nz expected="2010-05-15T22" /> + +<@assertEquals actual=d?date?iso_utc expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_ms expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_m expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_h expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_ms_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_m_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_utc_h_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_ms expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_m expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_h expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_ms_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_m_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_local_h_nz expected="2010-05-15" /> + +<@assertEquals actual=d?time?iso_utc expected="20:38:05Z" /> +<@assertEquals actual=d?time?iso_utc_ms expected="20:38:05.023Z" /> +<@assertEquals actual=d?time?iso_utc_m expected="20:38Z" /> +<@assertEquals actual=d?time?iso_utc_h expected="20Z" /> +<@assertEquals actual=d?time?iso_utc_nz expected="20:38:05" /> +<@assertEquals actual=d?time?iso_utc_ms_nz expected="20:38:05.023" /> +<@assertEquals actual=d?time?iso_utc_m_nz expected="20:38" /> +<@assertEquals actual=d?time?iso_utc_h_nz expected="20" /> +<@assertEquals actual=d?time?iso_local expected="22:38:05+02:00" /> +<@assertEquals actual=d?time?iso_local_ms expected="22:38:05.023+02:00" /> +<@assertEquals actual=d?time?iso_local_m expected="22:38+02:00" /> +<@assertEquals actual=d?time?iso_local_h expected="22+02:00" /> +<@assertEquals actual=d?time?iso_local_nz expected="22:38:05" /> +<@assertEquals actual=d?time?iso_local_ms_nz expected="22:38:05.023" /> +<@assertEquals actual=d?time?iso_local_m_nz expected="22:38" /> +<@assertEquals actual=d?time?iso_local_h_nz expected="22" /> + +<#assign dStrange = "600-01-01 23:59:59:123 +0000"?datetime("yyyy-MM-dd HH:mm:ss:S Z")> +<@assertEquals actual=dStrange?iso_utc_ms expected="0600-01-03T23:59:59.123Z" /> + +<#-- java.sql treatment --> +<@assertEquals actual=sqlDate?iso_local expected="2010-05-15" /> +<@assertEquals actual=sqlDate?iso_local_nz expected="2010-05-15" /> +<@assertEquals actual=sqlTime?iso_local_nz expected="22:38:05" /> +<@assertEquals actual=sqlTime?iso_utc_nz expected="20:38:05" /> + +<#setting time_zone="GMT+03"> <#-- should not mater --> +<@assertEquals actual=d?iso("UTC") expected="2010-05-15T20:38:05Z" /> +<@assertEquals actual=d?iso_ms("UTC") expected="2010-05-15T20:38:05.023Z" /> +<@assertEquals actual=d?iso_m("UTC") expected="2010-05-15T20:38Z" /> +<@assertEquals actual=d?iso_h("UTC") expected="2010-05-15T20Z" /> +<@assertEquals actual=d?iso_nz("UTC") expected="2010-05-15T20:38:05" /> +<@assertEquals actual=d?iso_ms_nz("UTC") expected="2010-05-15T20:38:05.023" /> +<@assertEquals actual=d?iso_m_nz("UTC") expected="2010-05-15T20:38" /> +<@assertEquals actual=d?iso_h_nz("UTC") expected="2010-05-15T20" /> +<@assertEquals actual=d?iso("GMT+02") expected="2010-05-15T22:38:05+02:00" /> +<@assertEquals actual=d?iso_ms("GMT+02") expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?iso_m("GMT+02") expected="2010-05-15T22:38+02:00" /> +<@assertEquals actual=d?iso_h("GMT+02") expected="2010-05-15T22+02:00" /> +<@assertEquals actual=d?iso_nz("GMT+02") expected="2010-05-15T22:38:05" /> +<@assertEquals actual=d?iso_ms_nz("GMT+02") expected="2010-05-15T22:38:05.023" /> +<@assertEquals actual=d?iso_m_nz("GMT+02") expected="2010-05-15T22:38" /> +<@assertEquals actual=d?iso_h_nz("GMT+02") expected="2010-05-15T22" /> + +<@assertEquals actual=d?date?iso("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_ms("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_m("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_h("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_nz("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_ms_nz("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_m_nz("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_h_nz("UTC") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_ms("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_m("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_h("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_nz("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_ms_nz("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_m_nz("GMT+02") expected="2010-05-15" /> +<@assertEquals actual=d?date?iso_h_nz("GMT+02") expected="2010-05-15" /> + +<@assertEquals actual=d?time?iso("UTC") expected="20:38:05Z" /> +<@assertEquals actual=d?time?iso_ms("UTC") expected="20:38:05.023Z" /> +<@assertEquals actual=d?time?iso_m("UTC") expected="20:38Z" /> +<@assertEquals actual=d?time?iso_h("UTC") expected="20Z" /> +<@assertEquals actual=d?time?iso_nz("UTC") expected="20:38:05" /> +<@assertEquals actual=d?time?iso_ms_nz("UTC") expected="20:38:05.023" /> +<@assertEquals actual=d?time?iso_m_nz("UTC") expected="20:38" /> +<@assertEquals actual=d?time?iso_h_nz("UTC") expected="20" /> +<@assertEquals actual=d?time?iso("GMT+02") expected="22:38:05+02:00" /> +<@assertEquals actual=d?time?iso_ms("GMT+02") expected="22:38:05.023+02:00" /> +<@assertEquals actual=d?time?iso_m("GMT+02") expected="22:38+02:00" /> +<@assertEquals actual=d?time?iso_h("GMT+02") expected="22+02:00" /> +<@assertEquals actual=d?time?iso_nz("GMT+02") expected="22:38:05" /> +<@assertEquals actual=d?time?iso_ms_nz("GMT+02") expected="22:38:05.023" /> +<@assertEquals actual=d?time?iso_m_nz("GMT+02") expected="22:38" /> +<@assertEquals actual=d?time?iso_h_nz("GMT+02") expected="22" /> + +<@assertEquals actual=d?iso(javaUTC) expected="2010-05-15T20:38:05Z" /> +<@assertEquals actual=d?iso(javaGMT02) expected="2010-05-15T22:38:05+02:00" /> +<@assertEquals actual=d?iso(adaptedToStringScalar) expected="2010-05-15T22:38:05+02:00" /> + +<#assign d = "12:00:00:1 +0000"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?iso_utc_ms expected="12:00:00.001Z" /> +<#assign d = "12:00:00:10 +0000"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?iso_utc_ms expected="12:00:00.01Z" /> +<#assign d = "12:00:00:100 +0000"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?iso_utc_ms expected="12:00:00.1Z" /> +<#assign d = "12:00:00:0 +0000"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?iso_utc_ms expected="12:00:00Z" /> + +<#setting time_zone="GMT+02"> +<#assign d = "2010-05-15"?date("yyyy-MM-dd")> +<@assertEquals actual=d?iso_local expected="2010-05-15" /> +<@assertEquals actual=d?iso_utc expected="2010-05-14" /> + +<#setting time_zone="GMT+02:30"> +<#assign d = "2010-05-15"?datetime("yyyy-MM-dd")> +<@assertEquals actual=d?iso_local expected="2010-05-15T00:00:00+02:30" /> + +<#setting time_zone="America/New_York"> +<@assertEquals actual="2010-05-09 20:00 +0000"?datetime("yyyy-MM-dd HH:mm Z")?iso_local expected="2010-05-09T16:00:00-04:00" /> +<@assertEquals actual="2010-01-01 20:00 +0000"?datetime("yyyy-MM-dd HH:mm Z")?iso_local expected="2010-01-01T15:00:00-05:00" /> + +<@assertFails>${d?iso("no such zone")}</@> + +<#setting time_zone="GMT+02"> +<@assertEquals actual=sqlTime?iso_local expected="22:38:05" /> +<@assertEquals actual=sqlTime?iso_utc expected="20:38:05" />
