Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Stop using deprecated throws matcher from pkg/test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo committed Jul 25, 2017
1 parent 99312c7 commit 4aae651
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions test/bazel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void main() {
expect(
() =>
config.outputPathFor(Uri.parse('a/b/c/quux.proto'), '.pb.dart'),
throws);
throwsArgumentError);
});
});

Expand Down Expand Up @@ -198,7 +198,9 @@ void main() {
test('should throw if target is in unknown package', () {
var target = Uri.parse('flob/flub/quux.proto');
var source = Uri.parse('foo/bar/baz.proto');
expect(() => config.resolveImport(target, source, '.pb.dart'), throws);
expect(
() => config.resolveImport(target, source, '.pb.dart'),
throwsA(startsWith('ERROR: cannot generate import for')));
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void main() {
expect(() {
message.addExtension(
Unittest.repeatedNestedMessageExtension, new TestAllTypes());
}, throws); // TypeError
}, throwsATypeError);
});

test('throws if an enum extension is set to a bad value', () {
Expand All @@ -139,7 +139,7 @@ void main() {
expect(() {
message.addExtension(
Unittest.repeatedForeignEnumExtension, TestAllTypes_NestedEnum.FOO);
}, throws); // TypeError
}, throwsATypeError);
});

test('can extend a message with a message field with a different type', () {
Expand Down
7 changes: 4 additions & 3 deletions test/repeated_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ library repeated_field_test;
import 'package:test/test.dart';

import '../out/protos/google/protobuf/unittest.pb.dart';
import 'test_util.dart';

// Suppress an analyzer warning for a deliberate type mismatch.
cast(x) => x;
Expand All @@ -20,7 +21,7 @@ void main() {

expect(() {
TestAllTypes.$checkItem(cast(new TestAllTypes_NestedMessage()));
}, throws);
}, throwsATypeError);
});

test("checkItems works for groups", () {
Expand All @@ -31,7 +32,7 @@ void main() {
expect(() {
TestAllTypes_RepeatedGroup
.$checkItem(cast(new TestAllTypes_OptionalGroup()));
}, throws);
}, throwsATypeError);
});

test("checkItems works for enums", () {
Expand All @@ -41,7 +42,7 @@ void main() {

expect(() {
TestAllTypes_NestedEnum.$checkItem(cast(ForeignEnum.FOREIGN_FOO));
}, throws);
}, throwsATypeError);
});

test("check properties are initialized for repeated fields", () {
Expand Down
2 changes: 2 additions & 0 deletions test/test_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import 'package:test/test.dart';
import '../out/protos/google/protobuf/unittest_import.pb.dart';
import '../out/protos/google/protobuf/unittest.pb.dart';

final Matcher throwsATypeError = throwsA(new isInstanceOf<TypeError>());

Int64 make64(lo, [hi = null]) {
if (hi == null) hi = lo < 0 ? -1 : 0;
return new Int64.fromInts(hi, lo);
Expand Down

0 comments on commit 4aae651

Please sign in to comment.