Skip to content

Commit

Permalink
Remove isDart2 utility (flutter#132)
Browse files Browse the repository at this point in the history
We no longer run tests on Dart 1 SDKs so we don't need to have
workarounds for behavior differences.
  • Loading branch information
natebosch authored Apr 2, 2020
1 parent d659d18 commit d5f8001
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 37 deletions.
32 changes: 8 additions & 24 deletions test/queue_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import 'package:collection/collection.dart';
import 'package:test/test.dart';

import 'utils.dart';

void main() {
group('QueueList()', () {
test('creates an empty QueueList', () {
Expand Down Expand Up @@ -257,37 +255,23 @@ void main() {
var patternQueue = QueueList<Pattern>()..addAll(['a', 'b']);
var stringQueue = patternQueue.cast<String>();
stringQueue.addAll(['c', 'd']);
expect(
stringQueue,
const TypeMatcher<QueueList<String>>(),
reason: 'Expected QueueList<String>, got ${stringQueue.runtimeType}',
skip: isDart2 ? false : 'Cast does nothing in Dart1',
);
expect(stringQueue, const TypeMatcher<QueueList<String>>(),
reason: 'Expected QueueList<String>, got ${stringQueue.runtimeType}');

expect(
stringQueue,
['a', 'b', 'c', 'd'],
skip: isDart2 ? false : 'Cast does nothing in Dart1',
);
expect(stringQueue, ['a', 'b', 'c', 'd']);

expect(patternQueue, stringQueue, reason: 'Should forward to original');
});

test('cast throws on mutation when the type is not valid', () {
QueueList<Object> stringQueue = QueueList<String>();
var numQueue = stringQueue.cast<num>();
expect(numQueue, const TypeMatcher<QueueList<num>>(),
reason: 'Expected QueueList<num>, got ${numQueue.runtimeType}');
expect(
numQueue,
const TypeMatcher<QueueList<num>>(),
reason: 'Expected QueueList<num>, got ${numQueue.runtimeType}',
skip: isDart2 ? false : 'Cast does nothing in Dart1',
);
expect(
() => numQueue.add(1),
// ignore: deprecated_member_use
throwsA(isA<CastError>()),
skip: isDart2 ? false : 'In Dart1 a TypeError is not thrown',
);
() => numQueue.add(1),
// ignore: deprecated_member_use
throwsA(isA<CastError>()));
});

test('cast returns a new QueueList', () {
Expand Down
13 changes: 0 additions & 13 deletions test/utils.dart

This file was deleted.

0 comments on commit d5f8001

Please sign in to comment.