diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibSpec.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibSpec.groovy new file mode 100644 index 0000000000..051cdd0a21 --- /dev/null +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibSpec.groovy @@ -0,0 +1,42 @@ +package org.grails.web.taglib + +import grails.testing.web.taglib.TagLibUnitTest +import org.grails.plugins.web.taglib.FormatTagLib +import spock.lang.IgnoreIf +import spock.lang.Requires +import spock.lang.Specification + +class FormatTagLibSpec extends Specification implements TagLibUnitTest { + + @Requires({ jvm.isJava8() }) + void testFormatCurrencyForJava8() { + given: + BigDecimal number = "3.12325678" as BigDecimal + "3,12 €" == applyTemplate('', [number: number]) + } + + @IgnoreIf({ jvm.isJava8() }) + void testFormatCurrency() { + given: + BigDecimal number = "3.12325678" as BigDecimal + "3,12${new String([160] as char[])}€" == applyTemplate('', [number: number]) + } + + @Requires({ jvm.isJava8() }) + void testFormatCurrencyWithCodeAndLocaleForJava8() { + given: + BigDecimal number = "3.12325678" as BigDecimal + + expect: + "3,12 USD" == applyTemplate('', [number: number]) + } + + @IgnoreIf({ jvm.isJava8() }) + void testFormatCurrencyWithCodeAndLocale() { + given: + BigDecimal number = "3.12325678" as BigDecimal + + expect: + "3,12${new String([160] as char[])}\$" == applyTemplate('', [number: number]) + } +} diff --git a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibTests.groovy b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibTests.groovy index bb77e887ea..d75efec125 100644 --- a/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibTests.groovy +++ b/grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibTests.groovy @@ -203,18 +203,6 @@ class FormatTagLibTests extends AbstractGrailsTagTests { assertOutputEquals("3.1233", template, [number: number]) } - void testFormatCurrency() { - def number = "3.12325678" as BigDecimal - def template = '' - assertOutputEquals("3,12 €", template, [number: number]) - } - - void testFormatCurrencyWithCodeAndLocale() { - def number = "3.12325678" as BigDecimal - def template = '' - assertOutputEquals("3,12 USD", template, [number: number]) - } - void testFormatCurrencyWithCode() { def number = "3.12325678" as BigDecimal def template = ''