From 3a7eeb63157f51fd6f6f2a91f45e82792259a418 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Thu, 5 Nov 2020 14:26:53 +0000 Subject: [PATCH] Rename is{Strong,Weak}Mode to has{Sound,Unsound}NullSafety Change-Id: If3912d75c5f89a741299b2fae4299d01ac928eec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170424 Reviewed-by: Lasse R.H. Nielsen Reviewed-by: Michael Thomsen Reviewed-by: Mayank Patke Commit-Queue: Erik Ernst --- pkg/expect/lib/expect.dart | 16 +++++++-------- pkg/expect/test/nnbd_mode_test.dart | 4 ++-- .../error_messages_in_null_checks_test.dart | 2 +- ...l_checks_with_dwarf_stack_traces_test.dart | 6 ++++-- .../vm/dart/transferable_throws_test.dart | 2 +- tests/corelib/reg_exp_all_matches_test.dart | 2 +- .../rti/required_named_parameters_test.dart | 6 ++++-- tests/dart2js/internal/rti/subtype_test.dart | 4 ++-- .../rti/required_named_parameters_test.dart | 6 ++++-- .../function_subtype/bound_closure5_test.dart | 2 +- .../bound_closure5a_test.dart | 2 +- .../function_subtype/bound_closure6_test.dart | 2 +- .../language/function_subtype/cast2_test.dart | 2 +- .../function_subtype/checked0_test.dart | 2 +- .../function_subtype/inline0_test.dart | 4 ++-- .../function_subtype/inline2_test.dart | 2 +- .../function_subtype/local2_test.dart | 2 +- .../function_subtype/local5_test.dart | 2 +- .../language/function_subtype/not2_test.dart | 2 +- .../language/function_subtype/not3_test.dart | 2 +- .../function_subtype/top_level1_test.dart | 2 +- tests/language/generic/instanceof.dart | 20 +++++++++++-------- .../generic_class_tearoff_test.dart | 2 +- tests/language/is/is2_test.dart | 2 +- .../nnbd/constant_null_safety_mode_test.dart | 6 +++--- tests/language/null/null_test.dart | 8 ++++---- tests/language/regress/regress34147_test.dart | 2 +- tests/language/regress/regress41890_test.dart | 4 ++-- .../vm/bool_check_stack_traces_test.dart | 2 +- tests/lib/mirrors/null_test.dart | 6 +++--- 30 files changed, 68 insertions(+), 58 deletions(-) diff --git a/pkg/expect/lib/expect.dart b/pkg/expect/lib/expect.dart index 6e6b8e67d66..a030354668c 100644 --- a/pkg/expect/lib/expect.dart +++ b/pkg/expect/lib/expect.dart @@ -10,11 +10,11 @@ library expect; import 'package:meta/meta.dart'; -/// Whether the program is running with weak null safety checking. -bool get isWeakMode => const [] is List; +/// Whether the program is running without sound null safety. +bool get hasUnsoundNullSafety => const [] is List; -/// Whether the program is running with strong null safety checking. -bool get isStrongMode => !isWeakMode; +/// Whether the program is running with sound null safety. +bool get hasSoundNullSafety => !hasUnsoundNullSafety; /** * Expect is used for tests that do not want to make use of the @@ -620,11 +620,11 @@ class Expect { /// Checks that [f] throws an appropriate error on a null argument. /// - /// In strong mode, this is expected to be a [TypeError] when casting the - /// `null` to some non-nullable type. In weak mode, that cast is ignored and - /// some later explicit validation should handle it and [ArgumentError]. + /// With sound null safety, this is expected to be a [TypeError] when casting + /// the `null` to some non-nullable type. In weak mode, that cast is ignored + /// and some later explicit validation should handle it and [ArgumentError]. static void throwsNullCheckError(void f()) { - if (isStrongMode) { + if (hasSoundNullSafety) { throwsTypeError(f); } else { throwsArgumentError(f); diff --git a/pkg/expect/test/nnbd_mode_test.dart b/pkg/expect/test/nnbd_mode_test.dart index 47fb62497af..35dd3451719 100644 --- a/pkg/expect/test/nnbd_mode_test.dart +++ b/pkg/expect/test/nnbd_mode_test.dart @@ -14,6 +14,6 @@ final bool strong = () { }(); void main() { - Expect.equals(strong, isStrongMode); - Expect.equals(!strong, isWeakMode); + Expect.equals(strong, hasSoundNullSafety); + Expect.equals(!strong, hasUnsoundNullSafety); } diff --git a/runtime/tests/vm/dart/error_messages_in_null_checks_test.dart b/runtime/tests/vm/dart/error_messages_in_null_checks_test.dart index 2a64885b433..30e08eff0b4 100644 --- a/runtime/tests/vm/dart/error_messages_in_null_checks_test.dart +++ b/runtime/tests/vm/dart/error_messages_in_null_checks_test.dart @@ -89,7 +89,7 @@ main(List args) { Expect.throws( () => 9.81 - doubleNull, - (e) => isWeakMode + (e) => hasUnsoundNullSafety ? (e is NoSuchMethodError && // If '-' is specialized. (e.toString().startsWith( diff --git a/runtime/tests/vm/dart/null_checks_with_dwarf_stack_traces_test.dart b/runtime/tests/vm/dart/null_checks_with_dwarf_stack_traces_test.dart index b508ea8d572..7a87925d72d 100644 --- a/runtime/tests/vm/dart/null_checks_with_dwarf_stack_traces_test.dart +++ b/runtime/tests/vm/dart/null_checks_with_dwarf_stack_traces_test.dart @@ -52,8 +52,10 @@ main(List args) { Expect.throws(() => doubleNull + 2.17, (e) => e is NoSuchMethodError); - Expect.throws(() => 9.81 - doubleNull, - (e) => isWeakMode ? (e is NoSuchMethodError) : (e is TypeError)); + Expect.throws( + () => 9.81 - doubleNull, + (e) => + hasUnsoundNullSafety ? (e is NoSuchMethodError) : (e is TypeError)); Expect.throws(() => intNull * 7, (e) => e is NoSuchMethodError); } diff --git a/runtime/tests/vm/dart/transferable_throws_test.dart b/runtime/tests/vm/dart/transferable_throws_test.dart index c2a35d6abab..2ad36059fa3 100644 --- a/runtime/tests/vm/dart/transferable_throws_test.dart +++ b/runtime/tests/vm/dart/transferable_throws_test.dart @@ -107,7 +107,7 @@ main() async { throwsIfCummulativeListIsTooLargeOn32bitPlatform(); dynamic myNull; - if (isWeakMode) { + if (hasUnsoundNullSafety) { Expect.throwsArgumentError(() => TransferableTypedData.fromList(myNull)); Expect.throwsArgumentError(() => TransferableTypedData.fromList([myNull])); Expect.throwsArgumentError( diff --git a/tests/corelib/reg_exp_all_matches_test.dart b/tests/corelib/reg_exp_all_matches_test.dart index 54fbf104cc8..a2897230749 100644 --- a/tests/corelib/reg_exp_all_matches_test.dart +++ b/tests/corelib/reg_exp_all_matches_test.dart @@ -10,7 +10,7 @@ class RegExpAllMatchesTest { static testIterator() { var matches = new RegExp("foo").allMatches("foo foo"); Iterator it = matches.iterator; - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throws(() => it.current); } else { Expect.isNull(it.current); diff --git a/tests/dart2js/internal/rti/required_named_parameters_test.dart b/tests/dart2js/internal/rti/required_named_parameters_test.dart index c07f7a485d6..ccf3f7d29bb 100644 --- a/tests/dart2js/internal/rti/required_named_parameters_test.dart +++ b/tests/dart2js/internal/rti/required_named_parameters_test.dart @@ -51,11 +51,13 @@ main() { // Subtype may not redeclare optional parameters as required rti2 = rti.testingUniverseEval(universe, "@(A,{a!A,b!A,c!A})"); - Expect.equals(isWeakMode, rti.testingIsSubtype(universe, rti2, rti1)); + Expect.equals( + hasUnsoundNullSafety, rti.testingIsSubtype(universe, rti2, rti1)); // Subtype may not declare new required named parameters rti2 = rti.testingUniverseEval(universe, "@(A,{a!A,b:A,c!A,d!A})"); - Expect.equals(isWeakMode, rti.testingIsSubtype(universe, rti2, rti1)); + Expect.equals( + hasUnsoundNullSafety, rti.testingIsSubtype(universe, rti2, rti1)); // Rti.toString() appears as expected Expect.equals('(B, {required B a, B b, required B c}) => dynamic', diff --git a/tests/dart2js/internal/rti/subtype_test.dart b/tests/dart2js/internal/rti/subtype_test.dart index 68f4de723ca..d4f0c48d5e4 100644 --- a/tests/dart2js/internal/rti/subtype_test.dart +++ b/tests/dart2js/internal/rti/subtype_test.dart @@ -78,7 +78,7 @@ void testTopTypes() { } void testNull() { - if (isStrongMode) { + if (hasSoundNullSafety) { unrelated(nullName, 'int'); unrelated(nullName, 'Iterable'); unrelated(nullName, objectName); @@ -93,7 +93,7 @@ void testNull() { void testBottom() { String never = '0&'; - if (isStrongMode) { + if (hasSoundNullSafety) { strictSubtype(never, nullName); } else { equivalent(never, nullName); diff --git a/tests/dart2js_2/internal/rti/required_named_parameters_test.dart b/tests/dart2js_2/internal/rti/required_named_parameters_test.dart index c07f7a485d6..ccf3f7d29bb 100644 --- a/tests/dart2js_2/internal/rti/required_named_parameters_test.dart +++ b/tests/dart2js_2/internal/rti/required_named_parameters_test.dart @@ -51,11 +51,13 @@ main() { // Subtype may not redeclare optional parameters as required rti2 = rti.testingUniverseEval(universe, "@(A,{a!A,b!A,c!A})"); - Expect.equals(isWeakMode, rti.testingIsSubtype(universe, rti2, rti1)); + Expect.equals( + hasUnsoundNullSafety, rti.testingIsSubtype(universe, rti2, rti1)); // Subtype may not declare new required named parameters rti2 = rti.testingUniverseEval(universe, "@(A,{a!A,b:A,c!A,d!A})"); - Expect.equals(isWeakMode, rti.testingIsSubtype(universe, rti2, rti1)); + Expect.equals( + hasUnsoundNullSafety, rti.testingIsSubtype(universe, rti2, rti1)); // Rti.toString() appears as expected Expect.equals('(B, {required B a, B b, required B c}) => dynamic', diff --git a/tests/language/function_subtype/bound_closure5_test.dart b/tests/language/function_subtype/bound_closure5_test.dart index 1844a42d2cd..d498a1947b1 100644 --- a/tests/language/function_subtype/bound_closure5_test.dart +++ b/tests/language/function_subtype/bound_closure5_test.dart @@ -39,7 +39,7 @@ main() { new D().test('bool', true); new D().test('int', false); new D().test('Object', false); - new D().test('Null', isWeakMode); + new D().test('Null', hasUnsoundNullSafety); new D().test('Never', true); new D().test('dynamic', false); } diff --git a/tests/language/function_subtype/bound_closure5a_test.dart b/tests/language/function_subtype/bound_closure5a_test.dart index 38b173df39e..b5d274ba3eb 100644 --- a/tests/language/function_subtype/bound_closure5a_test.dart +++ b/tests/language/function_subtype/bound_closure5a_test.dart @@ -41,7 +41,7 @@ main() { new D().test('bool', true); new D().test('int', false); new D().test('Object', false); - new D().test('Null', isWeakMode); + new D().test('Null', hasUnsoundNullSafety); new D().test('Never', true); new D().test('dynamic', false); } diff --git a/tests/language/function_subtype/bound_closure6_test.dart b/tests/language/function_subtype/bound_closure6_test.dart index e26d21f807b..ea119a5f8dc 100644 --- a/tests/language/function_subtype/bound_closure6_test.dart +++ b/tests/language/function_subtype/bound_closure6_test.dart @@ -42,6 +42,6 @@ main() { new C().test('int', false); new C().test('Object', false); new C().test('dynamic', false); - new C().test('Null', isWeakMode); + new C().test('Null', hasUnsoundNullSafety); new C().test('Never', true); } diff --git a/tests/language/function_subtype/cast2_test.dart b/tests/language/function_subtype/cast2_test.dart index 03a8f536023..5e0f5b70d71 100644 --- a/tests/language/function_subtype/cast2_test.dart +++ b/tests/language/function_subtype/cast2_test.dart @@ -26,7 +26,7 @@ void bar(int i) {} void main() { new Class().test(false, bar, "dynamic"); new Class().test(false, bar, "Object"); - new Class().test(isWeakMode, bar, "Null"); + new Class().test(hasUnsoundNullSafety, bar, "Null"); new Class().test(true, bar, "Never"); new Class().test(true, bar, "int"); new Class().test(false, bar, "bool"); diff --git a/tests/language/function_subtype/checked0_test.dart b/tests/language/function_subtype/checked0_test.dart index a3145297f3e..40abf58304a 100644 --- a/tests/language/function_subtype/checked0_test.dart +++ b/tests/language/function_subtype/checked0_test.dart @@ -69,6 +69,6 @@ main() { new C().test('int', false); new C().test('dynamic', false); new C().test('Object', false); - new C().test('Null', isWeakMode); + new C().test('Null', hasUnsoundNullSafety); new C().test('Null', true); } diff --git a/tests/language/function_subtype/inline0_test.dart b/tests/language/function_subtype/inline0_test.dart index 4e999980b27..c28d1d0da64 100644 --- a/tests/language/function_subtype/inline0_test.dart +++ b/tests/language/function_subtype/inline0_test.dart @@ -41,7 +41,7 @@ class C { } main() { - new C().test('bool', true, isWeakMode); + new C().test('bool', true, hasUnsoundNullSafety); new C().test('int', false, false); - new C().test('dynamic', true, isWeakMode); + new C().test('dynamic', true, hasUnsoundNullSafety); } diff --git a/tests/language/function_subtype/inline2_test.dart b/tests/language/function_subtype/inline2_test.dart index a3f40780765..2f63a3db976 100644 --- a/tests/language/function_subtype/inline2_test.dart +++ b/tests/language/function_subtype/inline2_test.dart @@ -23,7 +23,7 @@ void test(var f, String constructorName) { testDynamicTypeError(false, () => f(m1), "'new C.$constructorName(m1)'"); testDynamicTypeError(true, () => f(m2), "'new C.$constructorName(m2)'"); testDynamicTypeError( - isStrongMode, () => f(m3), "'new C.$constructorName(m3)'"); + hasSoundNullSafety, () => f(m3), "'new C.$constructorName(m3)'"); testDynamicTypeError(true, () => f(m4), "'new C.$constructorName(m4)'"); testDynamicTypeError(false, () => f(m5), "'new C.$constructorName(m5)'"); } diff --git a/tests/language/function_subtype/local2_test.dart b/tests/language/function_subtype/local2_test.dart index 7b0d19d06f0..fe3de216f94 100644 --- a/tests/language/function_subtype/local2_test.dart +++ b/tests/language/function_subtype/local2_test.dart @@ -38,6 +38,6 @@ main() { new C().test('int', false); new C().test('dynamic', false); new C().test('Object', false); - new C().test('Null', isWeakMode); + new C().test('Null', hasUnsoundNullSafety); new C().test('Never', true); } diff --git a/tests/language/function_subtype/local5_test.dart b/tests/language/function_subtype/local5_test.dart index 92d570f0950..18c887ce14a 100644 --- a/tests/language/function_subtype/local5_test.dart +++ b/tests/language/function_subtype/local5_test.dart @@ -40,6 +40,6 @@ main() { new D().test('int', false); new D().test('dynamic', false); new D().test('Object', false); - new D().test('Null', isWeakMode); + new D().test('Null', hasUnsoundNullSafety); new D().test('Never', true); } diff --git a/tests/language/function_subtype/not2_test.dart b/tests/language/function_subtype/not2_test.dart index 03b01103bbe..ffad8f71ed4 100644 --- a/tests/language/function_subtype/not2_test.dart +++ b/tests/language/function_subtype/not2_test.dart @@ -22,7 +22,7 @@ void bar(int i) {} void main() { new Class().test(true, bar, "dynamic"); new Class().test(true, bar, "Object"); - new Class().test(isStrongMode, bar, "Null"); + new Class().test(hasSoundNullSafety, bar, "Null"); new Class().test(false, bar, "Never"); new Class().test(false, bar, "int"); new Class().test(true, bar, "bool"); diff --git a/tests/language/function_subtype/not3_test.dart b/tests/language/function_subtype/not3_test.dart index 0c038265b43..e3d23bc6365 100644 --- a/tests/language/function_subtype/not3_test.dart +++ b/tests/language/function_subtype/not3_test.dart @@ -26,7 +26,7 @@ void bar(int i) {} void main() { new Class().test(true, bar, "dynamic"); new Class().test(true, bar, "Object"); - new Class().test(isStrongMode, bar, "Null"); + new Class().test(hasSoundNullSafety, bar, "Null"); new Class().test(false, bar, "Never"); new Class().test(false, bar, "int"); new Class().test(true, bar, "bool"); diff --git a/tests/language/function_subtype/top_level1_test.dart b/tests/language/function_subtype/top_level1_test.dart index 4e2d763c2d1..92aac322e36 100644 --- a/tests/language/function_subtype/top_level1_test.dart +++ b/tests/language/function_subtype/top_level1_test.dart @@ -40,6 +40,6 @@ main() { new C().test('int', false); new C().test('Object', false); new C().test('dynamic', false); - new C().test('Null', isWeakMode); + new C().test('Null', hasUnsoundNullSafety); new C().test('Never', true); } diff --git a/tests/language/generic/instanceof.dart b/tests/language/generic/instanceof.dart index 547239c4741..d90b97ead9e 100644 --- a/tests/language/generic/instanceof.dart +++ b/tests/language/generic/instanceof.dart @@ -56,7 +56,7 @@ class GenericInstanceof { } { Foo foo = new Foo>(); - Expect.equals(isWeakMode, foo.isT(new List.filled(5, null))); + Expect.equals(hasUnsoundNullSafety, foo.isT(new List.filled(5, null))); Expect.equals(true, foo.isT(new List.filled(5, "o"))); Expect.equals(true, foo.isT(new List.filled(5, 0))); Expect.equals(true, foo.isT(new List.filled(5, 0))); @@ -64,7 +64,7 @@ class GenericInstanceof { } { Foo foo = new Foo>(); - Expect.equals(isWeakMode, foo.isT(new List.filled(5, null))); + Expect.equals(hasUnsoundNullSafety, foo.isT(new List.filled(5, null))); Expect.equals(false, foo.isT(new List.filled(5, "o"))); Expect.equals(true, foo.isT(new List.filled(5, 0))); Expect.equals(false, foo.isT(new List.filled(5, 0))); @@ -72,7 +72,7 @@ class GenericInstanceof { } { Foo foo = new Foo>(); - Expect.equals(isWeakMode, foo.isT(new List.filled(5, null))); + Expect.equals(hasUnsoundNullSafety, foo.isT(new List.filled(5, null))); Expect.equals(false, foo.isT(new List.filled(5, "o"))); Expect.equals(true, foo.isT(new List.filled(5, 0))); Expect.equals(true, foo.isT(new List.filled(5, 0))); @@ -80,7 +80,7 @@ class GenericInstanceof { } { Foo foo = new Foo>(); - Expect.equals(isWeakMode, foo.isT(new List.filled(5, null))); + Expect.equals(hasUnsoundNullSafety, foo.isT(new List.filled(5, null))); Expect.equals(false, foo.isT(new List.filled(5, "o"))); Expect.equals(false, foo.isT(new List.filled(5, 0))); Expect.equals(false, foo.isT(new List.filled(5, 0))); @@ -96,7 +96,8 @@ class GenericInstanceof { } { Foo foo = new Foo(); - Expect.equals(isWeakMode, foo.isListT(new List.filled(5, null))); + Expect.equals( + hasUnsoundNullSafety, foo.isListT(new List.filled(5, null))); Expect.equals(true, foo.isListT(new List.filled(5, "o"))); Expect.equals(true, foo.isListT(new List.filled(5, 0))); Expect.equals(true, foo.isListT(new List.filled(5, 0))); @@ -104,7 +105,8 @@ class GenericInstanceof { } { Foo foo = new Foo(); - Expect.equals(isWeakMode, foo.isListT(new List.filled(5, null))); + Expect.equals( + hasUnsoundNullSafety, foo.isListT(new List.filled(5, null))); Expect.equals(false, foo.isListT(new List.filled(5, "o"))); Expect.equals(true, foo.isListT(new List.filled(5, 0))); Expect.equals(false, foo.isListT(new List.filled(5, 0))); @@ -112,7 +114,8 @@ class GenericInstanceof { } { Foo foo = new Foo(); - Expect.equals(isWeakMode, foo.isListT(new List.filled(5, null))); + Expect.equals( + hasUnsoundNullSafety, foo.isListT(new List.filled(5, null))); Expect.equals(false, foo.isListT(new List.filled(5, "o"))); Expect.equals(true, foo.isListT(new List.filled(5, 0))); Expect.equals(true, foo.isListT(new List.filled(5, 0))); @@ -120,7 +123,8 @@ class GenericInstanceof { } { Foo foo = new Foo(); - Expect.equals(isWeakMode, foo.isListT(new List.filled(5, null))); + Expect.equals( + hasUnsoundNullSafety, foo.isListT(new List.filled(5, null))); Expect.equals(false, foo.isListT(new List.filled(5, "o"))); Expect.equals(false, foo.isListT(new List.filled(5, 0))); Expect.equals(false, foo.isListT(new List.filled(5, 0))); diff --git a/tests/language/generic_methods/generic_class_tearoff_test.dart b/tests/language/generic_methods/generic_class_tearoff_test.dart index 6c98ba88404..28e9b8fe1d2 100644 --- a/tests/language/generic_methods/generic_class_tearoff_test.dart +++ b/tests/language/generic_methods/generic_class_tearoff_test.dart @@ -38,6 +38,6 @@ main() { Expect.isTrue(h is! Int2Int); Expect.isTrue(h is! String2String); - Expect.equals(isWeakMode, h is Object2Object); + Expect.equals(hasUnsoundNullSafety, h is Object2Object); Expect.isTrue(h is! GenericMethod); } diff --git a/tests/language/is/is2_test.dart b/tests/language/is/is2_test.dart index 93f6fb2f986..1d418b714c1 100644 --- a/tests/language/is/is2_test.dart +++ b/tests/language/is/is2_test.dart @@ -59,7 +59,7 @@ class InstanceofTest { var a = new List.empty(); Expect.equals(true, a is List); Expect.equals(true, a is List); - Expect.equals(isWeakMode, a is List); + Expect.equals(hasUnsoundNullSafety, a is List); Expect.equals(false, a is List); Expect.equals(false, a is List); Expect.equals(false, a is List); diff --git a/tests/language/nnbd/constant_null_safety_mode_test.dart b/tests/language/nnbd/constant_null_safety_mode_test.dart index 131a2ff447b..6e89c754d6e 100644 --- a/tests/language/nnbd/constant_null_safety_mode_test.dart +++ b/tests/language/nnbd/constant_null_safety_mode_test.dart @@ -5,15 +5,15 @@ import 'package:expect/expect.dart'; main() { - const trueInWeakMode = [] is List; - Expect.equals(isWeakMode, trueInWeakMode); + const trueInNoSoundMode = [] is List; + Expect.equals(hasUnsoundNullSafety, trueInNoSoundMode); // The following tests use the Uri.pathSegments() to access a constant list // that is defined in the SDK and verify the type associated with it does not // allow null when running with sound null safety. var emptyUri = Uri(pathSegments: []); dynamic stringList = emptyUri.pathSegments.toList(); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() { stringList.add(null); }); diff --git a/tests/language/null/null_test.dart b/tests/language/null/null_test.dart index f13312d24dd..48e9b25610e 100644 --- a/tests/language/null/null_test.dart +++ b/tests/language/null/null_test.dart @@ -145,13 +145,13 @@ void test() { // Test cast, "as", operator. Expect.equals(null, null as Null); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() => null as Object); } else { Expect.equals(null, null as Object); } Expect.equals(null, null as Object?); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() => null as int); } else { Expect.equals(null, null as int); @@ -163,13 +163,13 @@ void test() { Expect.equals(null, new Generic().cast(null)); Expect.equals(null, obj as Null); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() => obj as Object); } else { Expect.equals(null, obj as Object); } Expect.equals(null, obj as Object?); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() => obj as int); } else { Expect.equals(null, obj as int); diff --git a/tests/language/regress/regress34147_test.dart b/tests/language/regress/regress34147_test.dart index 20ab478a2bc..ab7197e449c 100644 --- a/tests/language/regress/regress34147_test.dart +++ b/tests/language/regress/regress34147_test.dart @@ -16,7 +16,7 @@ void main() { } void expectError(Function() callback) { - if (isWeakMode) { + if (hasUnsoundNullSafety) { Expect.throwsAssertionError(callback); } else { Expect.throwsTypeError(callback); diff --git a/tests/language/regress/regress41890_test.dart b/tests/language/regress/regress41890_test.dart index 86e43a7e2b4..9374e28401d 100644 --- a/tests/language/regress/regress41890_test.dart +++ b/tests/language/regress/regress41890_test.dart @@ -43,8 +43,8 @@ void test() { var item = items[i]; String code = answers[i]; bool expected = code == 'T' || - (code == 'S' && isStrongMode) || - (code == 'W' && isWeakMode); + (code == 'S' && hasSoundNullSafety) || + (code == 'W' && hasUnsoundNullSafety); Expect.equals(expected, predicate(item), "$predicate '$code' $item"); } } diff --git a/tests/language/vm/bool_check_stack_traces_test.dart b/tests/language/vm/bool_check_stack_traces_test.dart index bdc9ce551a3..e27da73d163 100644 --- a/tests/language/vm/bool_check_stack_traces_test.dart +++ b/tests/language/vm/bool_check_stack_traces_test.dart @@ -81,7 +81,7 @@ void testStackTrace(void testCase(dynamic condition), List lineNumbers) { print(stacktrace); print('-----------------------------'); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.isTrue(e is TypeError); Expect.equals( "type 'Null' is not a subtype of type 'bool'", e.toString()); diff --git a/tests/lib/mirrors/null_test.dart b/tests/lib/mirrors/null_test.dart index 0d5853974db..ab4c9156a3b 100644 --- a/tests/lib/mirrors/null_test.dart +++ b/tests/lib/mirrors/null_test.dart @@ -18,7 +18,7 @@ void test() { InstanceMirror im1 = reflect(null); Expect.equals(cm, im1.type); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() => im1.invoke(const Symbol("=="), [null]), 'null not assignable to Object'); } else { @@ -29,7 +29,7 @@ void test() { var obj = confuse(null); // Null value that isn't known at compile-time. InstanceMirror im2 = reflect(obj); Expect.equals(cm, im2.type); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError(() => im2.invoke(const Symbol("=="), [null]), 'null not assignable to Object'); } else { @@ -41,7 +41,7 @@ void test() { Expect.isTrue(nullMirror.getField(#hashCode).reflectee is int); Expect.equals(null.hashCode, nullMirror.getField(#hashCode).reflectee); Expect.equals('Null', nullMirror.getField(#runtimeType).reflectee.toString()); - if (isStrongMode) { + if (hasSoundNullSafety) { Expect.throwsTypeError( () => nullMirror.invoke(#==, [null]), 'null not assignable to Object'); } else {