-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
package:intl4xtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
I am encountering inconsistent sorting results when using the intl4x
package for locale-sensitive string collation. Specifically, the sorting works correctly when running the application with dart run
but produces incorrect results when running tests with dart test
.
import 'package:intl4x/collation.dart';
import 'package:intl4x/intl4x.dart';
import 'package:test/test.dart';
void main() {
group('Locale-Aware Sorting Tests', () {
test('Sorts words correctly with locale-sensitive collation', () {
intl = Intl(locale: Locale(language: 'en'));
List<String> words = [
'#Bright_Future',
'5-Star Ratings',
'Águas Claras',
'Étoile du Nord',
'Fjord Explorers',
'Grüner Baum',
'Infinity & Beyond',
'Ljósið',
'Müller’s Bakery',
'Nørrebro Adventures',
'Öl & Smörgås',
'Sunrise 🌅',
'Ütopia Designs',
'α-Group',
'Ωmega Industries',
'ßharp Solutions',
];
final collation = intl.collation(
const CollationOptions(
sensitivity: Sensitivity.base,
numeric: true,
),
);
words.sort(collation.compare);
// Expected sorted output
final expectedWords = [
'#Bright_Future',
'5-Star Ratings',
'Águas Claras',
'Étoile du Nord',
'Fjord Explorers',
'Grüner Baum',
'Infinity & Beyond',
'Ljósið',
'Müller’s Bakery',
'Nørrebro Adventures',
'Öl & Smörgås',
'Sunrise 🌅',
'Ütopia Designs',
'α-Group',
'ßharp Solutions',
'Ωmega Industries',
];
expect(words, equals(expectedWords));
});
});
}
Output:
dart --enable-experiment=native-assets test
Building package executable... (1.2s)
Built test:test.
00:01 +0 -1: test/main_test.dart: Locale-Aware Sorting Tests Sorts words correctly with locale-sensitive collation [E]
Expected: [
'#Bright_Future',
'5-Star Ratings',
'Águas Claras',
'Étoile du Nord',
'Fjord Explorers',
'Grüner Baum',
'Infinity & Beyond',
'Ljósið',
'Müller’s Bakery',
'Nørrebro Adventures',
'Öl & Smörgås',
'Sunrise 🌅',
'Ütopia Designs',
'α-Group',
'ßharp Solutions',
'Ωmega Industries'
]
Actual: [
'#Bright_Future',
'5-Star Ratings',
'Fjord Explorers',
'Grüner Baum',
'Infinity & Beyond',
'Ljósið',
'Müller’s Bakery',
'Nørrebro Adventures',
'Sunrise 🌅',
'Águas Claras',
'Étoile du Nord',
'Öl & Smörgås',
'Ütopia Designs',
'ßharp Solutions',
'Ωmega Industries',
'α-Group'
]
Which: at location [2] is 'Fjord Explorers' instead of 'Águas Claras'
package:matcher expect
test/main_test.dart 66:7 main.<fn>.<fn>
I think the issue is most likely that the native assets are not localized when I run tests.
Metadata
Metadata
Assignees
Labels
package:intl4xtype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)