@@ -2027,6 +2027,38 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
2027
2027
^''' ));
2028
2028
});
2029
2029
2030
+ testWithoutContext ('undefined plural cases throws syntax error' , () {
2031
+ const String pluralMessageWithUndefinedParts = '''
2032
+ {
2033
+ "count": "{count,plural, =0{None} =1{One} =2{Two} =3{Undefined Behavior!} other{Hmm...}}"
2034
+ }''' ;
2035
+ final Directory l10nDirectory = fs.currentDirectory.childDirectory ('lib' ).childDirectory ('l10n' )
2036
+ ..createSync (recursive: true );
2037
+ l10nDirectory.childFile (defaultTemplateArbFileName)
2038
+ .writeAsStringSync (pluralMessageWithUndefinedParts);
2039
+ try {
2040
+ LocalizationsGenerator (
2041
+ fileSystem: fs,
2042
+ inputPathString: defaultL10nPathString,
2043
+ outputPathString: defaultL10nPathString,
2044
+ templateArbFileName: defaultTemplateArbFileName,
2045
+ outputFileString: defaultOutputFileString,
2046
+ classNameString: defaultClassNameString,
2047
+ logger: logger,
2048
+ )
2049
+ ..loadResources ()
2050
+ ..writeOutputFiles ();
2051
+ } on L10nException catch (error) {
2052
+ expect (error.message, contains ('Found syntax errors.' ));
2053
+ expect (logger.hadErrorOutput, isTrue);
2054
+ expect (logger.errorText, contains ('''
2055
+ [app_en.arb:count] The plural cases must be one of "=0", "=1", "=2", "zero", "one", "two", "few", "many", or "other.
2056
+ 3 is not a valid plural case.
2057
+ {count,plural, =0{None} =1{One} =2{Two} =3{Undefined Behavior!} other{Hmm...}}
2058
+ ^''' ));
2059
+ }
2060
+ });
2061
+
2030
2062
testWithoutContext ('should automatically infer plural placeholders that are not explicitly defined' , () {
2031
2063
const String pluralMessageWithoutPlaceholdersAttribute = '''
2032
2064
{
0 commit comments