Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: tests/language/function_type/function_type4_test.dart

Issue 2879153005: Add support to dart2js for option --enable-asserts. (Closed)
Patch Set: Formatting Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/language/function_type/function_type4_test.dart
diff --git a/tests/language/function_type/function_type4_test.dart b/tests/language/function_type/function_type4_test.dart
index 17edd153da7530520a6b0185358893741cb1da9c..317bb697e773191d3357873737a6194ee5386f18 100644
--- a/tests/language/function_type/function_type4_test.dart
+++ b/tests/language/function_type/function_type4_test.dart
@@ -19,10 +19,6 @@ import 'package:expect/expect.dart';
@AssumeDynamic()
confuse(f) => f;
-final bool inCheckedMode =
- (() { bool result = false; assert(result = true); return result; })();
-
-
typedef F0<T> = int Function(int x0);
typedef F1<T> = Function Function(List<T> x0);
typedef F2<T> = core.List<core.int> Function(int y, [core.List<core.int> x]);
@@ -36,7 +32,8 @@ typedef F9<T> = Function Function(int y, {List<T> x}) Function();
typedef F10<T> = List<Function> Function([List<Function> x]) Function();
typedef F11<T> = List<Function> Function(List<T> x0) Function();
typedef F12<T> = core.List<core.int> Function(int x1, [Function x2]) Function();
-typedef F13<T> = core.List<core.int> Function(int x0, {core.List<core.int> x}) Function();
+typedef F13<T> = core.List<core.int> Function(int x0, {core.List<core.int> x})
+ Function();
typedef F14<T> = List<T> Function(Function x) Function();
typedef F15<T> = List<T> Function(int y, [core.List<core.int> x]) Function();
typedef F16<T> = Function([int x1]) Function();
@@ -48,7 +45,6 @@ typedef F21<T> = List<Function> Function<A>(List<Function> x) Function();
typedef F22<T> = Function<A>(core.List<core.int> x) Function();
typedef F23<T> = void Function<A>(List<T> x) Function();
-
int f0(int x0) => null;
Function f1(List<int> x0) => null;
core.List<core.int> f2(int y, [core.List<core.int> x]) => null;
@@ -74,7 +70,6 @@ List<Function> Function<A>(List<Function> x) f21() => null;
Function<A>(core.List<core.int> x) f22() => null;
void Function<A>(List<int> x) f23() => null;
-
class U4<T> {
final bool tIsBool;
final bool tIsInt;
@@ -105,7 +100,6 @@ class U4<T> {
Function<A>(core.List<core.int> x) Function() x22;
void Function<A>(List<T> x) Function() x23;
-
U4({this.tIsBool: false, this.tIsInt: false})
: tIsDynamic = !tIsBool && !tIsInt;
@@ -134,7 +128,6 @@ class U4<T> {
Function<A>(core.List<core.int> x) m22() => null;
void Function<A>(List<T> x) m23() => null;
-
runTests() {
testF0();
testF1();
@@ -184,7 +177,6 @@ class U4<T> {
l0 = m0;
x0 = confuse(m0);
l0 = confuse(m0);
-
}
/// Function Function(List<T> x0)
@@ -217,12 +209,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m1 is F1<bool>);
Expect.equals(tIsDynamic, confuse(m1) is F1<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x1 = (f1 as dynamic); });
- Expect.throws(() { x1 = confuse(f1); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x1 = (f1 as dynamic);
+ });
+ Expect.throws(() {
+ x1 = confuse(f1);
+ });
Function Function(List<T> x0) l1;
- Expect.throws(() { l1 = (f1 as dynamic); });
- Expect.throws(() { l1 = confuse(f1); });
+ Expect.throws(() {
+ l1 = (f1 as dynamic);
+ });
+ Expect.throws(() {
+ l1 = confuse(f1);
+ });
}
Function Function(List<T> x0) l1 = m1;
// In checked mode, verifies the type.
@@ -246,14 +246,14 @@ class U4<T> {
}
Expect.isTrue(m2 is F2);
- Expect.isTrue(m2 is core.List<core.int> Function(int y, [core.List<core.int> x]));
+ Expect.isTrue(
+ m2 is core.List<core.int> Function(int y, [core.List<core.int> x]));
Expect.isTrue(confuse(m2) is F2);
// In checked mode, verifies the type.
x2 = m2;
l2 = m2;
x2 = confuse(m2);
l2 = confuse(m2);
-
}
/// Function(int x0, [List<Function> x])
@@ -278,7 +278,6 @@ class U4<T> {
l3 = m3;
x3 = confuse(m3);
l3 = confuse(m3);
-
}
/// Function Function<A>(List<T> x)
@@ -311,12 +310,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m4 is F4<bool>);
Expect.equals(tIsDynamic, confuse(m4) is F4<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x4 = (f4 as dynamic); });
- Expect.throws(() { x4 = confuse(f4); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x4 = (f4 as dynamic);
+ });
+ Expect.throws(() {
+ x4 = confuse(f4);
+ });
Function Function<A>(List<T> x) l4;
- Expect.throws(() { l4 = (f4 as dynamic); });
- Expect.throws(() { l4 = confuse(f4); });
+ Expect.throws(() {
+ l4 = (f4 as dynamic);
+ });
+ Expect.throws(() {
+ l4 = confuse(f4);
+ });
}
Function Function<A>(List<T> x) l4 = m4;
// In checked mode, verifies the type.
@@ -347,7 +354,6 @@ class U4<T> {
l5 = m5;
x5 = confuse(m5);
l5 = confuse(m5);
-
}
/// int Function(int x0, [core.List<core.int> x]) Function()
@@ -365,14 +371,14 @@ class U4<T> {
}
Expect.isTrue(m6 is F6);
- Expect.isTrue(m6 is int Function(int x0, [core.List<core.int> x]) Function());
+ Expect
+ .isTrue(m6 is int Function(int x0, [core.List<core.int> x]) Function());
Expect.isTrue(confuse(m6) is F6);
// In checked mode, verifies the type.
x6 = m6;
l6 = m6;
x6 = confuse(m6);
l6 = confuse(m6);
-
}
/// Function Function(int x0) Function()
@@ -397,7 +403,6 @@ class U4<T> {
l7 = m7;
x7 = confuse(m7);
l7 = confuse(m7);
-
}
/// Function Function(int x, [List<Function> x2]) Function()
@@ -415,14 +420,14 @@ class U4<T> {
}
Expect.isTrue(m8 is F8);
- Expect.isTrue(m8 is Function Function(int x, [List<Function> x2]) Function());
+ Expect
+ .isTrue(m8 is Function Function(int x, [List<Function> x2]) Function());
Expect.isTrue(confuse(m8) is F8);
// In checked mode, verifies the type.
x8 = m8;
l8 = m8;
x8 = confuse(m8);
l8 = confuse(m8);
-
}
/// Function Function(int y, {List<T> x}) Function()
@@ -455,12 +460,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m9 is F9<bool>);
Expect.equals(tIsDynamic, confuse(m9) is F9<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x9 = (f9 as dynamic); });
- Expect.throws(() { x9 = confuse(f9); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x9 = (f9 as dynamic);
+ });
+ Expect.throws(() {
+ x9 = confuse(f9);
+ });
Function Function(int y, {List<T> x}) Function() l9;
- Expect.throws(() { l9 = (f9 as dynamic); });
- Expect.throws(() { l9 = confuse(f9); });
+ Expect.throws(() {
+ l9 = (f9 as dynamic);
+ });
+ Expect.throws(() {
+ l9 = confuse(f9);
+ });
}
Function Function(int y, {List<T> x}) Function() l9 = m9;
// In checked mode, verifies the type.
@@ -484,14 +497,14 @@ class U4<T> {
}
Expect.isTrue(m10 is F10);
- Expect.isTrue(m10 is List<Function> Function([List<Function> x]) Function());
+ Expect
+ .isTrue(m10 is List<Function> Function([List<Function> x]) Function());
Expect.isTrue(confuse(m10) is F10);
// In checked mode, verifies the type.
x10 = m10;
l10 = m10;
x10 = confuse(m10);
l10 = confuse(m10);
-
}
/// List<Function> Function(List<T> x0) Function()
@@ -524,12 +537,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m11 is F11<bool>);
Expect.equals(tIsDynamic, confuse(m11) is F11<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x11 = (f11 as dynamic); });
- Expect.throws(() { x11 = confuse(f11); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x11 = (f11 as dynamic);
+ });
+ Expect.throws(() {
+ x11 = confuse(f11);
+ });
List<Function> Function(List<T> x0) Function() l11;
- Expect.throws(() { l11 = (f11 as dynamic); });
- Expect.throws(() { l11 = confuse(f11); });
+ Expect.throws(() {
+ l11 = (f11 as dynamic);
+ });
+ Expect.throws(() {
+ l11 = confuse(f11);
+ });
}
List<Function> Function(List<T> x0) Function() l11 = m11;
// In checked mode, verifies the type.
@@ -553,14 +574,14 @@ class U4<T> {
}
Expect.isTrue(m12 is F12);
- Expect.isTrue(m12 is core.List<core.int> Function(int x1, [Function x2]) Function());
+ Expect.isTrue(
+ m12 is core.List<core.int> Function(int x1, [Function x2]) Function());
Expect.isTrue(confuse(m12) is F12);
// In checked mode, verifies the type.
x12 = m12;
l12 = m12;
x12 = confuse(m12);
l12 = confuse(m12);
-
}
/// core.List<core.int> Function(int x0, {core.List<core.int> x}) Function()
@@ -568,7 +589,8 @@ class U4<T> {
Expect.isTrue(f13 is F13);
Expect.isTrue(confuse(f13) is F13);
// In checked mode, verifies the type.
- core.List<core.int> Function(int x0, {core.List<core.int> x}) Function() l13;
+ core.List<core.int> Function(int x0, {core.List<core.int> x}) Function()
+ l13;
// The static function f13 sets `T` to `int`.
if (!tIsBool) {
x13 = f13 as dynamic;
@@ -578,14 +600,15 @@ class U4<T> {
}
Expect.isTrue(m13 is F13);
- Expect.isTrue(m13 is core.List<core.int> Function(int x0, {core.List<core.int> x}) Function());
+ Expect.isTrue(m13 is core.List<core.int> Function(int x0,
+ {core.List<core.int> x})
+ Function());
Expect.isTrue(confuse(m13) is F13);
// In checked mode, verifies the type.
x13 = m13;
l13 = m13;
x13 = confuse(m13);
l13 = confuse(m13);
-
}
/// List<T> Function(Function x) Function()
@@ -618,12 +641,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m14 is F14<bool>);
Expect.equals(tIsDynamic, confuse(m14) is F14<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x14 = (f14 as dynamic); });
- Expect.throws(() { x14 = confuse(f14); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x14 = (f14 as dynamic);
+ });
+ Expect.throws(() {
+ x14 = confuse(f14);
+ });
List<T> Function(Function x) Function() l14;
- Expect.throws(() { l14 = (f14 as dynamic); });
- Expect.throws(() { l14 = confuse(f14); });
+ Expect.throws(() {
+ l14 = (f14 as dynamic);
+ });
+ Expect.throws(() {
+ l14 = confuse(f14);
+ });
}
List<T> Function(Function x) Function() l14 = m14;
// In checked mode, verifies the type.
@@ -647,7 +678,8 @@ class U4<T> {
}
Expect.isTrue(m15 is F15);
- Expect.isTrue(m15 is List<T> Function(int y, [core.List<core.int> x]) Function());
+ Expect.isTrue(
+ m15 is List<T> Function(int y, [core.List<core.int> x]) Function());
Expect.isTrue(confuse(m15) is F15);
// In checked mode, verifies the type.
x15 = m15;
@@ -662,12 +694,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m15 is F15<bool>);
Expect.equals(tIsDynamic, confuse(m15) is F15<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x15 = (f15 as dynamic); });
- Expect.throws(() { x15 = confuse(f15); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x15 = (f15 as dynamic);
+ });
+ Expect.throws(() {
+ x15 = confuse(f15);
+ });
List<T> Function(int y, [core.List<core.int> x]) Function() l15;
- Expect.throws(() { l15 = (f15 as dynamic); });
- Expect.throws(() { l15 = confuse(f15); });
+ Expect.throws(() {
+ l15 = (f15 as dynamic);
+ });
+ Expect.throws(() {
+ l15 = confuse(f15);
+ });
}
List<T> Function(int y, [core.List<core.int> x]) Function() l15 = m15;
// In checked mode, verifies the type.
@@ -698,7 +738,6 @@ class U4<T> {
l16 = m16;
x16 = confuse(m16);
l16 = confuse(m16);
-
}
/// Function({List<Function> x}) Function()
@@ -723,7 +762,6 @@ class U4<T> {
l17 = m17;
x17 = confuse(m17);
l17 = confuse(m17);
-
}
/// Function() Function()
@@ -748,7 +786,6 @@ class U4<T> {
l18 = m18;
x18 = confuse(m18);
l18 = confuse(m18);
-
}
/// void Function(int x0, [List<Function> x]) Function()
@@ -773,7 +810,6 @@ class U4<T> {
l19 = m19;
x19 = confuse(m19);
l19 = confuse(m19);
-
}
/// void Function([List<T> x1]) Function()
@@ -806,12 +842,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m20 is F20<bool>);
Expect.equals(tIsDynamic, confuse(m20) is F20<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x20 = (f20 as dynamic); });
- Expect.throws(() { x20 = confuse(f20); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x20 = (f20 as dynamic);
+ });
+ Expect.throws(() {
+ x20 = confuse(f20);
+ });
void Function([List<T> x1]) Function() l20;
- Expect.throws(() { l20 = (f20 as dynamic); });
- Expect.throws(() { l20 = confuse(f20); });
+ Expect.throws(() {
+ l20 = (f20 as dynamic);
+ });
+ Expect.throws(() {
+ l20 = confuse(f20);
+ });
}
void Function([List<T> x1]) Function() l20 = m20;
// In checked mode, verifies the type.
@@ -835,14 +879,14 @@ class U4<T> {
}
Expect.isTrue(m21 is F21);
- Expect.isTrue(m21 is List<Function> Function<A>(List<Function> x) Function());
+ Expect
+ .isTrue(m21 is List<Function> Function<A>(List<Function> x) Function());
Expect.isTrue(confuse(m21) is F21);
// In checked mode, verifies the type.
x21 = m21;
l21 = m21;
x21 = confuse(m21);
l21 = confuse(m21);
-
}
/// Function<A>(core.List<core.int> x) Function()
@@ -867,7 +911,6 @@ class U4<T> {
l22 = m22;
x22 = confuse(m22);
l22 = confuse(m22);
-
}
/// void Function<A>(List<T> x) Function()
@@ -900,12 +943,20 @@ class U4<T> {
Expect.equals(tIsDynamic, m23 is F23<bool>);
Expect.equals(tIsDynamic, confuse(m23) is F23<bool>);
} else {
- if (inCheckedMode) {
- Expect.throws(() { x23 = (f23 as dynamic); });
- Expect.throws(() { x23 = confuse(f23); });
+ if (typeAssertionsEnabled) {
+ Expect.throws(() {
+ x23 = (f23 as dynamic);
+ });
+ Expect.throws(() {
+ x23 = confuse(f23);
+ });
void Function<A>(List<T> x) Function() l23;
- Expect.throws(() { l23 = (f23 as dynamic); });
- Expect.throws(() { l23 = confuse(f23); });
+ Expect.throws(() {
+ l23 = (f23 as dynamic);
+ });
+ Expect.throws(() {
+ l23 = confuse(f23);
+ });
}
void Function<A>(List<T> x) Function() l23 = m23;
// In checked mode, verifies the type.
@@ -913,8 +964,6 @@ class U4<T> {
x23 = confuse(m23);
}
}
-
-
}
void main() {
@@ -922,4 +971,3 @@ void main() {
new U4<int>(tIsInt: true).runTests();
new U4<bool>(tIsBool: true).runTests();
}
-

Powered by Google App Engine
This is Rietveld 408576698