Fix copyWith's return type. (#458)
Fix copyWith's return type.
diff --git a/protoc_plugin/test/validate_fail_test.dart b/protoc_plugin/test/validate_fail_test.dart
index a901d79..82adbeb 100755
--- a/protoc_plugin/test/validate_fail_test.dart
+++ b/protoc_plugin/test/validate_fail_test.dart
@@ -5,19 +5,22 @@
library validate_fail_test;
+import 'package:fixnum/fixnum.dart';
import 'package:test/test.dart';
import '../out/protos/google/protobuf/unittest.pb.dart';
// [ArgumentError] in production mode, [TypeError] in checked.
final invalidArgumentException =
- predicate((e) => e is ArgumentError || e is TypeError);
+// ignore: deprecated_member_use
+ predicate((e) => e is ArgumentError || e is TypeError || e is CastError);
final badArgument = throwsA(invalidArgumentException);
// Suppress an analyzer warning for a deliberate type mismatch.
dynamic cast(x) => x;
void main() {
+ // TODO(sigurdm): in a Dart 2 world most of these tests don't really make sense.
test('testValidationFailureMessages', () {
var builder = TestAllTypes();
@@ -26,7 +29,7 @@
}, throwsArgumentError);
expect(() {
- builder.optionalInt32 = cast('101');
+ builder.optionalInt32 = cast('101') as int;
}, badArgument);
expect(() {
builder.optionalInt32 = -2147483649;
@@ -36,17 +39,17 @@
}, throwsArgumentError);
expect(() {
- builder.optionalInt64 = cast('102');
+ builder.optionalInt64 = cast('102') as Int64;
}, badArgument);
expect(() {
- builder.optionalInt64 = cast(-9223372036854775808);
+ builder.optionalInt64 = cast(-9223372036854775808) as Int64;
}, badArgument);
expect(() {
- builder.optionalInt64 = cast(9223372036854775807);
+ builder.optionalInt64 = cast(9223372036854775807) as Int64;
}, badArgument);
expect(() {
- builder.optionalUint32 = cast('103');
+ builder.optionalUint32 = cast('103') as int;
}, badArgument);
expect(() {
builder.optionalUint32 = -1;
@@ -56,17 +59,17 @@
}, throwsArgumentError);
expect(() {
- builder.optionalUint64 = cast('104');
+ builder.optionalUint64 = cast('104') as Int64;
}, badArgument);
expect(() {
- builder.optionalUint64 = cast(-1);
+ builder.optionalUint64 = cast(-1) as Int64;
}, badArgument);
expect(() {
- builder.optionalUint64 = cast(8446744073709551616);
+ builder.optionalUint64 = cast(8446744073709551616) as Int64;
}, badArgument);
expect(() {
- builder.optionalSint32 = cast('105');
+ builder.optionalSint32 = cast('105') as int;
}, badArgument);
expect(() {
builder.optionalSint32 = -2147483649;
@@ -76,17 +79,17 @@
}, throwsArgumentError);
expect(() {
- builder.optionalSint64 = cast('106');
+ builder.optionalSint64 = cast('106') as Int64;
}, badArgument);
expect(() {
- builder.optionalSint64 = cast(-9223372036854775808);
+ builder.optionalSint64 = cast(-9223372036854775808) as Int64;
}, badArgument);
expect(() {
- builder.optionalSint64 = cast(9223372036854775807);
+ builder.optionalSint64 = cast(9223372036854775807) as Int64;
}, badArgument);
expect(() {
- builder.optionalFixed32 = cast('107');
+ builder.optionalFixed32 = cast('107') as int;
}, badArgument);
expect(() {
builder.optionalFixed32 = -1;
@@ -96,17 +99,17 @@
}, throwsArgumentError);
expect(() {
- builder.optionalFixed64 = cast('108');
+ builder.optionalFixed64 = cast('108') as Int64;
}, badArgument);
expect(() {
- builder.optionalFixed64 = cast(-1);
+ builder.optionalFixed64 = cast(-1) as Int64;
}, badArgument);
expect(() {
- builder.optionalFixed64 = cast(8446744073709551616);
+ builder.optionalFixed64 = cast(8446744073709551616) as Int64;
}, badArgument);
expect(() {
- builder.optionalSfixed32 = cast('109');
+ builder.optionalSfixed32 = cast('109') as int;
}, badArgument);
expect(() {
builder.optionalSfixed32 = -2147483649;
@@ -116,17 +119,17 @@
}, throwsArgumentError);
expect(() {
- builder.optionalSfixed64 = cast('110');
+ builder.optionalSfixed64 = cast('110') as Int64;
}, badArgument);
expect(() {
- builder.optionalSfixed64 = cast(-9223372036854775808);
+ builder.optionalSfixed64 = cast(-9223372036854775808) as Int64;
}, badArgument);
expect(() {
- builder.optionalSfixed64 = cast(9223372036854775807);
+ builder.optionalSfixed64 = cast(9223372036854775807) as Int64;
}, badArgument);
expect(() {
- builder.optionalFloat = cast('111');
+ builder.optionalFloat = cast('111') as double;
}, badArgument);
expect(() {
builder.optionalFloat = -3.4028234663852886E39;
@@ -136,15 +139,15 @@
}, throwsArgumentError);
expect(() {
- builder.optionalDouble = cast('112');
+ builder.optionalDouble = cast('112') as double;
}, badArgument);
expect(() {
- builder.optionalBool = cast('113');
+ builder.optionalBool = cast('113') as bool;
}, badArgument);
expect(() {
- builder.optionalString = cast(false);
+ builder.optionalString = cast(false) as String;
}, badArgument);
// Can't test this easily in strong mode.
@@ -153,11 +156,11 @@
// }, badArgument);
expect(() {
- builder.optionalNestedMessage = cast('118');
+ builder.optionalNestedMessage = cast('118') as TestAllTypes_NestedMessage;
}, badArgument);
expect(() {
- builder.optionalNestedEnum = cast('121');
+ builder.optionalNestedEnum = cast('121') as TestAllTypes_NestedEnum;
}, badArgument);
// Set repeating value (no setter should exist).