Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions executors/dart/bin/executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,36 @@ void main() {
} catch (e) {
throw 'ERRORSTART $line ERROREND';
}

final testType = TestTypes.values.firstWhereOrNull(
(type) => type.name == decoded['test_type'],
);
final outputLine = switch (testType) {
TestTypes.collation => testCollation(line),
TestTypes.decimal_fmt => testDecimalFormatWrapped(line),
TestTypes.number_fmt => testDecimalFormatWrapped(line),
TestTypes.datetime_fmt => testDateTimeFmt(line),
TestTypes.display_names => throw UnimplementedError(
'display_names is not supported yet',
),
TestTypes.lang_names => testLangNames(line),
// TestTypes.likely_subtags => testLikelySubtags(line),
TestTypes.likely_subtags => throw UnimplementedError(
'likely_subtags is not supported yet, as the Locale object is not yet migrated to ICU4X',
),
TestTypes.list_fmt => testListFmt(line),
TestTypes.plural_rules => testPluralRules(line),
null => throw ArgumentError.value(
decoded['test_type'],
'Unknown test type',
),
};

print(outputLine);
try {
final testType = TestTypes.values.firstWhereOrNull(
(type) => type.name == decoded['test_type'],
);
final outputLine = switch (testType) {
TestTypes.collation => testCollation(line),
TestTypes.decimal_fmt => testDecimalFormatWrapped(line),
TestTypes.number_fmt => testDecimalFormatWrapped(line),
TestTypes.datetime_fmt => testDateTimeFmt(line),
TestTypes.display_names => throw UnimplementedError(
'display_names is not supported yet',
),
TestTypes.lang_names => testLangNames(line),
// TestTypes.likely_subtags => testLikelySubtags(line),
TestTypes.likely_subtags => throw UnimplementedError(
'likely_subtags is not supported yet, as the Locale object is not yet migrated to ICU4X',
),
TestTypes.list_fmt => testListFmt(line),
TestTypes.plural_rules => testPluralRules(line),
null => throw ArgumentError.value(
decoded['test_type'],
'Unknown test type',
),
};
print(outputLine);
} catch (e, s) {
throw ArgumentError(
'Error while executing on $line. Error was:\n $e \n $s',
);
}
}
}
}
Expand Down
21 changes: 14 additions & 7 deletions executors/dart/lib/collator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import 'dart:convert';

import 'package:intl4x/collation.dart';
import 'package:intl4x/intl4x.dart';

String testCollation(String jsonEncoded) {
final json = jsonDecode(jsonEncoded) as Map<String, dynamic>;
Expand Down Expand Up @@ -52,16 +51,13 @@ String testCollation(String jsonEncoded) {
});
} else {
try {
final coll = Intl(locale: Locale.parse(localeString));

final collationOptions = CollationOptions(
final compared = Collation(
locale: Locale.parse(localeString),
ignorePunctuation: ignorePunctuation,
sensitivity: sensitivity,
numeric: numeric,
caseFirst: caseFirst,
);

final compared = coll.collation(collationOptions).compare(s1, s2);
).compare(s1, s2);

bool result;
if (compareType == '=') {
Expand Down Expand Up @@ -91,3 +87,14 @@ String testCollation(String jsonEncoded) {
}
return jsonEncode(outputLine);
}

// Copied from intl4x/lib/src/collation/collation_ecma.dart
extension on CaseFirst {
/// The JavaScript-compatible string representation of the case first option.
String get jsName => switch (this) {
// Map the custom name 'localeDependent' to 'false'.
CaseFirst.localeDependent => 'false',
// All other cases implicitly use the enum's name (e.g., 'upper', 'lower').
_ => name,
};
}
Loading
Loading