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
76 changes: 38 additions & 38 deletions pkgs/characters/test/characters_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ void main([List<String>? args]) {
test('operations', () {
var flag = '\u{1F1E9}\u{1F1F0}'; // Regional Indicators "DK".
var string = 'Hi $flag!';
expect(string.length, 8);
expect(string, hasLength(8));
var cs = gc(string);
expect(cs.length, 5);
expect(cs, hasLength(5));
expect(cs.toList(), ['H', 'i', ' ', flag, '!']);
expect(cs.skip(2).toString(), ' $flag!');
expect(cs.skipLast(2).toString(), 'Hi ');
Expand All @@ -41,9 +41,9 @@ void main([List<String>? args]) {
expect(cs.characterAt(1).toString(), 'i');
expect(cs.characterAt(3).toString(), flag);

expect(cs.contains('\u{1F1E9}'), false);
expect(cs.contains(flag), true);
expect(cs.contains('$flag!'), false);
expect(cs, isNot(contains('\u{1F1E9}')));
expect(cs, contains(flag));
expect(cs, isNot(contains('$flag!')));
expect(cs.containsAll(gc('$flag!')), true);

expect(cs.takeWhile((x) => x != ' ').toString(), 'Hi');
Expand Down Expand Up @@ -82,24 +82,24 @@ void main([List<String>? args]) {
group('CharacterRange', () {
test('new', () {
var range = CharacterRange('abc');
expect(range.isEmpty, true);
expect(range, isEmpty);
expect(range.moveNext(), true);
expect(range.current, 'a');
});
group('new.at', () {
test('simple', () {
var range = CharacterRange.at('abc', 0);
expect(range.isEmpty, true);
expect(range, isEmpty);
expect(range.moveNext(), true);
expect(range.current, 'a');

range = CharacterRange.at('abc', 1);
expect(range.isEmpty, true);
expect(range, isEmpty);
expect(range.moveNext(), true);
expect(range.current, 'b');

range = CharacterRange.at('abc', 1, 2);
expect(range.isEmpty, false);
expect(range, isNotEmpty);
expect(range.current, 'b');
expect(range.moveNext(), true);

Expand All @@ -118,30 +118,30 @@ void main([List<String>? args]) {
var rainbowFlag = '$flag$white$zwj$rainbow';
var string = '-$rainbowFlag-';
var range = CharacterRange.at(string, 1);
expect(range.isEmpty, true);
expect(range, isEmpty);
expect(range.moveNext(), true);
expect(range.current, rainbowFlag);

range = range = CharacterRange.at(string, 2);
expect(range.isEmpty, false);
expect(range, isNotEmpty);
expect(range.current, rainbowFlag);

range = range = CharacterRange.at(string, 0, 2);
expect(range.isEmpty, false);
expect(range, isNotEmpty);
expect(range.current, '-$rainbowFlag');

range = range = CharacterRange.at(string, 0, 2);
expect(range.isEmpty, false);
expect(range, isNotEmpty);
expect(range.current, '-$rainbowFlag');

range =
range = CharacterRange.at(string, 2, '-$rainbowFlag'.length - 1);
expect(range.isEmpty, false);
expect(range, isNotEmpty);
expect(range.current, rainbowFlag);
expect(range.stringBeforeLength, 1);

range = range = CharacterRange.at(string, 0, string.length);
expect(range.isEmpty, false);
expect(range, isNotEmpty);
expect(range.current, string);
});
});
Expand Down Expand Up @@ -244,7 +244,7 @@ void expectGC(Characters actual, List<String> expected) {
expect(actual.string, text);
expect(actual.toString(), text);
expect(actual.toList(), expected);
expect(actual.length, expected.length);
expect(actual, hasLength(expected.length));
if (expected.isNotEmpty) {
expect(actual.first, expected.first);
expect(actual.last, expected.last);
Expand All @@ -261,10 +261,10 @@ void expectGC(Characters actual, List<String> expected) {
expect(actual.isNotEmpty, expected.isNotEmpty);
expect(actual.contains(''), false);
for (var char in expected) {
expect(actual.contains(char), true);
expect(actual, contains(char));
}
for (var i = 1; i < expected.length; i++) {
expect(actual.contains(expected[i - 1] + expected[i]), false);
expect(actual, isNot(contains(expected[i - 1] + expected[i])));
}
expect(actual.skip(1).toList(), expected.skip(1).toList());
expect(actual.take(1).toList(), expected.take(1).toList());
Expand Down Expand Up @@ -324,7 +324,7 @@ void expectGC(Characters actual, List<String> expected) {

// Iteration.
var it = actual.iterator;
expect(it.isEmpty, true);
expect(it, isEmpty);
for (var i = 0; i < expected.length; i++) {
expect(it.moveNext(), true);
expect(it.current, expected[i]);
Expand All @@ -340,7 +340,7 @@ void expectGC(Characters actual, List<String> expected) {
expect(it.current, expected[i]);
}
expect(it.moveBack(), false);
expect(it.isEmpty, true);
expect(it, isEmpty);

// GraphemeClusters operations.
expect(actual.toUpperCase().string, text.toUpperCase());
Expand Down Expand Up @@ -379,10 +379,10 @@ void expectGC(Characters actual, List<String> expected) {
var back = false;
if (pos < 0) {
expect(lastMove, false);
expect(it.isEmpty, true);
expect(it, isEmpty);
} else if (pos >= expected.length) {
expect(lastMove, false);
expect(it.isEmpty, true);
expect(it, isEmpty);
back = true;
} else {
expect(lastMove, true);
Expand Down Expand Up @@ -413,48 +413,48 @@ void testParts(
var cs = gc('$a$b$c$d$e');
test('$cs', () {
var it = cs.iterator;
expect(it.isEmpty, true);
expect(it.isNotEmpty, false);
expect(it, isEmpty);
expect(it, isEmpty);
expect(it.current, '');

// moveNext().
expect(it.moveNext(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$a');
expect(it.moveNext(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$b');
expect(it.moveNext(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$c');
expect(it.moveNext(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$d');
expect(it.moveNext(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$e');
expect(it.moveNext(), false);
expect(it.isEmpty, true);
expect(it, isEmpty);
expect(it.current, '');

// moveBack().
expect(it.moveBack(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$e');
expect(it.moveBack(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$d');
expect(it.moveBack(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$c');
expect(it.moveBack(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$b');
expect(it.moveBack(), true);
expect(it.isEmpty, false);
expect(it, isNotEmpty);
expect(it.current, '$a');
expect(it.moveBack(), false);
expect(it.isEmpty, true);
expect(it, isEmpty);
expect(it.current, '');

// moveNext(int).
Expand Down Expand Up @@ -723,10 +723,10 @@ void testParts(
ci.dropFirst();
ci.dropLast();
expect(ci.currentCharacters, cr + pattern + lf + pic + pattern + zwj + pic);
expect(ci.currentCharacters.length, 7);
expect(ci.currentCharacters, hasLength(7));
ri = ci.replaceAll(pattern, non)!;
expect(ri.currentCharacters, cr + lf + pic + zwj + pic);
expect(ri.currentCharacters.length, 2);
expect(ri.currentCharacters, hasLength(2));
ci.dropFirst();
ci.dropLast(5);
expect(ci.currentCharacters, pattern);
Expand Down
2 changes: 1 addition & 1 deletion pkgs/collection/test/boollist_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void main() {

test('expand from = 0', () {
var b = BoolList(0, growable: true);
expect(b.length, 0);
expect(b, hasLength(0));

b.length = 256;
expect(b, List.filled(256, false));
Expand Down
40 changes: 20 additions & 20 deletions pkgs/collection/test/canonicalized_map_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ void main() {
test('set affects nothing for uncanonicalizable key', () {
map['foo'] = 'value';
expect(map['foo'], isNull);
expect(map.containsKey('foo'), isFalse);
expect(map.length, equals(0));
expect(map, isNot(contains('foo')));
expect(map, hasLength(0));
});

test('canonicalizes keys for addAll', () {
Expand All @@ -38,7 +38,7 @@ void main() {

test('uses the final value for addAll collisions', () {
map.addAll({'1': 'value 1', '01': 'value 2', '001': 'value 3'});
expect(map.length, equals(1));
expect(map, hasLength(1));
expect(map['0001'], equals('value 3'));
});

Expand All @@ -51,12 +51,12 @@ void main() {

test('canonicalizes keys for containsKey', () {
map['1'] = 'value';
expect(map.containsKey('01'), isTrue);
expect(map.containsKey('2'), isFalse);
expect(map, contains('01'));
expect(map, isNot(contains('2')));
});

test('containsKey returns false for uncanonicalizable key', () {
expect(map.containsKey('foo'), isFalse);
expect(map, isNot(contains('foo')));
});

test('canonicalizes keys for putIfAbsent', () {
Expand All @@ -81,34 +81,34 @@ void main() {

test('containsValue returns whether a value is in the map', () {
map['1'] = 'value';
expect(map.containsValue('value'), isTrue);
expect(map.containsValue('not value'), isFalse);
expect(map, containsValue('value'));
expect(map, isNot(containsValue('not value')));
});

test('isEmpty returns whether the map is empty', () {
expect(map.isEmpty, isTrue);
expect(map, isEmpty);
map['1'] = 'value';
expect(map.isEmpty, isFalse);
expect(map, isNotEmpty);
map.remove('01');
expect(map.isEmpty, isTrue);
expect(map, isEmpty);
});

test("isNotEmpty returns whether the map isn't empty", () {
expect(map.isNotEmpty, isFalse);
expect(map, isEmpty);
map['1'] = 'value';
expect(map.isNotEmpty, isTrue);
expect(map, isNotEmpty);
map.remove('01');
expect(map.isNotEmpty, isFalse);
expect(map, isEmpty);
});

test('length returns the number of pairs in the map', () {
expect(map.length, equals(0));
expect(map, hasLength(0));
map['1'] = 'value 1';
expect(map.length, equals(1));
expect(map, hasLength(1));
map['01'] = 'value 01';
expect(map.length, equals(1));
expect(map, hasLength(1));
map['02'] = 'value 02';
expect(map.length, equals(2));
expect(map, hasLength(2));
});

test('uses original keys for keys', () {
Expand Down Expand Up @@ -216,7 +216,7 @@ void main() {
'01': 'value 2',
'001': 'value 3',
}, int.parse);
expect(map.length, equals(1));
expect(map, hasLength(1));
expect(map['0001'], equals('value 3'));
});
});
Expand All @@ -237,7 +237,7 @@ void main() {
{'1': 'value 1', '01': 'value 2', '001': 'value 3'}.entries,
int.parse,
);
expect(map.length, equals(1));
expect(map, hasLength(1));
expect(map['0001'], equals('value 3'));
});
});
Expand Down
6 changes: 3 additions & 3 deletions pkgs/collection/test/combined_wrapper/map_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ void main() {
test('should function as an empty map when no maps are passed', () {
var empty = CombinedMapView([]);
expect(empty, isEmpty);
expect(empty.length, 0);
expect(empty, hasLength(0));
});

test('should function as an empty map when only empty maps are passed', () {
var empty = CombinedMapView([{}, {}, {}]);
expect(empty, isEmpty);
expect(empty.length, 0);
expect(empty, hasLength(0));
});

test('should reflect underlying changes back to the combined map', () {
Expand Down Expand Up @@ -74,7 +74,7 @@ void main() {

void _testReadMap(Map<int, int> original, Map<int, int> wrapped, String name) {
test('$name length', () {
expect(wrapped.length, equals(original.length));
expect(wrapped, hasLength(original.length));
});

test('$name isEmpty', () {
Expand Down
Loading
Loading