diff options
| author | Di Peng | 2011-07-29 14:22:37 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-08-14 23:44:20 -0700 |
| commit | 966cbd4cf8d795b1706ff400f604c6002d7e81f9 (patch) | |
| tree | 3ca9c42d7bad4f151c72d39f3ef9b053de6cc861 /i18n/spec/parserSpec.js | |
| parent | 8534b7c7c0aa352eb0f17dbe8b22ba34f995654d (diff) | |
| download | angular.js-966cbd4cf8d795b1706ff400f604c6002d7e81f9.tar.bz2 | |
feat(i18n): collect and convert locale info from closure
- add i18n/closure directory with closure i18n files and
update-closure.sh script to update them
- generate.sh script runs node.js scripts that extract localization
rules from the closure library, transform them to a more suitable
format and dumps them into i18n/locale directory as angular's $locale
services
- update Rakefile to copy i18n files to build/ and pkg/ dirs
- copy i18n stuff during rake build
- e2e tests for several locales
Diffstat (limited to 'i18n/spec/parserSpec.js')
| -rw-r--r-- | i18n/spec/parserSpec.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/i18n/spec/parserSpec.js b/i18n/spec/parserSpec.js new file mode 100644 index 00000000..2904e31c --- /dev/null +++ b/i18n/spec/parserSpec.js @@ -0,0 +1,51 @@ +var parsePattern = require('../src/parser.js').parsePattern; + +describe('parsePattern', function() { + function parseAndExpect(pattern, pp, np, ps, ns, mii, mif, maf, g, lg) { + var p = parsePattern(pattern); + + expect(p.minInt).toEqual(mii); + expect(p.minFrac).toEqual(mif); + expect(p.maxFrac).toEqual(maf); + + expect(p.posPre).toEqual(pp); + expect(p.posSuf).toEqual(ps); + expect(p.negPre).toEqual(np); + expect(p.negSuf).toEqual(ns); + + expect(p.gSize).toBe(g); + expect(p.lgSize).toBe(lg); + } + + it('should parse DECIMAL patterns', function() { + // all DECIMAL patterns from closure + parseAndExpect('#,##0.###', '', '-', '', '', 1, 0, 3, 3, 3); + parseAndExpect('#,##0.###;#,##0.###-', '', '', '', '-', 1, 0, 3, 3, 3); + parseAndExpect('#,##,##0.###', '', '-', '', '', 1, 0, 3, 2, 3); + parseAndExpect("#,##0.###;\'\u202A\'-#,##0.###\'\u202C\'", + '', '\u202A-', '', '\u202C', 1, 0, 3, 3, 3); + }); + + it('should parse CURRENCY patterns', function() { + // all CURRENCY patterns from closure + parseAndExpect('#,##0.00 \u00A4', '', '-', ' \u00A4', ' \u00A4', 1, 2, 2, 3, 3); + parseAndExpect("#,##0.00\u00A0\u00A4;\'\u202A\'-#,##0.00\'\u202C\'\u00A0\u00A4", + '', '\u202A-', '\u00A0\u00A4', '\u202C\u00A0\u00A4', 1, 2, 2, 3, 3); + parseAndExpect('#,##0.00 \u00A4;(#,##0.00 \u00A4)', + '', '(', ' \u00A4', ' \u00A4)', 1, 2, 2, 3, 3); + parseAndExpect('#,##,##0.00\u00A4', '', '-', '\u00A4', '\u00A4', 1, 2, 2, 2, 3); + parseAndExpect('#,##,##0.00\u00A4;(#,##,##0.00\u00A4)', + '', '(', '\u00A4', '\u00A4)', 1, 2, 2, 2, 3); + parseAndExpect('\u00A4#,##0.00', '\u00A4', '\u00A4-', '', '', 1, 2, 2, 3, 3); + parseAndExpect('\u00A4#,##0.00;(\u00A4#,##0.00)', + '\u00A4', '(\u00A4', '', ')', 1, 2, 2, 3, 3); + parseAndExpect('\u00A4#,##0.00;\u00A4-#,##0.00', + '\u00A4', '\u00A4-', '', '', 1, 2, 2, 3, 3); + parseAndExpect('\u00A4 #,##0.00', '\u00A4 ', '\u00A4 -', '', '', 1, 2, 2, 3, 3); + parseAndExpect('\u00A4 #,##0.00;\u00A4-#,##0.00', + '\u00A4 ', '\u00A4-', '', '', 1, 2, 2, 3, 3); + parseAndExpect('\u00A4 #,##0.00;\u00A4 #,##0.00-', + '\u00A4 ', '\u00A4 ', '', '-', 1, 2, 2, 3, 3); + parseAndExpect('\u00A4 #,##,##0.00', '\u00A4 ', '\u00A4 -', '', '', 1, 2, 2, 2, 3); + }); +}); |
