]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/testdata/numberformattestspecification.txt
ICU-62141.0.1.tar.gz
[apple/icu.git] / icuSources / test / testdata / numberformattestspecification.txt
CommitLineData
0f5d89e8 1// Copyright (C) 2016 and later: Unicode, Inc. and others.
f3c0d7a5
A
2// License & terms of use: http://www.unicode.org/copyright.html
3// Copyright (C) 2015-2016, International Business Machines
2ca993e8
A
4// Corporation and others. All Rights Reserved.
5//
6// This file is divided into test suites separated by whitespace. Each test
7// suite starts with the name of the test followed by global field settings
8// for that test suite. After the global settings, comes "begin", the
9// per-test field names, and finally the test specific field values, 1 test
10// per line.
0f5d89e8
A
11//
12// breaks field names:
13// H = ICU4J 58 (archive)
14// J = ICU4J (current)
15// K = JDK (ignored if not OpenJDK 1.8)
16// C = ICU4C (current)
17// P = Properties-based ICU4J (bypasses DecimalFormat wrapper)
18// Q = ? (old, from ICU 61 tests, maybe the same as P?
19//
2ca993e8
A
20// For more information on the format of this file, including all the available
21// field names, please see
22// https://docs.google.com/document/d/1T2P0p953_Lh1pRwo-5CuPVrHlIBa_wcXElG-Hhg_WHM/edit?usp=sharing
23
24test plus sign
0f5d89e8 25set locale ar-EG
2ca993e8
A
26set pattern +0;-#
27begin
28format output breaks
0f5d89e8
A
296 \u061C+\u0666 HK
30-6 \u061C-\u0666 K
2ca993e8
A
31
32test basic patterns
33set locale fr_FR
34set format 1234.567
35begin
36pattern output
37#,##0.## 1\u00a0234,57
380.## 1234,57
390 1235
40#,##0.### 1\u00a0234,567
41###0.###### 1234,567
42###0.0000# 1234,5670
4300000.0000 01234,5670
44#,##0.00 \u00a4 1\u00a0234,57 \u20ac
45'tick''bitten '0.00 tick'bitten 1234,57
46'tick' 'bitten '0.00 tick bitten 1234,57
47
48
49test minimum and maximum fraction digits
50set locale en
51set minIntegerDigits 2
52set maxIntegerDigits 4
53set minFractionDigits 3
54set maxFractionDigits 5
55begin
56format output
576 06.000
586.000005 06.000
596.000006 06.00001
601002003004005 4005.000
61-1002003004005 -4005.000
6212 12.000
6312345 2345.000
6472.1234 72.1234
65
0f5d89e8
A
66test patterns with no '0' symbols
67set locale en_US
68begin
69pattern format output breaks
70# 514.23 514
71# 0.23 0
72# 0 0
73# 1 1
74##.# 514.23 514.2
75##.# 0.23 0.2
76##.# 0 0
77##.# 1 1
78#.# 514.23 514.2
79#.# 0.23 0.2
80#.# 0 0
81#.# 1 1
82.# 514.23 514.2
83.# 0.23 .2
84.# 0 .0
85.# 1 1.0
86#. 514.23 514.
87#. 0.23 0.
88#. 0 0.
89#. 1 1.
90. 514.23 514.
91. 0.23 0.
92. 0 0.
93. 1 1.
94
95test behavior on numbers approaching zero
96set locale en
97begin
98pattern format output breaks
99#.## 0.01 0.01
100#.## 0.001 0
101#.## 0 0
102#.00 0.01 .01
103#.00 0.001 .00
104#.00 0 .00
1050.00 0.01 0.01
1060.00 0.001 0.00
1070.00 0 0.00
108
109// Not in official spec, but needed for backwards compatibility
110test patterns with leading grouping separator
111set locale en_US
112begin
113pattern format output breaks
114,##0 1234.56 1,235
115'#',## 3456 #34,56
116
117test patterns with valid and invalid quote marks
118set locale et
119begin
120pattern format output breaks
121'# 1 fail
122''# 1 '1
123'''# 1 fail
124''''# 1 ''1
125'''''# 1 fail
126'-''-'# 1 -'-1
127// K doesn't know the locale symbol for et
128-'-'# 1 −-1 K
129'#'# 1 #1
130''#'' 1 '1'
131''#- 1 '1− K
132'-'#- 1 -1− K
133-#'-' 1 −1- K
134
2ca993e8
A
135test int64
136set locale en
137begin
138format output
1391002003004005 1002003004005
140-1002003004005 -1002003004005
141
142test rounding
143set locale fr
144begin
145pattern format output breaks
1460.5 1.25 1,0 K
1470.5 1.75 2,0 K
1480.5 -1.25 -1,0 K
14900.5 -1.75 -02,0 K
1504 2.0 0 K
1514 6.0 8 K
1524 10.0 8 K
1532.70 99.0 99,90 K
1542.73 272.0 273,00 K
155#,#3.70 104.0 1\u00a003,60 K
156
157test significant digits
158set locale en
159set pattern #,#@,@###
160begin
161format output breaks
1627 7.0 K
16323 23 K
164100 100 K
1651000 1000 K
16610000 1,0000 K
16710001 1,0001 K
16810001.5 1,0002 K
1691234567 1,23,4600 K
170-1234567 -1,23,4600 K
1713.14159 3.1416 K
172
173test scientific notation
174set locale fr
175begin
176pattern format output breaks
1770.00E0 12345 1,23E4
178000.00E0 12300 123,00E2
179000.0#E0 12300 123,0E2
180000.0#E0 12300.1 123,0E2
181000.0#E0 12301.0 123,01E2
182// JDK does not support exponent signs
183000.0#E+00 12301.0 123,01E+02 K
184// JDK gives 12,345E3. JDK seems to include the hashes in significant digits
185##0.00E0 12345 12,3E3 K
186// JDK gives 12,3001E3
187##0.0000E0 12300.1 12,300E3 K
188// JDK gives 12,3001E3
189##0.000#E0 12300.1 12,30E3 K
190##0.000#E0 12301 12,301E3
0f5d89e8 1910.05E0 12301.2 1,25E4 HK
2ca993e8
A
192##0.000#E0 0.17 170,0E-3
193// JDK doesn't support significant digits in exponents
0f5d89e8 194@@@E0 6.235 6,24E0 K
2ca993e8
A
195@@@E0 6235 6,24E3 K
196@@@#E0 6200 6,20E3 K
197@@@#E0 6201 6,201E3 K
198@@@#E0 6201.7 6,202E3 K
199@@@#E00 6201.7 6,202E03 K
200@@@#E+00 6201.7 6,202E+03 K
0f5d89e8
A
201// If no zeros are specified, significant digits is fraction length plus 1
202#.##E0 52413 5,24E4
203###.##E0 52413 52,4E3 K
204#E0 52413 5,2413E4 K
2050E0 52413 5E4
2ca993e8
A
206
207test percents
208set locale fr
209begin
210pattern format output breaks
2110.0% 0.573 57,3%
212%0.0 0.573 %57,3
213p%p0.0 0.573 p%p57,3
214p'%'p0.0 0.573 p%p0,6
215%@@@@ 0.0326 %3,260 K
216%#,@@@ 15.43 %1\u00a0540 K
217// JDK does not support rounding increments
218%#,##4.1 16.55 %1\u00a0656,4 K
219// JDK gives %16,255E3
220%##0.00E0 162.55 %16,3E3 K
221
222test permille
223set locale fr
224begin
225pattern format output breaks
2260.0\u2030 0.573 573,0‰
227\u20300.0 0.573 \u2030573,0
228p\u2030p0.0 0.573 p\u2030p573,0
229p'\u2030'p0.0 0.573 p\u2030p0,6
230\u2030@@@@ 0.0326 \u203032,60 K
231\u2030#,@@@ 15.43 \u203015\u00a0400 K
232\u2030#,##4.1 16.55 \u203016\u00a0551,7 K
233// JDK gives \u2030162,55E3
234\u2030##0.00E0 162.55 \u2030163E3 K
235
236test padding
237set locale fr_FR
238begin
239pattern format output breaks
240// JDK does not seem to support padding
241$**####,##0 1234 $***1\u00a0234 K
242*x$####,##0 1234 xxx$1\u00a0234 K
243####,##0*x$ 1234 1\u00a0234xxx$ K
244####,##0$*x 1234 1\u00a0234$xxx K
245// JDK doesn't seem to handle suffixes correctly dropping the 'nx' entirely
246####,##0$*x;ne#n -1234 ne1\u00a0234nx K
247####,##0$*x;n#'*' -1234 n1\u00a0234*xx K
248*y%4.2###### 4.33 yyyy%432,6 K
249// In J ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
0f5d89e8
A
250\u00a4\u00a4 **####0.00 433.0 EUR *433,00 HK
251// In H ICU adds padding as if 'EUR' is only 2 chars (2 * 0xa4)
252// P fails this one because the test code bypasses CurrencyUsage
253\u00a4\u00a4 **#######0 433.0 EUR *433,00 HKP
2ca993e8
A
254
255test padding and currencies
256begin
257locale currency pattern format output breaks
258// In J, JPY is considered 2 char (2 * 0xa4) even though padding is done
259// after prefix. In C this test works.
0f5d89e8 260fr JPY \u00a4\u00a4 **#######0 433.22 JPY ****433 HK
2ca993e8
A
261// JDK doesn't correct rounding for currency, shows USD (433
262en USD \u00a4\u00a4 **#######0;\u00a4\u00a4 (#) -433.22 USD (433.22) K
263
264test currencies
265set locale fr
266set format 1234.567
267begin
268pattern currency output breaks
269// JDK gives shows EUR instead of the euro symbol in this case
270#,##0.00 \u00a4 EUR 1\u00a0234,57 \u20ac K
271// JDK gives 1\u00A0234,57. JDK doesn't seem to correct rounding
272// based on currency.
273#,##0.00 \u00a4 JPY 1\u00a0235 JPY K
274
275test prefixes and suffixes
276set locale en
277set pattern 0.00+;(#)
278begin
279format output breaks
2807 7.00+
281// JDK does not support negative suffixes
282-3.5 (3.50) K
283
284test minimum grouping digits
285set locale en
286set pattern #,##0
287set minGroupingDigits 2
288begin
289format output breaks
290// min grouping digits not supported in any existing implementation
291// but could be easily added to the new DecimalFormat C code.
0f5d89e8 2921000 1000 HK
2ca993e8
A
29310000 10,000
294100000 100,000
2951000000 1,000,000
296
297test min max fraction digits
298set locale en
299set pattern #,##0.###
300set format 1234.567
301begin
302minFractionDigits maxFractionDigits output
3030 0 1,235
3040 2 1,234.57
3054 5 1,234.5670
306
307test min max integer digits
308set locale en
309set pattern #,##0.###
310set format 1234.567
311begin
312minIntegerDigits maxIntegerDigits output
3130 0 .567
3140 3 234.567
3155 5 01,234.567
316
317test min max fraction digits scientific
318set locale en
319set pattern #E0
320set format 299792458.0
321begin
322minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
0f5d89e8
A
323// JDK gives 2.99792458E8 (maxInt + maxFrac instead of minInt + maxFrac)
3241 99 0 5 2.99792E8 K
2ca993e8
A
325// JDK gives .3E9 instead of unlimited precision.
3260 1 0 0 2.99792458E8 K
3271 1 0 0 3E8
328// JDK gives E0 instead of allowing for unlimited precision
3290 0 0 0 2.99792458E8 K
0f5d89e8
A
330// JDK gives .299792E9; Q gives 2.99792E8
3310 1 0 5 2.9979E8 KQ
2ca993e8
A
332// JDK gives 300E6
3330 3 0 0 299.792458E6 K
334// JDK gives 299.8E6 (maybe maxInt + maxFrac instead of minInt + maxFrac)?
3350 3 0 1 300E6 K
336// JDK gives 299.7925E6
3372 3 0 4 299.792E6 K
338// JDK gives 299.79246E6
3392 3 0 5 299.7925E6 K
3403 3 0 5 299.79246E6
3413 3 0 4 299.7925E6
3422 2 0 3 29.979E7
3434 4 0 0 2998E5
3440 0 1 5 .29979E9
345// JDK gives E0
3460 0 1 0 2.99792458E8 K
0f5d89e8
A
347// JDK and Q give .2998E9
3480 0 0 4 2.998E8 KQ
349// According to the spec, if maxInt>minInt and minInt>1, then set
350// Context: #13289
2ca993e8
A
3512 8 1 6 2.9979246E8 K
352// Treat max int digits > 8 as being the same as min int digits.
353// This behavior is not spelled out in the specification.
354// JDK fails here because it tries to use 9 + 6 = 15 sig digits.
3552 9 1 6 29.979246E7 K
356
357test significant digits scientific
358set locale en
359set pattern #E0
360set format 290000000.0
361begin
362minSigDigits maxSigDigits output breaks
3630 1 3E8 K
3640 2 2.9E8 K
3650 3 2.9E8 K
3661 1 3E8 K
3671 2 2.9E8 K
3681 3 2.9E8 K
3692 2 2.9E8 K
3702 3 2.9E8 K
3713 3 2.90E8 K
3723 4 2.90E8 K
373
374test min max fraction digits scientific 2
375set locale en
376set pattern #E0
377set format 29979245.0
378begin
379minIntegerDigits maxIntegerDigits minFractionDigits maxFractionDigits output breaks
380// JDK gives E0
3810 0 0 0 2.9979245E7 K
382// JDK gives .3E8
3830 1 0 0 2.9979245E7 K
384// JDK gives 2998E4.
3850 4 0 0 2997.9245E4 K
386
387test ticket 11524
388set locale en
389set pattern #,##0.###
390begin
0f5d89e8
A
391format maxIntegerDigits output breaks
392123 1 3
393// (ICU 61 behavior)
3940 0 0
395// Q ignores max integer if it is less than zero and prints "123"
396123 -2147483648 0 Q
39712345 1 5
39812345 -2147483648 0 Q
3995.3 1 5.3
4005.3 -2147483648 .3 Q
2ca993e8
A
401
402test patterns with zero
403set locale en
404set format 0
405begin
0f5d89e8 406pattern output breaks
2ca993e8
A
407#.# 0
408#. 0.
409.# .0
410# 0
0f5d89e8
A
411#,##0.00 0.00
412#,###.00 .00
2ca993e8
A
41300.000E00 00.000E00
4140.####E0 0E0
415##0.######E000 0E000
416
417test significant digits manually set
418set locale en_US
419set pattern 0.0
420set useSigDigits 1
421set minSigDigits 3
422set maxSigDigits 5
423begin
424format output breaks
4250.0012 0.00120 K
4260.00123 0.00123 K
4270.001234 0.001234 K
4280.0012345 0.0012345 K
4290.00123456 0.0012346 K
0f5d89e8
A
430-43 -43.0
431-43.7 -43.7
2ca993e8
A
432-43.76 -43.76 K
433-43.762 -43.762 K
434-43.7626 -43.763 K
435
436test grouping used setters
437set locale en_US
438set pattern #,##0
439set format 12345
440begin
441output useGrouping
44212,345
44312,345 1
44412345 0
445
0f5d89e8
A
446test grouping used setters in parsing
447set pattern #,##0
448begin
449locale useGrouping parse output breaks
450en_US 1 123,456 123456
451en_US 0 123,456 123
452en_US 1 123.456 123.456
453en_US 0 123.456 123.456
454it_IT 1 123,456 123.456
455it_IT 0 123,456 123.456
456it_IT 1 123.456 123456
457it_IT 0 123.456 123
458
459test no grouping in pattern with parsing
460set pattern 0
461begin
462locale parse output breaks
463en_US 123,456 123
464en_US 123.456 123.456
465fr_FR 123,456 123.456
466fr_FR 123.456 123
467
2ca993e8
A
468test grouping setters
469set locale en_US
470set pattern 0
471set format 123456789
472set useGrouping 1
473begin
0f5d89e8 474output grouping grouping2 breaks
2ca993e8 4751,2345,6789 4
0f5d89e8
A
4761,23,45,6789 4 2 K
477
478test grouping setters with min grouping digits
479set locale en_US
480set pattern 0
481set format 123456789
482set useGrouping 1
483begin
484output grouping grouping2 minGroupingDigits breaks
4851,23,45,6789 4 2 2 K
486123,456789 6 6 3
487123456789 6 6 4 HK
2ca993e8
A
488
489test multiplier setters
490set locale en_US
491begin
492format multiplier output breaks
49323 -12 -276
49423 -1 -23
0f5d89e8
A
495// H (ICU4J 58) and J (current ICU4J) throw exception on zero multiplier.
496// ICU4C prints 23.
497// Q multiplies by zero and prints 0.
49823 0 0 CHJ
2ca993e8
A
49923 1 23
50023 12 276
501-23 12 -276
502-23 -12 276
503
504test rounding setters
505set locale en_US
506set pattern 0.0#
507set roundingIncrement 0.25
508begin
509format output breaks
510-0.35 -0.25 K
5110.35 0.25 K
0f5d89e8
A
512// P doesn't support mixing minFrac with roundingIncrement (prints 0.50).
5130.39 0.5 JKP
5140.62 0.5 JKP
2ca993e8
A
5150.63 0.75 K
516
517test padding setters
518set locale en_US
519set pattern bill0
520set format 1357
521begin
522padCharacter formatWidth output breaks
0f5d89e8 523* 8 bill1357
2ca993e8
A
524* 9 *bill1357 K
525^ 10 ^^bill1357 K
526
527test use scientific setter
528set locale en_US
529set pattern 0.00
530set format 186283
531begin
0f5d89e8 532output useScientific breaks
2ca993e8 533186283.00
0f5d89e8
A
5341.86E5 1 K
535186283.00 0
2ca993e8
A
536
537test rounding mode setters
538set locale en_US
0f5d89e8 539set pattern 0.5
2ca993e8
A
540begin
541format roundingMode output breaks
0f5d89e8
A
5421.24 halfUp 1.0 K
5431.25 halfUp 1.5
5441.25 halfDown 1.0 K
5451.26 halfDown 1.5
5461.25 halfEven 1.0 K
547-1.01 up -1.5
548-1.49 down -1.0 K
5491.01 up 1.5
5501.49 down 1.0 K
551-1.01 ceiling -1.0 K
552-1.49 floor -1.5
2ca993e8
A
553
554test currency usage setters
2ca993e8 555set locale CH
2ca993e8
A
556set pattern \u00a4\u00a4 0
557begin
0f5d89e8
A
558format currency currencyUsage output breaks
5590.37 CHF standard CHF 0.37 K
5600.37 CHF cash CHF 0.35 K
5611.234 CZK standard CZK 1.23 K
5621.234 CZK cash CZK 1
563
564test currency usage to pattern
565set locale en
566begin
567currency currencyUsage toPattern breaks
568// These work in J, but it prepends an extra hash sign to the pattern.
569// C does not print the currency rounding information in the pattern.
570// K does not support this feature.
571USD standard 0.00 CHK
572CHF standard 0.00 CHK
573CZK standard 0.00 CHK
574USD cash 0.00 CHK
575CHF cash 0.05 CHK
576CZK cash 0 CHK
577
578test currency rounding
579set locale en
580set currency USD
581begin
582pattern format output breaks
583# 123 123 P
584// Currency rounding should always override the pattern.
585// K prints the currency in ISO format for some reason.
586\u00a4# 123 $123.00 K
587\u00a4#.000 123 $123.00 K
588\u00a4#.## 123 $123.00 K
2ca993e8
A
589
590test exponent parameter setters
591set locale en_US
592set pattern 0.##E0
593set format 299792458
594begin
595decimalSeparatorAlwaysShown exponentSignAlwaysShown minimumExponentDigits output breaks
5960 0 2 3E08 K
5970 1 3 3E+008 K
2ca993e8
A
598// decimalSeparatorAlwaysShown K=JDK; C=ICU4C; J=ICU4J
599// See ticket 11621
0f5d89e8
A
6001 0 2 3.E08 K
6011 1 3 3.E+008 K
f3c0d7a5 6021 0 1 3.E8
2ca993e8
A
6030 0 1 3E8
604
605test exponent decimalSeparatorAlwaysShown default
606set locale en_US
607set pattern 0.##E0
608begin
0f5d89e8 609format output decimalSeparatorAlwaysShown breaks
2ca993e8
A
610// decimalSeparatorAlwaysShown off by default
611299792458 3E8
612299000000 2.99E8
0f5d89e8 613299792458 3.E8 1
2ca993e8
A
614
615test pad position setters
616set locale en_US
617set pattern **[#####0.##];((#))
618begin
619format padPosition output breaks
62012.34 beforePrefix ****[12.34] K
62112.34 afterPrefix [****12.34] K
62212.34 beforeSuffix [12.34****] K
62312.34 afterSuffix [12.34]**** K
624-12.34 beforePrefix **((12.34)) K
625-12.34 afterPrefix ((**12.34)) K
626-12.34 beforeSuffix ((12.34**)) K
627-12.34 afterSuffix ((12.34))** K
628
629test affix setters
630set locale fr_FR
631set currency EUR
632set pattern 0.00
633begin
634format positivePrefix positiveSuffix negativePrefix negativeSuffix output
63512.34 % %12,34
63612.34 \u00a4\u00a4 12,34\u00a4\u00a4
63712.34 - + 12,34
638-12.34 - + -12,34+
639-12.34 \u00a4 \u00a412,34
64012.34 \u00a4 12,34
641-12.34 % 12,34%
64212.34 % 12,34
643
644test more affix setters
645set locale fr_FR
646set pattern %0.00
647begin
648format positivePrefix negativePrefix output
6490.648 booya cooya booya64,80
650
651test nan and infinity
652set locale en_US
653set pattern [0.00];(#)
654begin
655format output breaks
0f5d89e8 656Inf [\u221e]
2ca993e8 657-Inf (\u221e) K
0f5d89e8
A
658// J does not print the affixes
659// K prints \uFFFD
660// Q prints the affixes
661NaN NaN HKQ
2ca993e8
A
662
663test nan and infinity with multiplication
664set locale en
665set multiplier 100
666begin
667format output breaks
668Inf \u221e
669-Inf -\u221e
670NaN NaN K
671
672test nan and infinity with padding
673set locale en_US
674set pattern $$$0.00$
0f5d89e8 675set formatWidth 8
2ca993e8
A
676begin
677format padPosition output breaks
0f5d89e8
A
678Inf beforePrefix $$$\u221e$ K
679Inf afterPrefix $$$ \u221e$ K
680Inf beforeSuffix $$$\u221e $ K
681Inf afterSuffix $$$\u221e$ K
682// J does not print the affixes
683// K prints \uFFFD
684// Q gets $$$NaN$
685NaN beforePrefix NaN HKQ
686NaN afterPrefix NaN HKQ
687NaN beforeSuffix NaN HKQ
688NaN afterSuffix NaN HKQ
2ca993e8 689
f3c0d7a5 690test apply formerly localized patterns
2ca993e8 691begin
f3c0d7a5
A
692// documentation says localizedPattern is not supported, change to pattern
693locale pattern format output breaks
694en #0% 0.4376 44%
2ca993e8 695// This next test breaks JDK. JDK doesn't multiply by 100.
0f5d89e8
A
696fa \u0025\u00a0\u0023\u0030 0.4376 \u066a\u00a0\u06f4\u06f4 K
697
698test localized pattern basic symbol coverage
699begin
700locale localizedPattern toPattern breaks
701it #.##0,00 #,##0.00
702// JDK either doesn't know sl uses this character for minus sign
703// or doesn't support minus sign in localized pattern
704sl #.##0;#.##0− #,##0;#,##0- K
705// JDK does not have data for "×10^" in this locale
706en_SE 0,00×10^0;0,00×10^0- 0.00E0;0.00E0- K
707// JDK does not seem to transform the digits in localized patterns
708ar_SA #\u066C##\u0660\u066B\u0660\u0660;a# #,##0.00;a#,##0.00 K
2ca993e8
A
709
710test toPattern
711set locale en
712begin
713pattern toPattern breaks
0f5d89e8 714// All of the C and S failures in this section are because of functionally equivalent patterns
2ca993e8
A
715// JDK doesn't support any patterns with padding or both negative prefix and suffix
716// Breaks ICU4J See ticket 11671
0f5d89e8 717**0,000 **0,000 HK
2ca993e8
A
718**##0,000 **##0,000 K
719**###0,000 **###0,000 K
0f5d89e8 720**####0,000 **#,##0,000 JKP
2ca993e8 721###,000. #,000.
0f5d89e8 7220,000 #0,000 JP
2ca993e8 723.00 #.00
0f5d89e8
A
724000 #000 JP
725000,000 #,000,000 JP
2ca993e8 726pp#,000 pp#,000
0f5d89e8 72700.## #00.## JP
2ca993e8
A
728#,#00.025 #,#00.025
729// No secondary grouping in JDK
730#,##,###.02500 #,##,###.02500 K
731pp#,000;(#) pp#,000;(#,000) K
0f5d89e8 732**####,##,##0.0##;(#) **#,##,##,##0.0##;**(##,##,##0.0##) JKP
2ca993e8
A
733// No significant digits in JDK
734@@### @@### K
735@,@#,### @,@#,### K
7360.00E0 0.00E0
0f5d89e8
A
737// The following one works in JDK, probably because
738// it just returns the same string
739@@@##E0 @@@##E0
2ca993e8
A
740###0.00#E0 ###0.00#E0
741##00.00#E0 ##00.00#E0
7420.00E+00 0.00E+00 K
743000.00E00 000.00E00
744###0.00#E00 ###0.00#E00
745
746test parse
747set locale en
748set pattern +#,##0.0###;(#)
749begin
750parse output breaks
751+5,347.25 5347.25
752+5,347,.25 5347.25
753+5,347, 5347
754+5347,,, 5347
755+5347,,,d8 5347
756(5,347.25) -5347.25
0f5d89e8
A
757// H requires prefix and suffix for lenient parsing, but C doesn't
7585,347.25 5347.25 HK
759(5,347.25 -5347.25 H
760// S is successful at parsing this as -5347.25 in lenient mode
761-5,347.25 -5347.25 CHK
2ca993e8
A
762+3.52E4 35200
763(34.8E-3) -0.0348
764// JDK stops parsing at the spaces. JDK doesn't see space as a grouping separator
765(34 25E-1) -342.5 K
766(34,,25E-1) -342.5
0f5d89e8
A
767// Trailing grouping separators are not OK.
768// H fails; C/J/P stop at the offending separator.
769(34,,25,E-1) fail CJKP
770(34,,25,E-1) -342.5 H
771(34 25 E-1) -342.5 HK
772(34,,25 E-1) -342.5 CHK
2ca993e8 773// Spaces are not allowed after exponent symbol
0f5d89e8
A
774// C parses up to the E but H bails
775(34 25E -1) -3425 HK
2ca993e8
A
776+3.52EE4 3.52
777+1,234,567.8901 1234567.8901
778+1,23,4567.8901 1234567.8901
0f5d89e8 779// Fraction grouping is disabled by default
2ca993e8
A
780+1,23,4567.89,01 1234567.89
781+1,23,456.78.9 123456.78
782+12.34,56 12.34
0f5d89e8
A
783+79,,20,33 792033
784// JDK gets 79
785+79 20 33 792033 K
2ca993e8 786// Parsing stops at comma as it is different from other separators
0f5d89e8
A
787+79 20,33 7920 K
788+79,,20 33 7920
2ca993e8 789+ 79 79 K
0f5d89e8 790+,79,,20,33 792033
2ca993e8
A
791+7920d3 7920
792// Whitespace immediately after prefix doesn't count as digit separator
0f5d89e8
A
793// in C but is does in H
794+ ,79,,20,33 792033 HK
2ca993e8
A
795( 19 45) -1945 K
796// C allows trailing separators when there is a prefix and suffix.
0f5d89e8
A
797// H allows trailing separators only when there is just a prefix.
798// In this case, H just bails
799( 19 45 ) -1945 HK
2ca993e8 800(,,19,45) -1945
0f5d89e8
A
801// C parses to the space, but H bails
802(,,19 45) -19 H
803// H bails b/c comma different separator than space. C doesn't treat leading spaces
2ca993e8 804// as a separator.
0f5d89e8
A
805( 19,45) -1945 HK
806// H bails. Doesn't allow trailing separators when there is prefix and suffix.
807(,,19,45,) -1945 H
808// H bails on next 4 because H doesn't allow letters inside prefix and suffix.
2ca993e8 809// C will parse up to the letter.
0f5d89e8
A
810(,,19,45,d1) -1945 H
811(,,19,45d1) -1945 H
812( 19 45 d1) -1945 HK
813( 19 45d1) -1945 HK
814// H does allow trailing separator before a decimal point
2ca993e8
A
815(19,45,.25) -1945.25
816// 2nd decimal points are ignored
817+4.12.926 4.12
818
819test parse suffix
820set locale en
821set pattern #,##0.0###+;#-
822begin
823parse output breaks
0f5d89e8
A
824// C sees this as -3426, don't understand why.
825// J and K just bail.
8263426 3426 CHK
2ca993e8 8273426+ 3426
0f5d89e8
A
828// J bails; C and K see -34
82934 d1+ 34 CHK
2ca993e8 830// JDK sees this as -1234 for some reason
0f5d89e8 831// H bails b/c of trailing separators
2ca993e8 832// C parses until trailing separators, but sees -1234
0f5d89e8 8331,234,,,+ 1234 CHK
2ca993e8 8341,234- -1234
0f5d89e8
A
835// H and P bail because of trailing separators
8361,234,- -1234 HJP
2ca993e8 837// J bails here too
0f5d89e8 8381234 - -1234 H
2ca993e8
A
839
840
841
842test parse strict
843set locale en
0f5d89e8 844set pattern +#,##,##0.0###;(#)
2ca993e8 845set lenient 0
0f5d89e8 846set minGroupingDigits 2
2ca993e8
A
847begin
848parse output breaks
849+123d5 123
850+5347.25 5347.25
851// separators in wrong place cause failure, no separators ok.
0f5d89e8
A
852+65,347.25 65347.25
853(65347.25) -65347.25
854(65,347.25) -65347.25
2ca993e8
A
855// JDK does allow separators in the wrong place and parses as -5347.25
856(53,47.25) fail K
0f5d89e8
A
857// strict requires prefix or suffix, except in C
85865,347.25 fail
2ca993e8
A
859+3.52E4 35200
860(34.8E-3) -0.0348
861(3425E-1) -342.5
862// Strict doesn't allow separators in sci notation.
0f5d89e8
A
863(63,425) -63425
864// H does not allow grouping separators in scientific notation.
865(63,425E-1) -6342.5 H
2ca993e8
A
866// Both prefix and suffix needed for strict.
867// JDK accepts this and parses as -342.5
868(3425E-1 fail K
869+3.52EE4 3.52
0f5d89e8 870+12,34,567.8901 1234567.8901
2ca993e8
A
871// With strict digit separators don't have to be the right type
872// JDK doesn't acknowledge space as a separator
0f5d89e8 873+12 34 567.8901 1234567.8901 K
2ca993e8
A
874// In general the grouping separators have to match their expected
875// location exactly. The only exception is when string being parsed
876// have no separators at all.
0f5d89e8
A
877+12,345.67 12345.67
878// JDK doesn't require separators to be in the right place.
2ca993e8 879+1,23,4567.8901 fail K
0f5d89e8 880+1,234,567.8901 fail K
2ca993e8
A
881+1234,567.8901 fail K
882+1,234567.8901 fail K
883+1234567.8901 1234567.8901
0f5d89e8
A
884// Minimum grouping is not satisfied below, but that's ok
885// because minimum grouping is optional.
886+1,234.5 1234.5
2ca993e8 887// Comma after decimal means parse to a comma
0f5d89e8
A
888+1,23,456.78,9 123456.78
889// C and H fail upon seeing the second decimal point
890+1,23,456.78.9 123456.78 CH
2ca993e8
A
891+79 79
892+79 79
893+ 79 fail
894// JDK parses as -1945
895(1,945d1) fail K
896
0f5d89e8
A
897test parse strict scientific
898// See #13737: Old behavior should be retained in this case
899set locale en
900set pattern #E0
901set lenient 0
902begin
903parse output breaks
904123 123
905123E1 1230
906123E0 123
907123E 123
908
909test parse strict without prefix/suffix
910set locale en
911set pattern #
912set lenient 0
913begin
914parse output breaks
91512.34 12.34
916-12.34 -12.34
917// The following case passes only when setSignAlwaysShown is enabled
918+12.34 fail
919$12.34 fail
920
2ca993e8
A
921test parse integer only
922set locale en
923set pattern 0.00
924set parseIntegerOnly 1
925begin
926parse output breaks
92735 35
0f5d89e8
A
928// S accepts leading plus signs
929+35 35 CHK
2ca993e8
A
930-35 -35
9312.63 2
932-39.99 -39
933
934test parse no exponent flag
935set pattern 0
936set locale en
937begin
938parseNoExponent parse output breaks
939// JDK doesn't allow lowercase exponent but ICU4J and ICU4C do.
9400 5e2 500 K
9410 5.3E2 530
942// See ticket 11725
0f5d89e8
A
9431 5e2 5 H
9441 5.3E2 5.3 HK
2ca993e8
A
945
946test parse currency fail
947set pattern 0
948set locale en
949begin
950parse output outputCurrency breaks
0f5d89e8
A
951// Fixed in ticket 11735
95253.45 fail USD
2ca993e8
A
953
954test parse strange prefix
955set locale en
956set positivePrefix dd
957set negativePrefix ddd
958begin
959parse output
960dd4582 4582
961ddd4582 -4582
962
963test parse strange suffix
964set locale en
965set positiveSuffix dd
966set negativePrefix
967set negativeSuffix ddd
968begin
969parse output
9704582dd 4582
9714582ddd -4582
972
973test really strange suffix
974set locale en
975set positiveSuffix 9K
976set negativePrefix
977set negativeSuffix 9N
978begin
979parse output breaks
0f5d89e8
A
980// A non-greedy parse is required to pass these cases.
981// All of the implementations being tested are greedy.
9826549K 654 CHJKP
9836549N -654 CHJKP
2ca993e8
A
984
985test really strange prefix
986set locale en
987set positivePrefix 82
988set negativePrefix 28
989begin
990parse output
9918245 45
9922845 -45
993
0f5d89e8
A
994test parse pattern with quotes
995set locale en
996set pattern '-'#y
997begin
998parse output breaks
999-45y 45
1000
1001test parse with locale symbols
1002// The grouping separator in it_CH is an apostrophe
1003set locale it_CH
1004set pattern #,##0
1005begin
1006parse output breaks
1007१३ 13
1008१३.३१‍ 13.31
1009123'456 123456
1010524'11.3 52411.3
1011३'११‍ 311
1012
1013test parse with European-style comma/period
1014set locale pt
1015set pattern #,##0
1016begin
1017parse output breaks
1018123.456 123456
1019123,456 123.456
1020987,654.321 987.654
1021987,654 321 987.654
1022987.654,321 987654.321
1023
2ca993e8
A
1024test select
1025set locale sr
1026begin
1027format pattern plural
1028Inf 0 other
1029-Inf 0 other
1030NaN 0 other
1031Inf 0.0 other
1032-Inf 0.0 other
1033NaN 0.0 other
10341 0 one
10351 0.0 other
10362 0 few
10372 0.0 other
10382 0E0 other
10395.1 0.0 one
10405.09 0.0 one
1041
1042test parse currency ISO
1043set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
0f5d89e8 1044set locale en_GB
2ca993e8
A
1045begin
1046parse output outputCurrency breaks
0f5d89e8
A
104753.45 fail GBP
1048£53.45 53.45 GBP
1049$53.45 fail USD J
2ca993e8 105053.45 USD 53.45 USD
0f5d89e8
A
105153.45 GBP 53.45 GBP
1052USD 53.45 53.45 USD H
105353.45USD 53.45 USD CH
2ca993e8
A
1054USD53.45 53.45 USD
1055(7.92) USD -7.92 USD
0f5d89e8 1056(7.92) GBP -7.92 GBP
2ca993e8 1057(7.926) USD -7.926 USD
0f5d89e8
A
1058(7.926 USD) -7.926 USD CH
1059(USD 7.926) -7.926 USD CH
1060USD (7.926) -7.926 USD CH
1061USD (7.92) -7.92 USD CH
1062(7.92)USD -7.92 USD CH
1063USD(7.92) -7.92 USD CH
2ca993e8 1064(8) USD -8 USD
0f5d89e8 1065-8 USD -8 USD C
2ca993e8
A
106667 USD 67 USD
106753.45$ fail USD
0f5d89e8 1068US Dollars 53.45 53.45 USD H
2ca993e8 106953.45 US Dollars 53.45 USD
0f5d89e8 1070US Dollar 53.45 53.45 USD H
2ca993e8
A
107153.45 US Dollar 53.45 USD
1072US Dollars53.45 53.45 USD
0f5d89e8 107353.45US Dollars 53.45 USD CH
2ca993e8
A
1074US Dollar53.45 53.45 USD
1075US Dollat53.45 fail USD
0f5d89e8
A
107653.45US Dollar 53.45 USD CH
1077US Dollars (53.45) -53.45 USD CH
2ca993e8 1078(53.45) US Dollars -53.45 USD
0f5d89e8
A
1079(53.45) Euros -53.45 EUR
1080US Dollar (53.45) -53.45 USD CH
2ca993e8 1081(53.45) US Dollar -53.45 USD
0f5d89e8
A
1082US Dollars(53.45) -53.45 USD CH
1083(53.45)US Dollars -53.45 USD CH
1084US Dollar(53.45) -53.45 USD CH
2ca993e8 1085US Dollat(53.45) fail USD
0f5d89e8 1086(53.45)US Dollar -53.45 USD CH
2ca993e8
A
1087
1088
1089test parse currency ISO negative
1090set pattern 0.00 \u00a4\u00a4;-# \u00a4\u00a4
0f5d89e8 1091set locale en_GB
2ca993e8
A
1092begin
1093parse output outputCurrency breaks
0f5d89e8
A
109453.45 fail GBP
1095£53.45 53.45 GBP
1096$53.45 fail USD J
2ca993e8 109753.45 USD 53.45 USD
0f5d89e8
A
109853.45 GBP 53.45 GBP
1099USD 53.45 53.45 USD H
110053.45USD 53.45 USD CH
2ca993e8
A
1101USD53.45 53.45 USD
1102-7.92 USD -7.92 USD
0f5d89e8 1103-7.92 GBP -7.92 GBP
2ca993e8 1104-7.926 USD -7.926 USD
0f5d89e8
A
1105USD -7.926 -7.926 USD CH
1106-7.92USD -7.92 USD CH
1107USD-7.92 -7.92 USD CH
2ca993e8
A
1108-8 USD -8 USD
110967 USD 67 USD
0f5d89e8
A
111053.45$ 53.45 USD CH
1111US Dollars 53.45 53.45 USD H
2ca993e8 111253.45 US Dollars 53.45 USD
0f5d89e8 1113US Dollar 53.45 53.45 USD H
2ca993e8
A
111453.45 US Dollar 53.45 USD
1115US Dollars53.45 53.45 USD
0f5d89e8 111653.45US Dollars 53.45 USD CH
2ca993e8
A
1117US Dollar53.45 53.45 USD
1118US Dollat53.45 fail USD
0f5d89e8 111953.45US Dollar 53.45 USD CH
2ca993e8
A
1120
1121
1122test parse currency long
1123set pattern 0.00 \u00a4\u00a4\u00a4;(#) \u00a4\u00a4\u00a4
0f5d89e8 1124set locale en_GB
2ca993e8
A
1125begin
1126parse output outputCurrency breaks
0f5d89e8
A
1127// H throws a NullPointerException on the first case
112853.45 fail GBP
1129£53.45 53.45 GBP
1130$53.45 fail USD J
2ca993e8 113153.45 USD 53.45 USD
0f5d89e8
A
113253.45 GBP 53.45 GBP
1133USD 53.45 53.45 USD H
113453.45USD 53.45 USD CH
2ca993e8
A
1135USD53.45 53.45 USD
1136(7.92) USD -7.92 USD
0f5d89e8 1137(7.92) GBP -7.92 GBP
2ca993e8 1138(7.926) USD -7.926 USD
0f5d89e8
A
1139(7.926 USD) -7.926 USD CH
1140(USD 7.926) -7.926 USD CH
1141USD (7.926) -7.926 USD CH
1142USD (7.92) -7.92 USD CH
1143(7.92)USD -7.92 USD CH
1144USD(7.92) -7.92 USD CH
2ca993e8 1145(8) USD -8 USD
0f5d89e8 1146-8 USD -8 USD C
2ca993e8 114767 USD 67 USD
0f5d89e8
A
1148// H throws a NullPointerException on the next case
114953.45$ 53.45 USD CH
1150US Dollars 53.45 53.45 USD H
2ca993e8 115153.45 US Dollars 53.45 USD
0f5d89e8 1152US Dollar 53.45 53.45 USD H
2ca993e8
A
115353.45 US Dollar 53.45 USD
1154US Dollars53.45 53.45 USD
0f5d89e8 115553.45US Dollars 53.45 USD CH
2ca993e8
A
1156US Dollar53.45 53.45 USD
1157US Dollat53.45 fail USD
0f5d89e8 115853.45US Dollar 53.45 USD CH
2ca993e8
A
1159
1160
1161test parse currency short
1162set pattern 0.00 \u00a4;(#) \u00a4
0f5d89e8 1163set locale en_GB
2ca993e8
A
1164begin
1165parse output outputCurrency breaks
0f5d89e8
A
116653.45 fail GBP
1167£53.45 53.45 GBP
1168$53.45 fail USD J
2ca993e8 116953.45 USD 53.45 USD
0f5d89e8
A
117053.45 GBP 53.45 GBP
1171USD 53.45 53.45 USD H
117253.45USD 53.45 USD CH
2ca993e8
A
1173USD53.45 53.45 USD
1174(7.92) USD -7.92 USD
0f5d89e8 1175(7.92) GBP -7.92 GBP
2ca993e8 1176(7.926) USD -7.926 USD
0f5d89e8
A
1177(7.926 USD) -7.926 USD CH
1178(USD 7.926) -7.926 USD CH
1179USD (7.926) -7.926 USD CH
1180USD (7.92) -7.92 USD CH
1181(7.92)USD -7.92 USD CH
1182USD(7.92) -7.92 USD CH
2ca993e8 1183(8) USD -8 USD
0f5d89e8 1184-8 USD -8 USD C
2ca993e8 118567 USD 67 USD
0f5d89e8
A
118653.45$ 53.45 USD CH
1187US Dollars 53.45 53.45 USD H
2ca993e8 118853.45 US Dollars 53.45 USD
0f5d89e8 1189US Dollar 53.45 53.45 USD H
2ca993e8
A
119053.45 US Dollar 53.45 USD
1191US Dollars53.45 53.45 USD
0f5d89e8 119253.45US Dollars 53.45 USD CH
2ca993e8
A
1193US Dollar53.45 53.45 USD
1194US Dollat53.45 fail USD
0f5d89e8 119553.45US Dollar 53.45 USD CH
2ca993e8
A
1196
1197
1198test parse currency short prefix
1199set pattern \u00a40.00;(\u00a4#)
0f5d89e8 1200set locale en_GB
2ca993e8
A
1201begin
1202parse output outputCurrency breaks
0f5d89e8
A
120353.45 fail GBP
1204£53.45 53.45 GBP
1205$53.45 fail USD J
120653.45 USD 53.45 USD C
120753.45 GBP 53.45 GBP C
1208USD 53.45 53.45 USD H
120953.45USD 53.45 USD CH
2ca993e8 1210USD53.45 53.45 USD
0f5d89e8
A
1211// C and P fail these because '(' is an incomplete prefix.
1212(7.92) USD -7.92 USD CHJP
1213(7.92) GBP -7.92 GBP CHJP
1214(7.926) USD -7.926 USD CHJP
1215(7.926 USD) -7.926 USD CHJP
1216(USD 7.926) -7.926 USD H
1217USD (7.926) -7.926 USD CHJP
1218USD (7.92) -7.92 USD CHJP
1219(7.92)USD -7.92 USD CHJP
1220USD(7.92) -7.92 USD CHJP
1221(8) USD -8 USD CHJP
1222-8 USD -8 USD C
122367 USD 67 USD C
122453.45$ 53.45 USD CH
1225US Dollars 53.45 53.45 USD H
2ca993e8 122653.45 US Dollars 53.45 USD
0f5d89e8 1227US Dollar 53.45 53.45 USD H
2ca993e8
A
122853.45 US Dollar 53.45 USD
1229US Dollars53.45 53.45 USD
0f5d89e8 123053.45US Dollars 53.45 USD CH
2ca993e8 1231US Dollar53.45 53.45 USD
0f5d89e8 123253.45US Dollar 53.45 USD CH
2ca993e8
A
1233
1234test format foreign currency
1235set locale fa_IR
0f5d89e8 1236set currency IRR
2ca993e8
A
1237begin
1238pattern format output breaks
1239\u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 # 1235 \u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 K
1240\u00a4\u00a4 0.00;\u00a4\u00a4 -# 1235 IRR \u06F1\u06F2\u06F3\u06F5 K
1241\u00a4 0.00;\u00a4 -# 1235 \u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 K
1242
1243test parse foreign currency symbol
1244set pattern \u00a4 0.00;\u00a4 -#
1245set locale fa_IR
1246begin
0f5d89e8 1247parse output outputCurrency breaks
2ca993e8
A
1248\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1249IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
0f5d89e8
A
1250// P fails here because this currency name is in the Trie only, but it has the same prefix as the non-Trie currency
1251\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR JP
2ca993e8
A
1252IRR 1235 1235 IRR
1253\u0631\u06cc\u0627\u0644 1235 1235 IRR
0f5d89e8 1254\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR JP
2ca993e8
A
1255
1256test parse foreign currency ISO
1257set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 -#
1258set locale fa_IR
1259begin
0f5d89e8 1260parse output outputCurrency breaks
2ca993e8
A
1261\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1262IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
0f5d89e8 1263\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR JP
2ca993e8
A
1264IRR 1235 1235 IRR
1265\u0631\u06cc\u0627\u0644 1235 1235 IRR
0f5d89e8 1266\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR JP
2ca993e8
A
1267
1268test parse foreign currency full
1269set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 -#
1270set locale fa_IR
1271begin
0f5d89e8 1272parse output outputCurrency breaks
2ca993e8
A
1273\u0631\u06cc\u0627\u0644 \u06F1\u06F2\u06F3\u06F5 1235 IRR
1274IRR \u06F1\u06F2\u06F3\u06F5 1235 IRR
0f5d89e8 1275\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 \u06F1\u06F2\u06F3\u06F5 1235 IRR JP
2ca993e8
A
1276IRR 1235 1235 IRR
1277\u0631\u06cc\u0627\u0644 1235 1235 IRR
0f5d89e8 1278\u0631\u06cc\u0627\u0644 \u0627\u06cc\u0631\u0627\u0646 1235 1235 IRR JP
2ca993e8
A
1279
1280test parse currency with foreign symbols symbol english
1281set pattern \u00a4 0.00;\u00a4 (#)
1282set locale en_US
1283begin
1284parse output outputCurrency
1285EUR 7.82 7.82 EUR
1286\u20ac 7.82 7.82 EUR
1287Euro 7.82 7.82 EUR
1288Euros 7.82 7.82 EUR
1289
1290test parse currency with foreign symbols ISO english
1291set pattern \u00a4\u00a4 0.00;\u00a4\u00a4 (#)
1292set locale en_US
1293begin
1294parse output outputCurrency
1295EUR 7.82 7.82 EUR
1296\u20ac 7.82 7.82 EUR
1297Euro 7.82 7.82 EUR
1298Euros 7.82 7.82 EUR
1299
1300test parse currency with foreign symbols full english
1301set pattern \u00a4\u00a4\u00a4 0.00;\u00a4\u00a4\u00a4 (#)
1302set locale en_US
1303begin
1304parse output outputCurrency
1305EUR 7.82 7.82 EUR
1306\u20ac 7.82 7.82 EUR
1307Euro 7.82 7.82 EUR
1308Euros 7.82 7.82 EUR
1309
0f5d89e8
A
1310test parse currency without currency mode
1311// Should accept a symbol associated with the currency specified by the API,
1312// but should not traverse the full currency data.
1313set locale en_US
1314set pattern \u00a4#,##0.00
1315begin
1316parse currency output breaks
1317$52.41 USD 52.41
1318USD52.41 USD 52.41 K
1319\u20ac52.41 USD fail
1320EUR52.41 USD fail
1321$52.41 EUR fail
1322USD52.41 EUR fail
1323\u20ac52.41 EUR 52.41 K
1324EUR52.41 EUR 52.41
1325
2ca993e8
A
1326test parse currency ISO strict
1327set pattern 0.00 \u00a4\u00a4;(#) \u00a4\u00a4
1328set locale en_US
1329set lenient 0
1330begin
1331parse output outputCurrency breaks
0f5d89e8 1332$53.45 53.45 USD JP
2ca993e8
A
133353.45 USD 53.45 USD
1334USD 53.45 fail USD
133553.45USD fail USD
0f5d89e8 1336USD53.45 53.45 USD JP
2ca993e8
A
1337(7.92) USD -7.92 USD
1338(7.92) EUR -7.92 EUR
1339(7.926) USD -7.926 USD
1340(7.926 USD) fail USD
1341(USD 7.926) fail USD
1342USD (7.926) fail USD
1343USD (7.92) fail USD
1344(7.92)USD fail USD
1345USD(7.92) fail USD
1346(8) USD -8 USD
0f5d89e8 1347-8 USD fail USD H
2ca993e8
A
134867 USD 67 USD
134953.45$ fail USD
1350US Dollars 53.45 fail USD
135153.45 US Dollars 53.45 USD
1352US Dollar 53.45 fail USD
135353.45 US Dollar 53.45 USD
0f5d89e8 1354US Dollars53.45 53.45 USD JP
2ca993e8 135553.45US Dollars fail USD
0f5d89e8 1356US Dollar53.45 53.45 USD JP
2ca993e8
A
1357US Dollat53.45 fail USD
135853.45US Dollar fail USD
1359US Dollars (53.45) fail USD
1360(53.45) US Dollars -53.45 USD
1361US Dollar (53.45) fail USD
1362(53.45) US Dollar -53.45 USD
1363US Dollars(53.45) fail USD
1364(53.45)US Dollars fail USD
1365US Dollar(53.45) fail USD
1366US Dollat(53.45) fail USD
1367(53.45)US Dollar fail USD
1368
1369test ticket 10436
1370set locale en
1371set roundingMode ceiling
1372set minFractionDigits 0
1373set maxFractionDigits 0
1374begin
1375format output breaks
0f5d89e8
A
1376-0.99 -0 HK
1377
1378test parse decimalPatternMatchRequired
1379set locale en
1380set decimalPatternMatchRequired 1
1381begin
1382pattern parse output breaks
1383// K doesn't support this feature.
13840 123 123
13850 123. fail CHK
13860 1.23 fail CHK
13870 -513 -513
13880 -513. fail CHK
13890 -5.13 fail CHK
13900.0 123 fail K
13910.0 123. 123 C
13920.0 1.23 1.23 C
13930.0 -513 fail K
13940.0 -513. -513
13950.0 -5.13 -5.13
1396
1397test parse minus sign
1398set locale en
1399set pattern #
1400begin
1401pattern parse output breaks
1402# -123 -123
1403# - 123 -123 HK
1404# -123 -123 HK
1405# - 123 -123 HK
1406# 123- 123
1407# 123 - 123
1408#;#- 123- -123
1409#;#- 123 - -123 HK
1410
1411test parse case sensitive
1412set locale en
1413set lenient 1
1414set pattern Aa#
1415begin
1416parse parseCaseSensitive output breaks
1417Aa1.23 1 1.23
1418Aa1.23 0 1.23
1419AA1.23 1 fail
1420// H and K do not support case-insensitive parsing for prefix/suffix.
1421// H supports it for the exponent separator, but not K.
1422AA1.23 0 1.23 CHK
1423aa1.23 1 fail
1424aa1.23 0 1.23 CHK
1425Aa1.23E3 1 1230
1426Aa1.23E3 0 1230
1427Aa1.23e3 1 1.23 CH
1428Aa1.23e3 0 1230 K
1429NaN 1 NaN K
1430NaN 0 NaN K
1431nan 1 fail
1432nan 0 NaN CHK
1433
1434test parse infinity and scientific notation overflow
1435set locale en
1436set lenient 1
1437begin
1438parse output breaks
1439NaN NaN K
1440// JDK returns zero
14411E999999999999999 Inf K
1442-1E999999999999999 -Inf K
14431E-99999999999999 0.0
1444// Note: The test suite code doesn't properly check for 0.0 vs. -0.0
1445-1E-99999999999999 -0.0
14461E2147483648 Inf K
14471E2147483647 Inf K
1448// H, J and K get Infinity
14491E2147483646 1E+2147483646 HJK
14501E-2147483649 0
14511E-2147483648 0
1452// H and K return zero here
14531E-2147483647 1E-2147483647 HJK
14541E-2147483646 1E-2147483646 HJK
1455
1456test format push limits
1457set locale en
1458set minFractionDigits 2
1459set roundingMode halfDown
1460begin
1461maxFractionDigits format output breaks
1462100 987654321987654321 987654321987654321.00
1463100 987654321.987654321 987654321.987654321
1464100 9999999999999.9950000000001 9999999999999.9950000000001
14652 9999999999999.9950000000001 10000000000000.00
14662 9999999.99499999 9999999.99
1467// K doesn't support halfDown rounding mode?
14682 9999999.995 9999999.99 K
14692 9999999.99500001 10000000.00
1470100 56565656565656565656565656565656565656565656565656565656565656 56565656565656565656565656565656565656565656565656565656565656.00
1471100 454545454545454545454545454545.454545454545454545454545454545 454545454545454545454545454545.454545454545454545454545454545
1472100 0.0000000000000000000123 0.0000000000000000000123
1473100 -78787878787878787878787878787878 -78787878787878787878787878787878.00
1474100 -8989898989898989898989.8989898989898989 -8989898989898989898989.8989898989898989
1475
1476test ticket 11230
1477set locale en
1478begin
1479pattern lenient parse output breaks
1480// Groups after the first group need 2 digits to be accepted.
1481// JDK does not see space as grouping and parses most of these as 9.
1482#,##0 1 9 9 9 CH
1483#,##0 1 9 99 999 K
1484#,##0 1 9 999 9999 K
1485#,##0 1 9 9 9 9 CH
1486#,##0 1 ,9 9
1487#,##0 1 99,.0 99
1488#,##0 1 9 9. 9 CH
1489#,##0 1 9 99. 999 K
14900 1 9 9 9
14910 1 9 99 9
14920 1 9 999 9
14930 1 9 9 9 9
14940 1 ,9 fail
14950 1 99,.0 99
14960 1 9 9. 9
14970 1 9 99. 9
1498#,##0 0 9 9 fail K
1499#,##0 0 9 99 fail K
1500#,##0 0 9 999 9999 K
1501#,##0 0 9 9 9 fail K
1502#,##0 0 ,9 fail K
1503#,##0 0 99,.0 fail K
1504#,##0 0 9 9. fail K
1505#,##0 0 9 99. fail K
15060 0 9 9 9
15070 0 9 99 9
15080 0 9 999 9
15090 0 9 9 9 9
15100 0 ,9 fail
15110 0 99,.0 99
15120 0 9 9. 9
15130 0 9 99. 9
1514
1515test more strict grouping parse
1516set locale en
1517set pattern #,##,##0
1518begin
1519lenient parse output breaks
15201 1,23,, 123
15210 9999, 9999
15220 1,23,, fail K
1523
1524test parse ignorables
1525set locale ar
1526// Note: Prefixes contain RLMs, as do some of the test cases.
1527set pattern x a‎b0c df
1528set negativePrefix y g‎h
1529set negativeSuffix i jk
1530begin
1531parse output breaks
1532x a‎b56c df 56
1533x a‎b56c df 56 K
1534x ab56c df 56 K
1535x ab56c df 56 HK
1536x ab56c df 56 K
1537x ab56 56 HK
1538x a b56 56 HK
153956cdf 56 HK
154056c df 56 HK
154156cd f 56 HK
154256c‎d‎f 56 HK
154356cdf 56 HK
154456c d‎f 56 HK
154556‎c df 56 HK
1546y g‎h56i jk -56
1547y g‎h56i jk -56 K
1548y gh56i jk -56 K
1549y gh56i jk -56 HK
1550y gh56i jk -56 K
1551y gh56 -56 HK
1552y g h56 -56 HK
1553// S stops parsing after the 'i' for these and returns -56
1554// C stops before the 'i' and gets 56
155556ijk -56 CHK
155656i jk -56 CHK
155756ij k -56 CHK
155856i‎j‎k -56 CHK
155956ijk -56 CHK
156056i j‎k -56 CHK
156156‎i jk -56 CHK
1562// S and C get 56 (accepts ' ' gs grouping); H and K get null
15635 6 fail CJP
15645‎6 5 HK
1565
1566test parse spaces in grouping
1567// This test gives the ideal behavior of these cases, which
1568// none of the implementations currently support.
1569// Similar to the test above for ticket #11230
1570set locale en
1571set pattern #,##0
1572begin
1573parse output breaks
15741 2 1 CH
15751 23 123 K
1576// K gets 1 here; doesn't pick up the grouping separator
15771 234 1234 K
1578
1579test rounding increment significant digits
1580// This test is for #13111
1581set locale en
1582set pattern 0.1
1583set useSigDigits 1
1584set maxSigDigits 2
1585begin
1586format output breaks
1587// C and J get "1"
1588// P gets "1.0"
1589// K gets "1.1" (??)
15900.975 0.98 CHJKP
1591
1592test lenient parse currency match
1593// This test is for #13112
1594set locale en
1595set pattern ¤#,##0.00
1596begin
1597parse output breaks
1598// H and K get null
15991.23!@#$%^ 1.23 HK
1600
1601test percentage parsing multiplier
1602// This test is for #13114
1603set locale en
1604set pattern 0%
1605begin
1606parse output breaks
160755% 0.55
1608// H and K get null
1609// C and P scale by 100 even if the percent sign is not present
161055 0.55 HK
1611
1612test trailing grouping separators in pattern
1613// This test is for #13115
1614set locale en
1615begin
1616pattern format output breaks
1617$0M 123456 $123456M
1618// The following patterns are rejected as malformed.
1619$0,M 123456 fail
1620$0,,M 123456 fail
1621
1622test empty negative subpattern
1623// This test is for #13117
1624set locale en
1625begin
1626pattern format output breaks
16270 -15 -15
16280; -15 -15
1629// C, H and K still prepend a '-' even though the pattern says otherwise
16300;0 -15 15 CHK
1631
1632test percentage multiplier parsing
1633// This test is for #13129
1634set locale en
1635set pattern 0%
1636begin
1637parse output breaks
16389223372036854775807% 92233720368547758.07 K
1639
1640test sign always shown
1641set locale en
1642set pattern 0
1643set signAlwaysShown 1
1644begin
1645format output breaks
1646// C, H and K do not support this feature
164742 +42 CHK
16480 +0 CHK
1649-42 -42
1650
1651test parse strict with plus sign
1652set locale en
1653set pattern 0
1654set signAlwaysShown 1
1655begin
1656lenient parse output breaks
16571 42 42
16581 -42 -42
16591 +42 42 CHK
16601 0 0
16611 +0 0 CHK
16620 42 fail CHK
16630 -42 -42
16640 +42 42 CHK
16650 0 fail CHK
16660 +0 0 CHK
1667
1668test parse with scientific-separator-affix overlap
1669set locale en
1670begin
1671pattern lenient parse output breaks
16720E0','x 1 5E3,x 5000
16730E0','x 0 5E3,x 5000
16740E0'.'x 1 5E3.x 5000
16750E0'.'x 0 5E3.x 5000
1676
1677test parse lowercase currency
1678set locale en
1679set pattern ¤¤0
1680set currency USD
1681begin
1682parse output outputCurrency breaks
1683USD123 123 USD
1684USD 123 123 USD H
1685// C does not currently accept case-insensitive ISO codes
1686usd123 123 USD C
1687usd 123 123 USD CH
1688Usd123 123 USD C
1689Usd 123 123 USD CH
1690US$123 123 USD C
1691us$123 fail fail
1692Us$123 fail fail
1693123 US dollars 123 USD
1694123 US DOLLARS 123 USD
1695123 us dollars 123 USD
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
2ca993e8 1737