@@ -528,8 +528,8 @@ class BoundsHelperPredicatesTest extends _BoundsTestBase {
528
528
class LowerBoundTest extends _BoundsTestBase {
529
529
test_bottom_any () {
530
530
void check (DartType T1 , DartType T2 ) {
531
- expect (typeSystem. isBottom ( T1 ), isTrue, reason : _typeString ( T1 ) );
532
- expect (typeSystem. isBottom ( T2 ), isFalse, reason : _typeString ( T2 ) );
531
+ _assertBottom ( T1 );
532
+ _assertNotBottom ( T2 );
533
533
_checkGreatestLowerBound (T1 , T2 , T1 );
534
534
}
535
535
@@ -571,8 +571,8 @@ class LowerBoundTest extends _BoundsTestBase {
571
571
572
572
test_bottom_bottom () {
573
573
void check (DartType T1 , DartType T2 ) {
574
- expect (typeSystem. isBottom ( T1 ), isTrue, reason : _typeString ( T1 ) );
575
- expect (typeSystem. isBottom ( T2 ), isTrue, reason : _typeString ( T2 ) );
574
+ _assertBottom ( T1 );
575
+ _assertBottom ( T2 );
576
576
_checkGreatestLowerBound (T1 , T2 , T1 );
577
577
}
578
578
@@ -1097,11 +1097,9 @@ class LowerBoundTest extends _BoundsTestBase {
1097
1097
1098
1098
test_null_any () {
1099
1099
void check (DartType T2 , DartType expected) {
1100
- var T2_str = _typeString (T2 );
1101
-
1102
- expect (typeSystem.isNull (T2 ), isFalse, reason: 'isNull: $T2_str ' );
1103
- expect (typeSystem.isTop (T2 ), isFalse, reason: 'isTop: $T2_str ' );
1104
- expect (typeSystem.isBottom (T2 ), isFalse, reason: 'isBottom: $T2_str ' );
1100
+ _assertNotBottom (T2 );
1101
+ _assertNotNull (T2 );
1102
+ _assertNotTop (T2 );
1105
1103
1106
1104
_checkGreatestLowerBound (nullNone, T2 , expected);
1107
1105
}
@@ -1143,14 +1141,11 @@ class LowerBoundTest extends _BoundsTestBase {
1143
1141
1144
1142
test_null_null () {
1145
1143
void check (DartType T1 , DartType T2 ) {
1146
- var T1_str = _typeString (T1 );
1147
- var T2_str = _typeString (T2 );
1148
-
1149
- expect (typeSystem.isNull (T1 ), isTrue, reason: 'isNull: $T1_str ' );
1150
- expect (typeSystem.isNull (T2 ), isTrue, reason: 'isNull: $T2_str ' );
1144
+ _assertNull (T1 );
1145
+ _assertNull (T2 );
1151
1146
1152
- expect (typeSystem. isBottom ( T1 ), isFalse, reason : 'isBottom: $ T1_str ' );
1153
- expect (typeSystem. isBottom ( T2 ), isFalse, reason : 'isBottom: $ T2_str ' );
1147
+ _assertNotBottom ( T1 );
1148
+ _assertNotBottom ( T2 );
1154
1149
1155
1150
_checkGreatestLowerBound (T1 , T2 , T1 );
1156
1151
}
@@ -1161,8 +1156,7 @@ class LowerBoundTest extends _BoundsTestBase {
1161
1156
1162
1157
test_object_any () {
1163
1158
void check (DartType T2 , DartType expected) {
1164
- var T2_str = _typeString (T2 );
1165
- expect (typeSystem.isObject (T2 ), isFalse, reason: 'isObject: $T2_str ' );
1159
+ _assertNotObject (T2 );
1166
1160
1167
1161
_checkGreatestLowerBound (objectNone, T2 , expected);
1168
1162
}
@@ -1216,11 +1210,8 @@ class LowerBoundTest extends _BoundsTestBase {
1216
1210
1217
1211
test_object_object () {
1218
1212
void check (DartType T1 , DartType T2 ) {
1219
- var T1_str = _typeString (T1 );
1220
- var T2_str = _typeString (T2 );
1221
-
1222
- expect (typeSystem.isObject (T1 ), isTrue, reason: 'isObject: $T1_str ' );
1223
- expect (typeSystem.isObject (T2 ), isTrue, reason: 'isObject: $T2_str ' );
1213
+ _assertObject (T1 );
1214
+ _assertObject (T2 );
1224
1215
1225
1216
_checkGreatestLowerBound (T1 , T2 , T1 );
1226
1217
}
@@ -1309,8 +1300,8 @@ class LowerBoundTest extends _BoundsTestBase {
1309
1300
1310
1301
test_top_any () {
1311
1302
void check (DartType T1 , DartType T2 ) {
1312
- expect (typeSystem. isTop ( T1 ), isTrue, reason : _typeString ( T1 ) );
1313
- expect (typeSystem. isTop ( T2 ), isFalse, reason : _typeString ( T2 ) );
1303
+ _assertTop ( T1 );
1304
+ _assertNotTop ( T2 );
1314
1305
_checkGreatestLowerBound (T1 , T2 , T2 );
1315
1306
}
1316
1307
@@ -1357,8 +1348,8 @@ class LowerBoundTest extends _BoundsTestBase {
1357
1348
1358
1349
test_top_top () {
1359
1350
void check (DartType T1 , DartType T2 ) {
1360
- expect (typeSystem. isTop ( T1 ), isTrue, reason : _typeString ( T1 ) );
1361
- expect (typeSystem. isTop ( T2 ), isTrue, reason : _typeString ( T2 ) );
1351
+ _assertTop ( T1 );
1352
+ _assertTop ( T2 );
1362
1353
_checkGreatestLowerBound (T1 , T2 , T2 );
1363
1354
}
1364
1355
@@ -1458,8 +1449,8 @@ actual: $resultStr
1458
1449
class UpperBoundTest extends _BoundsTestBase {
1459
1450
test_bottom_any () {
1460
1451
void check (DartType T1 , DartType T2 ) {
1461
- expect (typeSystem. isBottom ( T1 ), isTrue, reason : _typeString ( T1 ) );
1462
- expect (typeSystem. isBottom ( T2 ), isFalse, reason : _typeString ( T2 ) );
1452
+ _assertBottom ( T1 );
1453
+ _assertNotBottom ( T2 );
1463
1454
_checkLeastUpperBound (T1 , T2 , T2 );
1464
1455
}
1465
1456
@@ -1501,8 +1492,8 @@ class UpperBoundTest extends _BoundsTestBase {
1501
1492
1502
1493
test_bottom_bottom () {
1503
1494
void check (DartType T1 , DartType T2 ) {
1504
- expect (typeSystem. isBottom ( T1 ), isTrue, reason : _typeString ( T1 ) );
1505
- expect (typeSystem. isBottom ( T2 ), isTrue, reason : _typeString ( T2 ) );
1495
+ _assertBottom ( T1 );
1496
+ _assertBottom ( T2 );
1506
1497
_checkLeastUpperBound (T1 , T2 , T2 );
1507
1498
}
1508
1499
@@ -1894,17 +1885,14 @@ class UpperBoundTest extends _BoundsTestBase {
1894
1885
1895
1886
test_null_any () {
1896
1887
void check (DartType T1 , DartType T2 , DartType expected) {
1897
- var T1_str = _typeString (T1 );
1898
- var T2_str = _typeString (T2 );
1888
+ _assertNull (T1 );
1889
+ _assertNotNull (T2 );
1899
1890
1900
- expect (typeSystem. isNull ( T1 ), isTrue, reason : 'isNull: $ T1_str ' );
1901
- expect (typeSystem. isNull ( T2 ), isFalse, reason : 'isNull: $ T2_str ' );
1891
+ _assertNotTop ( T1 );
1892
+ _assertNotTop ( T2 );
1902
1893
1903
- expect (typeSystem.isTop (T1 ), isFalse, reason: 'isTop: $T1_str ' );
1904
- expect (typeSystem.isTop (T2 ), isFalse, reason: 'isTop: $T2_str ' );
1905
-
1906
- expect (typeSystem.isBottom (T1 ), isFalse, reason: 'isBottom: $T1_str ' );
1907
- expect (typeSystem.isBottom (T2 ), isFalse, reason: 'isBottom: $T2_str ' );
1894
+ _assertNotBottom (T1 );
1895
+ _assertNotBottom (T2 );
1908
1896
1909
1897
_checkLeastUpperBound (T1 , T2 , expected);
1910
1898
}
@@ -1943,14 +1931,11 @@ class UpperBoundTest extends _BoundsTestBase {
1943
1931
1944
1932
test_null_null () {
1945
1933
void check (DartType T1 , DartType T2 ) {
1946
- var T1_str = _typeString (T1 );
1947
- var T2_str = _typeString (T2 );
1948
-
1949
- expect (typeSystem.isNull (T1 ), isTrue, reason: 'isNull: $T1_str ' );
1950
- expect (typeSystem.isNull (T2 ), isTrue, reason: 'isNull: $T2_str ' );
1934
+ _assertNull (T1 );
1935
+ _assertNull (T2 );
1951
1936
1952
- expect (typeSystem. isBottom ( T1 ), isFalse, reason : 'isBottom: $ T1_str ' );
1953
- expect (typeSystem. isBottom ( T2 ), isFalse, reason : 'isBottom: $ T2_str ' );
1937
+ _assertNotBottom ( T1 );
1938
+ _assertNotBottom ( T2 );
1954
1939
1955
1940
_checkLeastUpperBound (T1 , T2 , T2 );
1956
1941
}
@@ -1961,11 +1946,8 @@ class UpperBoundTest extends _BoundsTestBase {
1961
1946
1962
1947
test_object_any () {
1963
1948
void check (DartType T1 , DartType T2 , DartType expected) {
1964
- var T1_str = _typeString (T1 );
1965
- var T2_str = _typeString (T2 );
1966
-
1967
- expect (typeSystem.isObject (T1 ), isTrue, reason: 'isObject: $T1_str ' );
1968
- expect (typeSystem.isObject (T2 ), isFalse, reason: 'isObject: $T2_str ' );
1949
+ _assertObject (T1 );
1950
+ _assertNotObject (T2 );
1969
1951
1970
1952
_checkLeastUpperBound (T1 , T2 , expected);
1971
1953
}
@@ -1983,11 +1965,8 @@ class UpperBoundTest extends _BoundsTestBase {
1983
1965
1984
1966
test_object_object () {
1985
1967
void check (DartType T1 , DartType T2 ) {
1986
- var T1_str = _typeString (T1 );
1987
- var T2_str = _typeString (T2 );
1988
-
1989
- expect (typeSystem.isObject (T1 ), isTrue, reason: 'isObject: $T1_str ' );
1990
- expect (typeSystem.isObject (T2 ), isTrue, reason: 'isObject: $T2_str ' );
1968
+ _assertObject (T1 );
1969
+ _assertObject (T2 );
1991
1970
1992
1971
_checkLeastUpperBound (T1 , T2 , T2 );
1993
1972
}
@@ -2052,8 +2031,8 @@ class UpperBoundTest extends _BoundsTestBase {
2052
2031
2053
2032
test_top_any () {
2054
2033
void check (DartType T1 , DartType T2 ) {
2055
- expect (typeSystem. isTop ( T1 ), isTrue, reason : _typeString ( T1 ) );
2056
- expect (typeSystem. isTop ( T2 ), isFalse, reason : _typeString ( T2 ) );
2034
+ _assertTop ( T1 );
2035
+ _assertNotTop ( T2 );
2057
2036
_checkLeastUpperBound (T1 , T2 , T1 );
2058
2037
}
2059
2038
@@ -2092,8 +2071,8 @@ class UpperBoundTest extends _BoundsTestBase {
2092
2071
2093
2072
test_top_top () {
2094
2073
void check (DartType T1 , DartType T2 ) {
2095
- expect (typeSystem. isTop ( T1 ), isTrue, reason : _typeString ( T1 ) );
2096
- expect (typeSystem. isTop ( T2 ), isTrue, reason : _typeString ( T2 ) );
2074
+ _assertTop ( T1 );
2075
+ _assertTop ( T2 );
2097
2076
_checkLeastUpperBound (T1 , T2 , T1 );
2098
2077
}
2099
2078
@@ -2214,6 +2193,12 @@ actual: $resultStr
2214
2193
2215
2194
@reflectiveTest
2216
2195
class _BoundsTestBase extends AbstractTypeSystemNullSafetyTest {
2196
+ void _assertBottom (DartType type) {
2197
+ if (! typeSystem.isBottom (type)) {
2198
+ fail ('isBottom must be true: ' + _typeString (type));
2199
+ }
2200
+ }
2201
+
2217
2202
void _assertNotBottom (DartType type) {
2218
2203
if (typeSystem.isBottom (type)) {
2219
2204
fail ('isBottom must be false: ' + _typeString (type));
@@ -2245,6 +2230,12 @@ class _BoundsTestBase extends AbstractTypeSystemNullSafetyTest {
2245
2230
}
2246
2231
}
2247
2232
2233
+ void _assertNull (DartType type) {
2234
+ if (! typeSystem.isNull (type)) {
2235
+ fail ('isNull must be true: ' + _typeString (type));
2236
+ }
2237
+ }
2238
+
2248
2239
void _assertNullability (DartType type, NullabilitySuffix expected) {
2249
2240
if (type.nullabilitySuffix != expected) {
2250
2241
fail ('Expected $expected in ' + _typeString (type));
@@ -2263,6 +2254,18 @@ class _BoundsTestBase extends AbstractTypeSystemNullSafetyTest {
2263
2254
_assertNullability (type, NullabilitySuffix .star);
2264
2255
}
2265
2256
2257
+ void _assertObject (DartType type) {
2258
+ if (! typeSystem.isObject (type)) {
2259
+ fail ('isObject must be true: ' + _typeString (type));
2260
+ }
2261
+ }
2262
+
2263
+ void _assertTop (DartType type) {
2264
+ if (! typeSystem.isTop (type)) {
2265
+ fail ('isTop must be true: ' + _typeString (type));
2266
+ }
2267
+ }
2268
+
2266
2269
String _typeParametersStr (TypeImpl type) {
2267
2270
var typeStr = '' ;
2268
2271
0 commit comments