-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix formatCurrency behaviour for JDK 8 and 11
See: #36
- Loading branch information
Showing
2 changed files
with
42 additions
and
12 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
grails-plugin-gsp/src/test/groovy/org/grails/web/taglib/FormatTagLibSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<FormatTagLib> { | ||
|
||
@Requires({ jvm.isJava8() }) | ||
void testFormatCurrencyForJava8() { | ||
given: | ||
BigDecimal number = "3.12325678" as BigDecimal | ||
"3,12 €" == applyTemplate('<g:formatNumber type="currency" number="${number}" locale="fi_FI" />', [number: number]) | ||
} | ||
|
||
@IgnoreIf({ jvm.isJava8() }) | ||
void testFormatCurrency() { | ||
given: | ||
BigDecimal number = "3.12325678" as BigDecimal | ||
"3,12${new String([160] as char[])}€" == applyTemplate('<g:formatNumber type="currency" number="${number}" locale="fi_FI" />', [number: number]) | ||
} | ||
|
||
@Requires({ jvm.isJava8() }) | ||
void testFormatCurrencyWithCodeAndLocaleForJava8() { | ||
given: | ||
BigDecimal number = "3.12325678" as BigDecimal | ||
|
||
expect: | ||
"3,12 USD" == applyTemplate('<g:formatNumber type="currency" currencyCode="USD" number="${number}" locale="fi_FI" />', [number: number]) | ||
} | ||
|
||
@IgnoreIf({ jvm.isJava8() }) | ||
void testFormatCurrencyWithCodeAndLocale() { | ||
given: | ||
BigDecimal number = "3.12325678" as BigDecimal | ||
|
||
expect: | ||
"3,12${new String([160] as char[])}\$" == applyTemplate('<g:formatNumber type="currency" currencyCode="USD" number="${number}" locale="fi_FI" />', [number: number]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters