http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xml-ns_prefix-scope.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xml-ns_prefix-scope.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xml.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xml.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xml.txt new file mode 100644 index 0000000..718bba1 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns1.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns1.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns1.txt new file mode 100644 index 0000000..69af553 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns3.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns3.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns3.txt new file mode 100644 index 0000000..f028f0a --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns4.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns4.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns4.txt new file mode 100644 index 0000000..f028f0a --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns5.txt ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns5.txt b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/expected/xmlns5.txt new file mode 100644 index 0000000..6e42b09 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/BeansTestResources.properties ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/BeansTestResources.properties b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/BeansTestResources.properties new file mode 100644 index 0000000..609e20b --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/defaultxmlns1.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/defaultxmlns1.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/defaultxmlns1.xml new file mode 100644 index 0000000..ed289bb --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xml-ns_prefix-scope.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xml-ns_prefix-scope.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xml.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xml.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xml.xml new file mode 100644 index 0000000..abf7e96 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlfragment.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlfragment.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlfragment.xml new file mode 100644 index 0000000..b5578b6 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns.xml new file mode 100644 index 0000000..6f6453e --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns2.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns2.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns2.xml new file mode 100644 index 0000000..c8bfc9f --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns3.xml ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns3.xml b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/models/xmlns3.xml new file mode 100644 index 0000000..8502ead --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/api-builtins.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/api-builtins.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/api-builtins.ftl new file mode 100644 index 0000000..5a9e2d7 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/arithmetic.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/arithmetic.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/arithmetic.ftl new file mode 100644 index 0000000..afd4c28 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/assignments.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/assignments.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/assignments.ftl new file mode 100644 index 0000000..f9f546d --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean-formatting.ftl new file mode 100644 index 0000000..a521fe8 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/boolean.ftl new file mode 100644 index 0000000..ab11c64 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/charset-in-header.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/charset-in-header.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/charset-in-header_inc1.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/charset-in-header_inc1.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/charset-in-header_inc2.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/charset-in-header_inc2.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comment.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comment.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comment.ftl new file mode 100644 index 0000000..9c47168 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl new file mode 100644 index 0000000..a711d4d --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/compress.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/compress.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/compress.ftl new file mode 100644 index 0000000..faf4ad6 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/date-type-builtins.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/date-type-builtins.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-iso-bi.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-iso-bi.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/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/test/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" /> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-iso-like.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-iso-like.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-iso-like.ftl new file mode 100644 index 0000000..a5accaf --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-iso-like.ftl @@ -0,0 +1,155 @@ +<#-- + 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?string.xs expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?string.iso expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?string('xs') expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?string('iso') expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?string.xs_nz expected="2010-05-15T22:38:05.023" /> +<@assertEquals actual=d?string.iso_nz expected="2010-05-15T22:38:05.023" /> +<@assertEquals actual=d?string.xs_fz expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?string.iso_fz expected="2010-05-15T22:38:05.023+02:00" /> +<@assertEquals actual=d?string.xs_u expected="2010-05-15T20:38:05.023Z" /> +<@assertEquals actual=d?string.iso_u expected="2010-05-15T20:38:05.023Z" /> +<@assertEquals actual=d?string.xs_s_u expected="2010-05-15T20:38:05Z" /> +<@assertEquals actual=d?string.iso_s_u expected="2010-05-15T20:38:05Z" /> + +<@assertEquals actual=d?date?string.xs expected="2010-05-15+02:00" /> +<@assertEquals actual=d?date?string.iso expected="2010-05-15" /> +<@assertEquals actual=d?date?string.xs_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?string.iso_nz expected="2010-05-15" /> +<@assertEquals actual=d?date?string.xs_fz expected="2010-05-15+02:00" /> +<@assertEquals actual=d?date?string.iso_fz expected="2010-05-15" /> + +<@assertEquals actual=d?time?string.xs expected="22:38:05.023+02:00" /> +<@assertEquals actual=d?time?string.iso expected="22:38:05.023+02:00" /> +<@assertEquals actual=d?time?string.xs_nz expected="22:38:05.023" /> +<@assertEquals actual=d?time?string.iso_nz expected="22:38:05.023" /> +<@assertEquals actual=d?time?string.xs_fz expected="22:38:05.023+02:00" /> +<@assertEquals actual=d?time?string.iso_fz expected="22:38:05.023+02:00" /> + +<#-- java.sql treatment --> +<@assertEquals actual=sqlDate?string.xs expected="2010-05-15" /> +<@assertEquals actual=sqlDate?string.iso expected="2010-05-15" /> +<@assertEquals actual=sqlDate?string.xs_fz expected="2010-05-15+02:00" /> +<@assertEquals actual=sqlDate?string.iso_fz expected="2010-05-15" /> +<@assertEquals actual=sqlDate?string.xs_nz expected="2010-05-15" /> +<@assertEquals actual=sqlDate?string.iso_nz expected="2010-05-15" /> +<@assertEquals actual=sqlTime?string.xs expected="22:38:05.023" /> +<@assertEquals actual=sqlTime?string.iso expected="22:38:05.023" /> +<@assertEquals actual=sqlTime?string.xs_fz expected="22:38:05.023+02:00" /> +<@assertEquals actual=sqlTime?string.iso_fz expected="22:38:05.023+02:00" /> +<@assertEquals actual=sqlTime?string.xs_nz expected="22:38:05.023" /> +<@assertEquals actual=sqlTime?string.iso_nz expected="22:38:05.023" /> + +<#assign d = "12:30:15:1 +0200"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?string.xs expected="12:30:15.001+02:00" /> +<@assertEquals actual=d?string.iso expected="12:30:15.001+02:00" /> +<@assertEquals actual=d?string.xs_ms expected="12:30:15.001+02:00" /> +<@assertEquals actual=d?string.iso_ms expected="12:30:15.001+02:00" /> +<@assertEquals actual=d?string.iso_s expected="12:30:15+02:00" /> +<@assertEquals actual=d?string.iso_m expected="12:30+02:00" /> +<@assertEquals actual=d?string.iso_h expected="12+02:00" /> +<#assign d = "12:30:15:10 +0200"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?string.xs expected="12:30:15.01+02:00" /> +<@assertEquals actual=d?string.iso expected="12:30:15.01+02:00" /> +<@assertEquals actual=d?string.xs_ms expected="12:30:15.010+02:00" /> +<@assertEquals actual=d?string.iso_ms expected="12:30:15.010+02:00" /> +<#assign d = "12:30:15:100 +0200"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?string.xs expected="12:30:15.1+02:00" /> +<@assertEquals actual=d?string.iso expected="12:30:15.1+02:00" /> +<@assertEquals actual=d?string.xs_ms expected="12:30:15.100+02:00" /> +<@assertEquals actual=d?string.iso_ms expected="12:30:15.100+02:00" /> +<#assign d = "12:30:15:0 +0200"?time("HH:mm:ss:S Z")> +<@assertEquals actual=d?string.xs expected="12:30:15+02:00" /> +<@assertEquals actual=d?string.iso expected="12:30:15+02:00" /> +<@assertEquals actual=d?string.xs_ms expected="12:30:15.000+02:00" /> +<@assertEquals actual=d?string.iso_ms expected="12:30:15.000+02:00" /> + +<#setting time_zone="GMT+02"> +<#assign d = "2010-05-15"?date("yyyy-MM-dd")> +<@assertEquals actual=d?string.xs expected="2010-05-15+02:00" /> +<@assertEquals actual=d?string.iso expected="2010-05-15" /> +<#setting time_zone="GMT+00"> +<@assertEquals actual=d?string.xs expected="2010-05-14Z" /> +<@assertEquals actual=d?string.iso expected="2010-05-14" /> + +<#setting time_zone="GMT+02:30"> +<#assign d = "2010-05-15"?datetime("yyyy-MM-dd")> +<@assertEquals actual=d?string.xs expected="2010-05-15T00:00:00+02:30" /> +<@assertEquals actual=d?string.iso expected="2010-05-15T00:00:00+02:30" /> + +<#setting time_zone="GMT-05"> +<#setting locale = "en_US"> +<#assign d = "BC 0001-05-15"?date("G yyyy-MM-dd")> +<#-- Tests that: (a) BC 1 isn't 0 like in ISO 8601; (b) No Julian calendar is used. --> +<@assertEquals actual=d?string.xs expected="-1-05-13-05:00" /> +<@assertEquals actual=d?string.iso expected="0000-05-13" /> + +<#assign dt = "2010-05-15T01:02:03"?datetime.xs> +<#setting datetime_format="xs"> +<@assertEquals actual=dt?string expected="2010-05-15T01:02:03-05:00" /> +<#setting datetime_format="xs u"> +<@assertEquals actual=dt?string expected="2010-05-15T06:02:03Z" /> +<#setting datetime_format="iso u"> +<@assertEquals actual=dt?string expected="2010-05-15T06:02:03Z" /> +<#setting datetime_format="xs fz"> +<@assertEquals actual=dt?string expected="2010-05-15T01:02:03-05:00" /> +<#setting datetime_format="xs fz u"> +<@assertEquals actual=dt?string expected="2010-05-15T06:02:03Z" /> +<#setting datetime_format="xs nz u"> +<@assertEquals actual=dt?string expected="2010-05-15T06:02:03" /> +<#setting datetime_format="iso m nz"> +<@assertEquals actual=dt?string expected="2010-05-15T01:02" /> + +<#assign d = dt?date> +<#setting date_format="xs"> +<@assertEquals actual=d?string expected="2010-05-15-05:00" /> +<#setting date_format="iso"> +<@assertEquals actual=d?string expected="2010-05-15" /> +<#setting date_format="xs fz"> +<@assertEquals actual=d?string expected="2010-05-15-05:00" /> +<#setting date_format="xs fz u"> +<@assertEquals actual=d?string expected="2010-05-15Z" /> +<#setting date_format="iso fz u"> +<@assertEquals actual=d?string expected="2010-05-15" /> +<#setting date_format="xs nz"> +<@assertEquals actual=d?string expected="2010-05-15" /> + +<#assign t = dt?time> +<@assertEquals actual=d?string expected="2010-05-15" /> +<#setting time_format="xs"> +<@assertEquals actual=t?string expected="01:02:03-05:00" /> +<#setting time_format="iso_m"> +<@assertEquals actual=t?string expected="01:02-05:00" /> +<#setting time_format="xs fz"> +<@assertEquals actual=t?string expected="01:02:03-05:00" /> +<#setting time_format="xs nz"> +<@assertEquals actual=t?string expected="01:02:03" /> +<#setting time_format="iso nz ms"> +<@assertEquals actual=t?string expected="01:02:03.000" /> + +<@assertFails message="Use ?date, ?time, or ?datetime">${unknownDate?string.xs}</@> +<@assertFails message="Use ?date, ?time, or ?datetime">${unknownDate?string.iso}</@> +<@assertFails message="format string">${.now?string.xs_fz_nz}</@> +<@assertFails message="format string">${.now?string.xs_u_fu}</@> +<@assertFails message="format string">${.now?string.xs_s_ms}</@> +<@assertFails message="format string">${.now?string.xs_q}</@> +<@assertFails message="format string">${.now?string.xss}</@> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-java.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-java.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-java.ftl new file mode 100644 index 0000000..82001db --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateformat-java.ftl @@ -0,0 +1,71 @@ +<#-- + 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 locale="en_US"> +<#setting time_zone="GMT"> +<#setting datetime_format=""> +${date} +${unknownDate?datetime} +${date?string} +${date?string[""]} +${date?string.short} +${date?string.medium} +${date?string.long} +${date?string.short_short} +${date?string.short_medium} +${date?string.short_long} +${date?string.medium_short} +${date?string.medium_medium} +${date?string.medium_long} +${date?string.long_short} +${date?string.long_medium} +${date?string.long_long} +${unknownDate?date} +${date?date?string[""]} +${date?date?string.short} +${date?date?string.medium} +${date?date?string.long} +${unknownDate?time} +${date?time?string[""]} +${date?time?string.short} +${date?time?string.medium} +${date?time?string.long} +<#setting locale="hu_hu"> +<#setting datetime_format="long_long"> +${date} +<#setting locale="en_US"> +<#setting datetime_format="EEE, dd MMM yyyyy HH:mm:ss z"> +${date} +${unknownDate?string["EEE, dd MMM yyyy HH:mm:ss z"]} +${unknownDate?string("EEE, dd MMM yyyy HH:mm:ss z")} +${unknownDate?string.yyyy} + +<#setting datetime_format="yyyy"> +<#assign s = date?string> +${s} +<#setting datetime_format="MM"> +${s} + +<#-- Check ?string lazy evaluation bug was fixed: --> +<#setting datetime_format="yyyy"> +<#assign s = date?string> +<#-- no ${s} --> +<#setting datetime_format="MM"> +${s} +<#assign s = date?string> +${s} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/28a276c8/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateparsing.ftl ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateparsing.ftl b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateparsing.ftl new file mode 100644 index 0000000..d830f95 --- /dev/null +++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/test/templatesuite/templates/dateparsing.ftl @@ -0,0 +1,84 @@ +<#-- + 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 locale="en_US"> +<#setting time_zone="GMT"> +<#setting datetime_format="G yyyy-MM-dd HH:mm:ss.S Z"> +<#setting date_format="G yyyy-MM-dd Z"> +<#setting time_format="HH:mm:ss.S Z"> + +<@assertEquals expected="AD 1998-10-30 15:30:44.512 +0000" actual='AD 1998-10-30 19:30:44.512 +0400'?datetime?string /> +<@assertEquals expected="AD 1998-10-29 +0000" actual='AD 1998-10-30 +0400'?date?string /> +<@assertEquals expected="15:30:44.512 +0000" actual='19:30:44.512 +0400'?time?string /> + +<@assertEquals expected="AD 1998-10-30 15:30:44.512 +0000" + actual='10/30/1998 19:30:44:512 GMT+04:00'?datetime("MM/dd/yyyy HH:mm:ss:S z")?string /> +<@assertEquals expected="AD 1998-10-29 +0000" + actual='10/30/1998 GMT+04:00'?date("MM/dd/yyyy z")?string /> +<@assertEquals expected="15:30:44.512 +0000" + actual='19:30:44:512 GMT+04:00'?time("HH:mm:ss:S z")?string /> + +<@assertEquals expected="AD 1998-10-30 15:30:44.512 +0000" actual='1998-10-30T19:30:44.512+04:00'?datetime.xs?string /> +<@assertEquals expected="AD 1998-10-29 +0000" actual='1998-10-30+04:00'?date.xs?string /> +<@assertEquals expected="15:30:44.512 +0000" actual='19:30:44.512+04:00'?time.xs?string /> + +<#assign gmtStr='1998-10-30T19:30:44.512'?datetime.xs?string /> +<#setting time_zone="GMT+01:00"> +<#assign gmt01Str='1998-10-30T19:30:44.512'?datetime.xs?string /> +<#setting time_zone="default"> +<#assign defStr='1998-10-30T19:30:44.512'?datetime.xs?string /> +<@assert test = gmtStr != gmt01Str /> +<@assert test = defStr != gmtStr || defStr != gmt01Str /> + +<#assign refDate = "AD 1998-10-30 +0000"?date> +<#assign refTime = "15:30:44.512 +0000"?time> +<#assign refDateTime = "AD 1998-10-30 15:30:44.512 +0000"?datetime> +<#setting time_zone="UTC"> +<#list ['xs', 'xs_nz', 'xs_fz', 'xs s', 'xs ms'] as format> + <#setting date_format=format> + <#setting time_format=format> + <#setting datetime_format=format> + <@assertEquals expected=refDate actual="1998-10-30Z"?date /> + <@assertEquals expected=refTime actual="15:30:44.512Z"?time /> + <@assertEquals expected=refDateTime actual="1998-10-30T15:30:44.512Z"?datetime /> +</#list> +<#list ['iso', 'iso_nz', 'iso_fz', 'iso m'] as format> + <#setting date_format=format> + <#setting time_format=format> + <#setting datetime_format=format> + <@assertEquals expected=refDate actual="1998-10-30"?date /> + <@assertEquals expected=refDate actual="19981030"?date /> + <@assertEquals expected=refTime actual="15:30:44,512Z"?time /> + <@assertEquals expected=refTime actual="153044,512Z"?time /> + <@assertEquals expected=refDateTime actual="1998-10-30T15:30:44,512Z"?datetime /> + <@assertEquals expected=refDateTime actual="19981030T153044,512Z"?datetime /> +</#list> + +<#setting time_zone="GMT+01:00"> +<#assign refDateTime='1998-10-30T19:30:44.512'?datetime.xs /> +<@assertEquals expected=refDateTime actual="1998-10-30T19:30:44.512"?datetime.xs /> +<@assertEquals expected=refDateTime actual="1998-10-30T19:30:44.512"?datetime.iso /> +<@assertEquals expected=refDateTime actual="1998-10-30T18:30:44.512"?datetime.xs_u /> +<@assertEquals expected=refDateTime actual="1998-10-30T18:30:44.512"?datetime.iso_u /> +<#setting time_zone="UTC"> +<@assertEquals expected=refDateTime actual="1998-10-30T18:30:44.512"?datetime.xs /> +<@assertEquals expected=refDateTime actual="1998-10-30T18:30:44.512"?datetime.iso /> +<@assertEquals expected=refDateTime actual="1998-10-30T19:30:44.512+01:00"?datetime.xs /> +<@assertEquals expected=refDateTime actual="1998-10-30T19:30:44.512+01:00"?datetime.xs_u /> +<@assertEquals expected=refDateTime actual="1998-10-30T19:30:44.512+01"?datetime.iso /> +<@assertEquals expected=refDateTime actual="1998-10-30T19:30:44.512+01"?datetime.iso_u /> \ No newline at end of file
