Index: tests/compiler/dart2js/type_variable_bound_test.dart |
diff --git a/tests/compiler/dart2js/type_variable_bound_test.dart b/tests/compiler/dart2js/type_variable_bound_test.dart |
index d8a6903a20c83fa8a1add9b2718062f54ea141ef..544d664a04668f7f23d26d3569cbc1115fd3fcf9 100644 |
--- a/tests/compiler/dart2js/type_variable_bound_test.dart |
+++ b/tests/compiler/dart2js/type_variable_bound_test.dart |
@@ -17,141 +17,136 @@ Future compile(String source) { |
}); |
} |
-test(String source, {var errors, var warnings}) { |
+Future test(String source, {var errors, var warnings}) async{ |
if (errors == null) errors = []; |
if (errors is! List) errors = [errors]; |
if (warnings == null) warnings = []; |
if (warnings is! List) warnings = [warnings]; |
- asyncTest(() => compile(source).then((compiler) { |
- DiagnosticCollector collector = compiler.diagnosticCollector; |
- Expect.equals(!errors.isEmpty, compiler.compilationFailed); |
- Expect.equals(errors.length, collector.errors.length, |
- 'unexpected error count: ${collector.errors.length} ' |
- 'expected ${errors.length}'); |
- Expect.equals(warnings.length, collector.warnings.length, |
- 'unexpected warning count: ${collector.warnings.length} ' |
- 'expected ${warnings.length}'); |
- |
- for (int i = 0 ; i < errors.length ; i++) { |
- Expect.equals(errors[i], collector.errors.elementAt(i).message.kind); |
- } |
- for (int i = 0 ; i < warnings.length ; i++) { |
- Expect.equals(warnings[i], collector.warnings.elementAt(i).message.kind); |
- } |
- })); |
+ var compiler = await compile(source); |
+ DiagnosticCollector collector = compiler.diagnosticCollector; |
+ Expect.equals(!errors.isEmpty, compiler.compilationFailed); |
+ Expect.equals(errors.length, collector.errors.length, |
+ 'unexpected error count: ${collector.errors.length} ' |
+ 'expected ${errors.length}'); |
+ Expect.equals(warnings.length, collector.warnings.length, |
+ 'unexpected warning count: ${collector.warnings.length} ' |
+ 'expected ${warnings.length}'); |
+ |
+ for (int i = 0 ; i < errors.length ; i++) { |
+ Expect.equals(errors[i], collector.errors.elementAt(i).message.kind); |
+ } |
+ for (int i = 0 ; i < warnings.length ; i++) { |
+ Expect.equals(warnings[i], collector.warnings.elementAt(i).message.kind); |
+ } |
} |
-test1() { |
- asyncTest(() => compile(r""" |
+Future test1() async { |
+ var compiler = await compile(r""" |
class A<T extends T> {} |
void main() { |
new A(); |
} |
-""").then((compiler) { |
- DiagnosticCollector collector = compiler.diagnosticCollector; |
- Expect.isFalse(compiler.compilationFailed); |
- Expect.isTrue(collector.errors.isEmpty, |
- 'unexpected errors: ${collector.errors}'); |
- Expect.equals(1, collector.warnings.length, |
- 'expected exactly one warning, but got ${collector.warnings}'); |
- |
- print(collector.warnings.elementAt(0)); |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(0).message.kind); |
- Expect.equals("T", |
- collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
- })); |
+"""); |
+ DiagnosticCollector collector = compiler.diagnosticCollector; |
+ Expect.isFalse(compiler.compilationFailed); |
+ Expect.isTrue(collector.errors.isEmpty, |
+ 'unexpected errors: ${collector.errors}'); |
+ Expect.equals(1, collector.warnings.length, |
+ 'expected exactly one warning, but got ${collector.warnings}'); |
+ |
+ print(collector.warnings.elementAt(0)); |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(0).message.kind); |
+ Expect.equals("T", |
+ collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
} |
-test2() { |
- asyncTest(() => compile(r""" |
+Future test2() async { |
+ var compiler = await compile(r""" |
class B<T extends S, S extends T> {} |
void main() { |
new B(); |
} |
-""").then((compiler) { |
- DiagnosticCollector collector = compiler.diagnosticCollector; |
- Expect.isFalse(compiler.compilationFailed); |
- print(collector.errors); |
- Expect.isTrue(collector.errors.isEmpty, 'unexpected errors'); |
- Expect.equals(2, collector.warnings.length, |
- 'expected exactly two errors, but got ${collector.warnings}'); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(0).message.kind); |
- Expect.equals("T", |
- collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(1).message.kind); |
- Expect.equals("S", |
- collector.warnings.elementAt(1).message.arguments['typeVariableName']); |
- })); |
+"""); |
+ DiagnosticCollector collector = compiler.diagnosticCollector; |
+ Expect.isFalse(compiler.compilationFailed); |
+ print(collector.errors); |
+ Expect.isTrue(collector.errors.isEmpty, 'unexpected errors'); |
+ Expect.equals(2, collector.warnings.length, |
+ 'expected exactly two errors, but got ${collector.warnings}'); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(0).message.kind); |
+ Expect.equals("T", |
+ collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(1).message.kind); |
+ Expect.equals("S", |
+ collector.warnings.elementAt(1).message.arguments['typeVariableName']); |
} |
-test3() { |
- asyncTest(() => compile(r""" |
+Future test3() async { |
+ var compiler = await compile(r""" |
class C<T extends S, S extends U, U extends T> {} |
void main() { |
new C(); |
} |
-""").then((compiler) { |
- DiagnosticCollector collector = compiler.diagnosticCollector; |
- Expect.isFalse(compiler.compilationFailed); |
- print(collector.errors); |
- Expect.isTrue(collector.errors.isEmpty, 'unexpected errors'); |
- Expect.equals(3, collector.warnings.length, |
- 'expected exactly one error, but got ${collector.warnings}'); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(0).message.kind); |
- Expect.equals("T", |
- collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(1).message.kind); |
- Expect.equals("S", |
- collector.warnings.elementAt(1).message.arguments['typeVariableName']); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(2).message.kind); |
- Expect.equals("U", |
- collector.warnings.elementAt(2).message.arguments['typeVariableName']); |
- })); |
+"""); |
+ DiagnosticCollector collector = compiler.diagnosticCollector; |
+ Expect.isFalse(compiler.compilationFailed); |
+ print(collector.errors); |
+ Expect.isTrue(collector.errors.isEmpty, 'unexpected errors'); |
+ Expect.equals(3, collector.warnings.length, |
+ 'expected exactly one error, but got ${collector.warnings}'); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(0).message.kind); |
+ Expect.equals("T", |
+ collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(1).message.kind); |
+ Expect.equals("S", |
+ collector.warnings.elementAt(1).message.arguments['typeVariableName']); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(2).message.kind); |
+ Expect.equals("U", |
+ collector.warnings.elementAt(2).message.arguments['typeVariableName']); |
} |
-test4() { |
- asyncTest(() => compile(r""" |
+Future test4() async { |
+ var compiler = await compile(r""" |
class D<T extends S, S extends U, U extends S> {} |
void main() { |
new D(); |
} |
-""").then((compiler) { |
- DiagnosticCollector collector = compiler.diagnosticCollector; |
- Expect.isFalse(compiler.compilationFailed); |
- print(collector.errors); |
- Expect.isTrue(collector.errors.isEmpty, 'unexpected errors'); |
- Expect.equals(2, collector.warnings.length, |
- 'expected exactly one error, but got ${collector.warnings}'); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(0).message.kind); |
- Expect.equals("S", |
- collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
- |
- Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
- collector.warnings.elementAt(1).message.kind); |
- Expect.equals("U", |
- collector.warnings.elementAt(1).message.arguments['typeVariableName']); |
- })); |
+"""); |
+ DiagnosticCollector collector = compiler.diagnosticCollector; |
+ Expect.isFalse(compiler.compilationFailed); |
+ print(collector.errors); |
+ Expect.isTrue(collector.errors.isEmpty, 'unexpected errors'); |
+ Expect.equals(2, collector.warnings.length, |
+ 'expected exactly one error, but got ${collector.warnings}'); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(0).message.kind); |
+ Expect.equals("S", |
+ collector.warnings.elementAt(0).message.arguments['typeVariableName']); |
+ |
+ Expect.equals(MessageKind.CYCLIC_TYPE_VARIABLE, |
+ collector.warnings.elementAt(1).message.kind); |
+ Expect.equals("U", |
+ collector.warnings.elementAt(1).message.arguments['typeVariableName']); |
} |
-test5() { |
- test(r""" |
+Future test5() { |
+ return test(r""" |
class A<T extends num> {} |
void main() { |
@@ -164,8 +159,8 @@ void main() { |
"""); |
} |
-test6() { |
- test(r""" |
+Future test6() { |
+ return test(r""" |
class A<T extends num> {} |
void main() { |
@@ -174,8 +169,8 @@ void main() { |
""", warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND); |
} |
-test7() { |
- test(r""" |
+Future test7() { |
+ return test(r""" |
class A<T extends num> {} |
class B<T> extends A<T> {} // Warning produced here. |
@@ -186,8 +181,8 @@ void main() { |
""", warnings: MessageKind.INVALID_TYPE_VARIABLE_BOUND); |
} |
-test8() { |
- test(r""" |
+Future test8() { |
+ return test(r""" |
class B<T extends B<T>> {} |
class C<T extends B<T>> extends B<T> {} |
class D<T extends C<T>> extends C<T> {} |
@@ -213,8 +208,8 @@ void main() { |
"""); |
} |
-test9() { |
- test(r""" |
+Future test9() { |
+ return test(r""" |
class B<T extends B<T>> {} |
class C<T extends B<T>> extends B<T> {} |
class D<T extends C<T>> extends C<T> {} |
@@ -229,8 +224,8 @@ void main() { |
MessageKind.INVALID_TYPE_VARIABLE_BOUND]); |
} |
-test10() { |
- test(r""" |
+Future test10() { |
+ return test(r""" |
class A { |
const A(); |
} |
@@ -246,8 +241,8 @@ main() { |
// TODO(het): The error is reported twice because both the Dart and JS constant |
// compilers are run on the const constructor, investigate why. |
-test11() { |
- test(r""" |
+Future test11() { |
+ return test(r""" |
class A { |
const A(); |
} |
@@ -265,15 +260,17 @@ main() { |
} |
main() { |
- test1(); |
- test2(); |
- test3(); |
- test4(); |
- test5(); |
- test6(); |
- test7(); |
- test8(); |
- test9(); |
- test10(); |
- test11(); |
+ asyncTest(() async { |
+ await test1(); |
+ await test2(); |
+ await test3(); |
+ await test4(); |
+ await test5(); |
+ await test6(); |
+ await test7(); |
+ await test8(); |
+ await test9(); |
+ await test10(); |
+ await test11(); |
+ }); |
} |