mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 18:31:32 +00:00
Adjust tests where a TypeError may occur to also expect ArgumentError
This change is required because said tests may throw an ArgumentError until we have soundness. Change-Id: I09f569bf4ade6936e672490ab6b539f1d15b7708 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140289 Commit-Queue: Aske Simon Christensen <askesc@google.com> Auto-Submit: Erik Ernst <eernst@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
parent
0296286c03
commit
e9fa8fcd05
|
@ -397,19 +397,22 @@ void testConstructor() {
|
|||
Expect.equals(4.0, f.w);
|
||||
}
|
||||
|
||||
// TODO(eernst): Come pure null-safety, this can only be `TypeError`.
|
||||
bool isTypeError(e) => e is TypeError || e is ArgumentError;
|
||||
|
||||
void testBadArguments() {
|
||||
dynamic dynamicNull = null;
|
||||
Expect.throwsTypeError(() => new Float32x4(dynamicNull, 2.0, 3.0, 4.0));
|
||||
Expect.throwsTypeError(() => new Float32x4(1.0, dynamicNull, 3.0, 4.0));
|
||||
Expect.throwsTypeError(() => new Float32x4(1.0, 2.0, dynamicNull, 4.0));
|
||||
Expect.throwsTypeError(() => new Float32x4(1.0, 2.0, 3.0, dynamicNull));
|
||||
Expect.throws(() => new Float32x4(dynamicNull, 2.0, 3.0, 4.0), isTypeError);
|
||||
Expect.throws(() => new Float32x4(1.0, dynamicNull, 3.0, 4.0), isTypeError);
|
||||
Expect.throws(() => new Float32x4(1.0, 2.0, dynamicNull, 4.0), isTypeError);
|
||||
Expect.throws(() => new Float32x4(1.0, 2.0, 3.0, dynamicNull), isTypeError);
|
||||
|
||||
// Use local variable typed as "dynamic" to avoid static warnings.
|
||||
dynamic str = "foo";
|
||||
Expect.throwsTypeError(() => new Float32x4(str, 2.0, 3.0, 4.0));
|
||||
Expect.throwsTypeError(() => new Float32x4(1.0, str, 3.0, 4.0));
|
||||
Expect.throwsTypeError(() => new Float32x4(1.0, 2.0, str, 4.0));
|
||||
Expect.throwsTypeError(() => new Float32x4(1.0, 2.0, 3.0, str));
|
||||
Expect.throws(() => new Float32x4(str, 2.0, 3.0, 4.0), isTypeError);
|
||||
Expect.throws(() => new Float32x4(1.0, str, 3.0, 4.0), isTypeError);
|
||||
Expect.throws(() => new Float32x4(1.0, 2.0, str, 4.0), isTypeError);
|
||||
Expect.throws(() => new Float32x4(1.0, 2.0, 3.0, str), isTypeError);
|
||||
}
|
||||
|
||||
void testSpecialValues() {
|
||||
|
|
|
@ -11,6 +11,9 @@ library int32x4_test;
|
|||
import 'dart:typed_data';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
// TODO(eernst): Come pure null-safety, it can only be `TypeError`.
|
||||
bool isTypeError(e) => e is TypeError || e is ArgumentError;
|
||||
|
||||
void testBadArguments() {
|
||||
// Check that the actual argument type error is detected and a dynamic
|
||||
// error is raised. This is not trivially covered by similar dynamic type
|
||||
|
@ -18,12 +21,10 @@ void testBadArguments() {
|
|||
// is a built-in type.
|
||||
|
||||
dynamic dynamicNull = null;
|
||||
Expect.throwsTypeError(() => new Int32x4(dynamicNull, 2, 3, 4));
|
||||
Expect.throwsTypeError(() => new Int32x4(1, dynamicNull, 3, 4));
|
||||
Expect.throwsTypeError(() => new Int32x4(1, 2, dynamicNull, 4));
|
||||
Expect.throwsTypeError(() => new Int32x4(1, 2, 3, dynamicNull));
|
||||
|
||||
bool isTypeError(e) => e is TypeError;
|
||||
Expect.throws(() => new Int32x4(dynamicNull, 2, 3, 4), isTypeError);
|
||||
Expect.throws(() => new Int32x4(1, dynamicNull, 3, 4), isTypeError);
|
||||
Expect.throws(() => new Int32x4(1, 2, dynamicNull, 4), isTypeError);
|
||||
Expect.throws(() => new Int32x4(1, 2, 3, dynamicNull), isTypeError);
|
||||
|
||||
// Use a local variable typed as dynamic to avoid static warnings.
|
||||
dynamic str = "foo";
|
||||
|
|
|
@ -11,7 +11,8 @@ bool throwsTypeError(void Function() f) {
|
|||
try {
|
||||
f();
|
||||
} catch (e) {
|
||||
return e is TypeError;
|
||||
// TODO(eernst): Come pure null-safety, this can only be `TypeError`.
|
||||
return e is TypeError || e is ArgumentError;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue