[Unicode]   Common Locale Data Repository : Bug Tracking Home | Site Map | Search
 

Changeset 13470


Ignore:
Timestamp:
05/18/17 13:44:47 (12 months ago)
Author:
mdavis
Message:

cldrbug 9507: fix examples. Found many problems that needed fixing, since a test was disabled that shouldn't have been.

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/cldr-unittest/src/org/unicode/cldr/unittest/TestExampleGenerator.java

    r13322 r13470  
    11package org.unicode.cldr.unittest; 
    22 
    3 import java.util.Arrays; 
    43import java.util.HashMap; 
    54import java.util.HashSet; 
     
    1817import org.unicode.cldr.util.With; 
    1918 
     19import com.google.common.collect.ImmutableSet; 
    2020import com.ibm.icu.dev.test.TestFmwk; 
    2121import com.ibm.icu.dev.util.CollectionUtilities; 
     
    3434                "one", 
    3535                "〖❬1,23 ❭value-one〗〖❬0,00 ❭value-one〗", 
    36                 "〖❬1,23❭_❬dollar des États-Unis❭〗〖❬1,23❭_❬euro❭〗〖❬0,00❭_❬dollar des États-Unis❭〗〖❬0,00❭_❬euro❭〗" }, 
     36            "〖❬1,23❭_❬dollar des États-Unis❭〗〖❬1,23❭_❬euro❭〗〖❬0,00❭_❬dollar des États-Unis❭〗〖❬0,00❭_❬euro❭〗" }, 
    3737            { 
    3838                "fr", 
    3939                "other", 
    4040                "〖❬2,34 ❭value-other〗〖❬3,45 ❭value-other〗", 
    41                 "〖❬2,34❭_❬dollars des États-Unis❭〗〖❬2,34❭_❬euros❭〗〖❬3,45❭_❬dollars des États-Unis❭〗〖❬3,45❭_❬euros❭〗" }, 
     41            "〖❬2,34❭_❬dollars des États-Unis❭〗〖❬2,34❭_❬euros❭〗〖❬3,45❭_❬dollars des États-Unis❭〗〖❬3,45❭_❬euros❭〗" }, 
    4242            { "en", "one", "〖❬1 ❭Bermudan dollar〗", 
    43                 "〖❬1❭ ❬US dollar❭〗〖❬1❭ ❬euro❭〗" }, 
     43            "〖❬1❭ ❬US dollar❭〗〖❬1❭ ❬euro❭〗" }, 
    4444            { "en", "other", 
    4545                "〖❬1.23 ❭Bermudan dollars〗〖❬0.00 ❭Bermudan dollars〗", 
    46                 "〖❬1.23❭ ❬US dollars❭〗〖❬1.23❭ ❬euros❭〗〖❬0.00❭ ❬US dollars❭〗〖❬0.00❭ ❬euros❭〗" }, }; 
     46            "〖❬1.23❭ ❬US dollars❭〗〖❬1.23❭ ❬euros❭〗〖❬0.00❭ ❬US dollars❭〗〖❬0.00❭ ❬euros❭〗" }, }; 
    4747        String sampleCurrencyPatternPrefix = "//ldml/numbers/currencyFormats[@numberSystem=\"latn\"]/unitPattern[@count=\""; 
    4848        String sampleCurrencyPrefix = "//ldml/numbers/currencies/currency[@type=\"BMD\"]/displayName[@count=\""; 
     
    7171    } 
    7272 
    73     static final Set<String> OK_TO_MISS_EXAMPLES = new HashSet<String>( 
    74         Arrays.asList( 
    75             "//ldml/layout/orientation/characterOrder", 
    76             "//ldml/layout/orientation/lineOrder", 
    77             "//ldml/characters/moreInformation", 
    78             "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/infinity", 
    79             "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/list", 
    80             "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/nan", 
    81             "//ldml/numbers/currencies/currency[@type=\"([^\"]*+)\"]/displayName", 
    82             "//ldml/localeDisplayNames/measurementSystemNames/measurementSystemName[@type=\"([^\"]*+)\"]", 
    83             // old format 
    84             "//ldml/numbers/currencyFormats/currencySpacing/afterCurrency/currencyMatch", 
    85             "//ldml/numbers/currencyFormats/currencySpacing/afterCurrency/insertBetween", 
    86             "//ldml/numbers/currencyFormats/currencySpacing/afterCurrency/surroundingMatch", 
    87             "//ldml/numbers/currencyFormats/currencySpacing/beforeCurrency/currencyMatch", 
    88             "//ldml/numbers/currencyFormats/currencySpacing/beforeCurrency/insertBetween", 
    89             "//ldml/numbers/currencyFormats/currencySpacing/beforeCurrency/surroundingMatch", 
    90             "//ldml/numbers/symbols/infinity", 
    91             "//ldml/numbers/symbols/list", 
    92             "//ldml/numbers/symbols/nan", 
    93             "//ldml/posix/messages/nostr", 
    94             "//ldml/posix/messages/yesstr", 
    95             // TODO Add examples 
    96             "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/beforeCurrency/currencyMatch", 
    97             "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/beforeCurrency/surroundingMatch", 
    98             "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/beforeCurrency/insertBetween", 
    99             "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/afterCurrency/currencyMatch", 
    100             "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/afterCurrency/surroundingMatch", 
    101             "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/afterCurrency/insertBetween", 
    102  
    103             "*")); 
    104     static final Set<String> OK_TO_MISS_BACKGROUND = new HashSet<String>( 
    105         Arrays 
    106             .asList( 
    107                 "//ldml/numbers/defaultNumberingSystem", 
    108                 "//ldml/numbers/otherNumberingSystems/native", 
    109                 // TODO fix formatting 
    110                 "//ldml/characters/exemplarCharacters", 
    111                 "//ldml/characters/exemplarCharacters[@type=\"([^\"]*+)\"]", 
    112                 // TODO Add background 
    113                 "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateFormats/dateFormatLength[@type=\"([^\"]*+)\"]/dateFormat[@type=\"([^\"]*+)\"]/pattern[@type=\"([^\"]*+)\"]", 
    114                 "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/timeFormats/timeFormatLength[@type=\"([^\"]*+)\"]/timeFormat[@type=\"([^\"]*+)\"]/pattern[@type=\"([^\"]*+)\"]", 
    115                 "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateTimeFormats/availableFormats/dateFormatItem[@id=\"([^\"]*+)\"]", 
    116                 "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/exemplarCity", 
    117                 "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/long/daylight", 
    118                 "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/short/generic", 
    119                 "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/short/standard", 
    120                 "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/short/daylight", 
    121                 "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/long/generic", 
    122                 "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/long/standard", 
    123                 "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/long/daylight", 
    124                 "//ldml/units/durationUnit[@type=\"([^\"]*+)\"]/durationUnitPattern", 
    125  
    126                 "*")); 
     73    static final Set<String> DELIBERATE_EXCLUDED_EXAMPLES = ImmutableSet.of( 
     74        // WARNING - do not disable the test by putting in too broad a match. Make sure the paths are reasonably granular. 
     75 
     76        // ======== 
     77        // DELIBERATE EXCLUSIONS; no need to have these in context. 
     78        // ======== 
     79 
     80        "//ldml/layout/orientation/characterOrder", 
     81        "//ldml/layout/orientation/lineOrder", 
     82        "//ldml/characters/moreInformation", 
     83        "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/infinity", 
     84        "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/list", 
     85        "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/nan", 
     86        "//ldml/numbers/currencies/currency[@type=\"([^\"]*+)\"]/displayName", 
     87        "//ldml/localeDisplayNames/measurementSystemNames/measurementSystemName[@type=\"([^\"]*+)\"]", 
     88        // old format 
     89        "//ldml/numbers/symbols/infinity", 
     90        "//ldml/numbers/symbols/list", 
     91        "//ldml/numbers/symbols/nan", 
     92        "//ldml/posix/messages/nostr", 
     93        "//ldml/posix/messages/yesstr", 
     94        "//ldml/contextTransforms/contextTransformUsage[@type=\"([^\"]*+)\"]/contextTransform[@type=\"([^\"]*+)\"]", 
     95        "//ldml/characters/exemplarCharacters", 
     96        "//ldml/characters/exemplarCharacters[@type=\"([^\"]*+)\"]", 
     97        "//ldml/characters/parseLenients.*", 
     98        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/months/monthContext[@type=\"([^\"]*+)\"]/monthWidth[@type=\"([^\"]*+)\"]/month[@type=\"([^\"]*+)\"]", 
     99        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/days/dayContext[@type=\"([^\"]*+)\"]/dayWidth[@type=\"([^\"]*+)\"]/day[@type=\"([^\"]*+)\"]", 
     100        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/quarters/quarterContext[@type=\"([^\"]*+)\"]/quarterWidth[@type=\"([^\"]*+)\"]/quarter[@type=\"([^\"]*+)\"]", 
     101        "//ldml/dates/fields/field[@type=\"([^\"]*+)\"]/displayName", 
     102        "//ldml/dates/fields/field[@type=\"([^\"]*+)\"]/relative[@type=\"([^\"]*+)\"]", 
     103        "//ldml/dates/fields/field[@type=\"([^\"]*+)\"]/relativeTime[@type=\"([^\"]*+)\"]/relativeTimePattern[@count=\"([^\"]*+)\"]", 
     104        "//ldml/dates/fields/field[@type=\"([^\"]*+)\"]/relativePeriod", 
     105        "//ldml/dates/fields/field[@type=\"([^\"]*+)\"]/displayName[@alt=\"([^\"]*+)\"]", 
     106        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/cyclicNameSets/cyclicNameSet[@type=\"([^\"]*+)\"]/cyclicNameContext[@type=\"([^\"]*+)\"]/cyclicNameWidth[@type=\"([^\"]*+)\"]/cyclicName[@type=\"([^\"]*+)\"]", 
     107 
     108        "//ldml/numbers/minimalPairs/pluralMinimalPairs[@count=\"([^\"]*+)\"]", 
     109        "//ldml/numbers/minimalPairs/ordinalMinimalPairs[@ordinal=\"([^\"]*+)\"]", 
     110        "//ldml/characterLabels/characterLabelPattern[@type=\"([^\"]*+)\"]", 
     111        "//ldml/characterLabels/characterLabelPattern[@type=\"([^\"]*+)\"][@count=\"([^\"]*+)\"]", 
     112        "//ldml/characterLabels/characterLabel[@type=\"([^\"]*+)\"]", 
     113 
     114        "//ldml/characters/parseLenients[@scope=\"([^\"]*+)\"][@level=\"([^\"]*+)\"]/parseLenient[@sample=\"([^\"]*+)\"]" 
     115 
     116        ); 
     117 
     118    /** 
     119        TEMPORARY EXCLUSIONS; TODO: add examples later  
     120     */ 
     121    static final Set<String> TEMPORARY_EXCLUDED_EXAMPLES = ImmutableSet.of( 
     122 
     123        "//ldml/numbers/currencyFormats/currencySpacing/beforeCurrency/currencyMatch", 
     124        "//ldml/numbers/currencyFormats/currencySpacing/beforeCurrency/surroundingMatch", 
     125        "//ldml/numbers/currencyFormats/currencySpacing/beforeCurrency/insertBetween", 
     126        "//ldml/numbers/currencyFormats/currencySpacing/afterCurrency/currencyMatch", 
     127        "//ldml/numbers/currencyFormats/currencySpacing/afterCurrency/surroundingMatch", 
     128        "//ldml/numbers/currencyFormats/currencySpacing/afterCurrency/insertBetween", 
     129        "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/beforeCurrency/currencyMatch", 
     130        "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/beforeCurrency/surroundingMatch", 
     131        "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/beforeCurrency/insertBetween", 
     132        "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/afterCurrency/currencyMatch", 
     133        "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/afterCurrency/surroundingMatch", 
     134        "//ldml/numbers/currencyFormats[@numberSystem=\"([^\"]*+)\"]/currencySpacing/afterCurrency/insertBetween", 
     135 
     136        "//ldml/localeDisplayNames/variants/variant[@type=\"([^\"]*+)\"]", 
     137        "//ldml/localeDisplayNames/keys/key[@type=\"([^\"]*+)\"]", 
     138        "//ldml/localeDisplayNames/types/type[@key=\"([^\"]*+)\"][@type=\"([^\"]*+)\"]", 
     139        "//ldml/localeDisplayNames/types/type[@key=\"([^\"]*+)\"][@type=\"([^\"]*+)\"][@alt=\"([^\"]*+)\"]", 
     140 
     141        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/eras/eraNames/era[@type=\"([^\"]*+)\"]", 
     142        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/eras/eraAbbr/era[@type=\"([^\"]*+)\"]", 
     143        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/eras/eraNarrow/era[@type=\"([^\"]*+)\"]", 
     144 
     145        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateTimeFormats/appendItems/appendItem[@request=\"([^\"]*+)\"]", 
     146        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateTimeFormats/intervalFormats/intervalFormatFallback", 
     147        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\"([^\"]*+)\"]/greatestDifference[@id=\"([^\"]*+)\"]", 
     148        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/eras/eraNames/era[@type=\"([^\"]*+)\"][@alt=\"([^\"]*+)\"]", 
     149        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/eras/eraAbbr/era[@type=\"([^\"]*+)\"][@alt=\"([^\"]*+)\"]", 
     150        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/eras/eraNarrow/era[@type=\"([^\"]*+)\"][@alt=\"([^\"]*+)\"]", 
     151        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/months/monthContext[@type=\"([^\"]*+)\"]/monthWidth[@type=\"([^\"]*+)\"]/month[@type=\"([^\"]*+)\"][@yeartype=\"([^\"]*+)\"]", 
     152        "//ldml/dates/timeZoneNames/gmtZeroFormat", 
     153 
     154        "//ldml/numbers/minimumGroupingDigits", 
     155        "//ldml/numbers/symbols/timeSeparator", 
     156        "//ldml/numbers/symbols[@numberSystem=\"([^\"]*+)\"]/timeSeparator", 
     157 
     158        "//ldml/units/unitLength[@type=\"([^\"]*+)\"]/unit[@type=\"([^\"]*+)\"]/displayName", 
     159        "//ldml/units/unitLength[@type=\"([^\"]*+)\"]/unit[@type=\"([^\"]*+)\"]/perUnitPattern", 
     160        "//ldml/units/unitLength[@type=\"([^\"]*+)\"]/coordinateUnit/coordinateUnitPattern[@type=\"([^\"]*+)\"]", 
     161 
     162        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/long/standard" // Error: (TestExampleGenerator.java:245) No background:   <Coordinated Universal Time>    〖Coordinated Universal Time〗     
     163 
     164        // WARNING - do not disable the test by putting in too broad a match. Make sure the paths are reasonably granular. 
     165 
     166        ); 
     167 
     168    static final Set<String> DELIBERATE_OK_TO_MISS_BACKGROUND = ImmutableSet.of( 
     169        "//ldml/numbers/defaultNumberingSystem", 
     170        "//ldml/numbers/otherNumberingSystems/native", 
     171        // TODO fix formatting 
     172        "//ldml/characters/exemplarCharacters", 
     173        "//ldml/characters/exemplarCharacters[@type=\"([^\"]*+)\"]", 
     174        // TODO Add background 
     175        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateFormats/dateFormatLength[@type=\"([^\"]*+)\"]/dateFormat[@type=\"([^\"]*+)\"]/pattern[@type=\"([^\"]*+)\"]", 
     176        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/timeFormats/timeFormatLength[@type=\"([^\"]*+)\"]/timeFormat[@type=\"([^\"]*+)\"]/pattern[@type=\"([^\"]*+)\"]", 
     177        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateTimeFormats/availableFormats/dateFormatItem[@id=\"([^\"]*+)\"]", 
     178        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/exemplarCity", 
     179        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/long/daylight", 
     180        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/short/generic", 
     181        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/short/standard", 
     182        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/short/daylight", 
     183        "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/long/generic", 
     184        "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/long/standard", 
     185        "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/long/daylight", 
     186        "//ldml/units/durationUnit[@type=\"([^\"]*+)\"]/durationUnitPattern" 
     187        ); 
     188    static final Set<String> TEMPORARY_OK_TO_MISS_BACKGROUND = ImmutableSet.of( 
     189        "//ldml/numbers/defaultNumberingSystem", 
     190        "//ldml/dates/calendars/calendar[@type=\"([^\"]*+)\"]/dateTimeFormats/availableFormats/dateFormatItem[@id=\"([^\"]*+)\"][@count=\"([^\"]*+)\"]", 
     191        "//ldml/dates/timeZoneNames/zone[@type=\"([^\"]*+)\"]/long/standard", 
     192        "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/short/generic", 
     193        "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/short/standard", 
     194        "//ldml/dates/timeZoneNames/metazone[@type=\"([^\"]*+)\"]/short/daylight" 
     195        ); 
    127196 
    128197    public void TestAllPaths() { 
    129         if (logKnownIssue( 
    130             "Cldrbug:6342", 
    131             "In our tests, make sure that either we have an example for every path, or that the path is on an exception list.")) { 
    132             return; 
    133         } 
    134198        ExampleGenerator exampleGenerator = getExampleGenerator("en"); 
    135199        PathStarrer ps = new PathStarrer(); 
     
    142206            if (value == null || path.endsWith("/alias") 
    143207                || path.startsWith("//ldml/identity") 
    144                 || OK_TO_MISS_EXAMPLES.contains(plainStarred)) { 
     208                || DELIBERATE_EXCLUDED_EXAMPLES.contains(plainStarred)) { 
     209                continue; 
     210            } 
     211            if (TEMPORARY_EXCLUDED_EXAMPLES.contains(plainStarred)) { 
     212                if (logKnownIssue( 
     213                    "Cldrbug:6342", 
     214                    "In our tests, make sure that either we have an example for every path that is used in context.")) { 
     215                    continue; 
     216                } 
    145217                continue; 
    146218            } 
     
    175247                    } 
    176248                } else if (!simplified.contains("❬") 
    177                     && !OK_TO_MISS_BACKGROUND.contains(plainStarred)) { 
     249                    && !DELIBERATE_OK_TO_MISS_BACKGROUND.contains(plainStarred) 
     250                    && !TEMPORARY_OK_TO_MISS_BACKGROUND.contains(plainStarred)) { 
    178251                    if (!seen.contains(javaEscapedStarred)) { 
    179252                        errln("No background:\t<" + value + ">\t" + simplified 
     
    192265        checkValue( 
    193266            "Length m", 
    194             "〖❬1❭ meter〗", 
     267            "〖❬1.00❭ meter〗", 
    195268            exampleGenerator, 
    196269            "//ldml/units/unitLength[@type=\"long\"]/unit[@type=\"length-meter\"]/unitPattern[@count=\"one\"]"); 
    197270        checkValue( 
    198271            "Length m", 
    199             "〖❬1.5❭ meters〗", 
     272            "〖❬1.50❭ meters〗", 
    200273            exampleGenerator, 
    201274            "//ldml/units/unitLength[@type=\"long\"]/unit[@type=\"length-meter\"]/unitPattern[@count=\"other\"]"); 
    202275        checkValue( 
    203276            "Length m", 
    204             "〖❬1.5❭ m〗", 
     277            "〖❬1.50❭ m〗", 
    205278            exampleGenerator, 
    206279            "//ldml/units/unitLength[@type=\"short\"]/unit[@type=\"length-meter\"]/unitPattern[@count=\"other\"]"); 
    207280        checkValue( 
    208281            "Length m", 
    209             "〖❬1.5❭m〗", 
     282            "〖❬1.50❭m〗", 
    210283            exampleGenerator, 
    211284            "//ldml/units/unitLength[@type=\"narrow\"]/unit[@type=\"length-meter\"]/unitPattern[@count=\"other\"]"); 
     
    221294 
    222295    public void TestCompoundUnit() { 
    223         String[][] tests = { { "LONG", "one", "〖❬1 meter❭ per ❬second❭〗" }, 
    224             { "SHORT", "one", "〖❬1 m❭/❬sec❭〗" }, 
    225             { "NARROW", "one", "〖❬1m❭/❬s❭〗" }, 
    226             { "LONG", "other", "〖❬1.5 meters❭ per ❬second❭〗" }, 
    227             { "SHORT", "other", "〖❬1.5 m❭/❬sec❭〗" }, 
    228             { "NARROW", "other", "〖❬1.5m❭/❬s❭〗" }, }; 
     296        String[][] tests = { { "LONG", "one", "〖❬1.00 meter❭ per ❬second❭〗" }, 
     297            { "SHORT", "one", "〖❬1.00 m❭/❬sec❭〗" }, 
     298            { "NARROW", "one", "〖❬1.00m❭/❬s❭〗" }, 
     299            { "LONG", "other", "〖❬1.50 meters❭ per ❬second❭〗" }, 
     300            { "SHORT", "other", "〖❬1.50 m❭/❬sec❭〗" }, 
     301            { "NARROW", "other", "〖❬1.50m❭/❬s❭〗" }, }; 
    229302        checkCompoundUnits("en", tests); 
    230303        // reenable these after Arabic has meter translated 
     
    331404                + "<div class='cldr_example'><span class='cldr_substituted'>usbeco</span> [<span class='cldr_substituted'>arabo, Afghanistan</span>]</div>" 
    332405                + "<div class='cldr_example'><span class='cldr_substituted'>usbeco</span> [<span class='cldr_substituted'>arabo, Afghanistan, Cifre indo-arabe, Fuso orario: africa/addis_ababa</span>]</div>", 
    333             actual); 
     406                actual); 
    334407        actual = exampleGenerator 
    335408            .getExampleHtml( 
     
    340413            "<div class='cldr_example'><span class='cldr_substituted'>usbeco (arabo</span>. <span class='cldr_substituted'>Afghanistan)</span></div>" 
    341414                + "<div class='cldr_example'><span class='cldr_substituted'>usbeco (arabo</span>. <span class='cldr_substituted'>Afghanistan</span>. <span class='cldr_substituted'>Cifre indo-arabe</span>. <span class='cldr_substituted'>Fuso orario: africa/addis_ababa)</span></div>", 
    342             actual); 
     415                actual); 
    343416    } 
    344417 
     
    404477            { 
    405478                "//ldml/numbers/currencies/currency[@type=\"BMD\"]/displayName[@count=\"other\"]", 
    406                 "〖❬1,23 ❭dollari delle Bermuda〗〖❬0,00 ❭dollari delle Bermuda〗" }, 
     479            "〖❬1,23 ❭dollari delle Bermuda〗〖❬0,00 ❭dollari delle Bermuda〗" }, 
    407480            { 
    408481                "//ldml/numbers/currencyFormats[@numberSystem=\"latn\"]/unitPattern[@count=\"other\"]", 
    409                 "〖❬1,23❭ ❬dollari statunitensi❭〗〖❬1,23❭ ❬euro❭〗〖❬0,00❭ ❬dollari statunitensi❭〗〖❬0,00❭ ❬euro❭〗" }, 
     482            "〖❬1,23❭ ❬dollari statunitensi❭〗〖❬1,23❭ ❬euro❭〗〖❬0,00❭ ❬dollari statunitensi❭〗〖❬0,00❭ ❬euro❭〗" }, 
    410483            { "//ldml/numbers/currencies/currency[@type=\"BMD\"]/symbol", 
    411                 "〖❬123.456,79 ❭BMD〗" }, }; 
     484            "〖❬123.456,79 ❭BMD〗" }, }; 
    412485 
    413486        ExampleGenerator exampleGenerator = getExampleGenerator("it"); 
     
    426499            { 
    427500                "//ldml/numbers/decimalFormats[@numberSystem=\"latn\"]/decimalFormatLength[@type=\"long\"]/decimalFormat[@type=\"standard\"]/pattern[@type=\"1000\"][@count=\"one\"]", 
    428                 "<div class='cldr_example'><span class='cldr_substituted'>1</span> thousand</div>" }, 
     501            "<div class='cldr_example'><span class='cldr_substituted'>1</span> thousand</div>" }, 
    429502            { 
    430503                "//ldml/numbers/percentFormats[@numberSystem=\"latn\"]/percentFormatLength/percentFormat[@type=\"standard\"]/pattern[@type=\"standard\"]", 
     
    455528 
    456529        for (String xpath : cldrFile.fullIterable()) { 
     530            if (xpath.endsWith("/alias")) { 
     531                continue; 
     532            } 
    457533            String value = cldrFile.getStringValue(xpath); 
    458534            checkPathValue(exampleGenerator, xpath, value, null); 
  • trunk/tools/java/org/unicode/cldr/test/ExampleGenerator.java

    r13066 r13470  
    260260     */ 
    261261    public String getExampleHtml(String xpath, String value, ExampleContext context, ExampleType type) { 
     262        if (value == null) { 
     263            return null; 
     264        } 
    262265        String cacheKey; 
    263266        String result = null; 
     
    314317                result = formatCountValue(xpath, parts, value, context, type); 
    315318            } else if (parts.getElement(-2).equals("compoundUnit")) { 
    316                 result = handleCompoundUnit(getUnitLength(), 
    317                     Count.valueOf(parts.getAttributeValue(-1, "count")), 
    318                     value); 
     319                String count = CldrUtility.ifNull(parts.getAttributeValue(-1, "count"), "other"); 
     320                result = handleCompoundUnit(getUnitLength(), Count.valueOf(count), value); 
    319321            } else if (parts.getElement(-1).equals("unitPattern")) { 
    320                 result = handleFormatUnit(getUnitLength(), Count.valueOf(parts.getAttributeValue(-1, "count")), value); 
     322                String count = parts.getAttributeValue(-1, "count"); 
     323                result = handleFormatUnit(getUnitLength(), Count.valueOf(count), value); 
    321324            } else if (parts.getElement(-1).equals("durationUnitPattern")) { 
    322325                result = handleDurationUnit(value); 
     
    534537        // listPatternType is either "duration" or null 
    535538        String listPatternType = parts.getAttributeValue(-2, "type"); 
    536         if (listPatternType == null) { 
     539        if (listPatternType == null || !listPatternType.contains("unit")) { 
    537540            return handleRegularListPatterns(parts, value); 
    538         } 
    539         else { 
     541        } else { 
    540542            return handleDurationListPatterns(parts, value, UnitLength.from(listPatternType)); 
    541543        } 
     
    963965                : "//ldml/units/unit[@type=\"" + unitType + "\"]/unitPattern", 
    964966                count, true); 
    965         return cldrFile.getWinningValue(unitNamePath); 
     967        return unitNamePath == null ? unitType : cldrFile.getWinningValue(unitNamePath); 
    966968    } 
    967969 
     
    14361438                    if (languageName == null) { 
    14371439                        languageName = cldrFile.getStringValueWithBailey(CLDRFile.getKey(CLDRFile.LANGUAGE_NAME, ltp.getLanguage())); 
     1440                        if (languageName == null) { 
     1441                            languageName = cldrFile.getStringValueWithBailey(CLDRFile.getKey(CLDRFile.LANGUAGE_NAME, "en")); 
     1442                        } 
     1443                        if (languageName == null) { 
     1444                            languageName = ltp.getLanguage(); 
     1445                        } 
    14381446                    } 
    14391447                    if (scriptName == null) { 
    14401448                        scriptName = cldrFile.getStringValueWithBailey(CLDRFile.getKey(CLDRFile.SCRIPT_NAME, ltp.getScript())); 
     1449                        if (scriptName == null) { 
     1450                            scriptName = cldrFile.getStringValueWithBailey(CLDRFile.getKey(CLDRFile.SCRIPT_NAME, "Latn")); 
     1451                        } 
     1452                        if (scriptName == null) { 
     1453                            scriptName = ltp.getScript(); 
     1454                        } 
    14411455                    } 
    14421456                    if (territoryName == null) { 
    14431457                        territoryName = cldrFile.getStringValueWithBailey(CLDRFile.getKey(CLDRFile.TERRITORY_NAME, ltp.getRegion())); 
     1458                        if (territoryName == null) { 
     1459                            territoryName = cldrFile.getStringValueWithBailey(CLDRFile.getKey(CLDRFile.TERRITORY_NAME, "US")); 
     1460                        } 
     1461                        if (territoryName == null) { 
     1462                            territoryName = ltp.getRegion(); 
     1463                        } 
    14441464                    } 
    14451465                    languageName = languageName.replace('(', '[').replace(')', ']').replace('(', '[').replace(')', ']'); 
     
    15081528        Matcher m = PARAMETER.matcher(inputPattern); 
    15091529        return backgroundStartSymbol + m.replaceAll(backgroundEndSymbol + "$1" + backgroundStartSymbol) 
    1510             + backgroundEndSymbol; 
     1530        + backgroundEndSymbol; 
    15111531    } 
    15121532 
     
    15231543        Matcher m = patternToEmbed.matcher(input); 
    15241544        return backgroundStartSymbol + m.replaceAll(backgroundEndSymbol + "$1" + backgroundStartSymbol) 
    1525             + backgroundEndSymbol; 
     1545        + backgroundEndSymbol; 
    15261546    } 
    15271547 
     
    17471767            : internal ? "〖" + exampleHtml 
    17481768                .replace("", "❬") 
    1749                 .replace("", "❭") + "〗" 
    1750                 : exampleHtml 
    1751                 .replace("<div class='cldr_example'>", "〖") 
    1752                 .replace("</div>", "〗") 
    1753                 .replace("<span class='cldr_substituted'>", "❬") 
    1754                 .replace("</span>", "❭"); 
     1769            .replace("", "❭") + "〗" 
     1770            : exampleHtml 
     1771            .replace("<div class='cldr_example'>", "〖") 
     1772            .replace("</div>", "〗") 
     1773            .replace("<span class='cldr_substituted'>", "❬") 
     1774            .replace("</span>", "❭"); 
    17551775    } 
    17561776 
Note: See TracChangeset for help on using the changeset viewer.