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

Unified Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 1632113002: make checker_test, inferred_type_test easier to debug (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/checker_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/checker_test.dart b/pkg/analyzer/test/src/task/strong/checker_test.dart
index d8fb80c7ac9a4fadd0aab612139a1d907e50e774..5b8f6fc0efccc8aae71913da5bc485b648b67fcc 100644
--- a/pkg/analyzer/test/src/task/strong/checker_test.dart
+++ b/pkg/analyzer/test/src/task/strong/checker_test.dart
@@ -12,8 +12,10 @@ import 'package:unittest/unittest.dart';
import 'strong_test_helper.dart';
void main() {
- testChecker('ternary operator', {
- '/main.dart': '''
+ testChecker(
Paul Berry 2016/02/05 15:23:16 Nit: consider modifying testChecker so that it doe
+ 'ternary operator',
+ () => {
+ '/main.dart': '''
abstract class Comparable<T> {
int compareTo(T other);
static int compare(Comparable a, Comparable b) => a.compareTo(b);
@@ -54,10 +56,12 @@ void main() {
print((/*info:DYNAMIC_CAST*/dyn) ? false : true);
}
'''
- });
+ });
- testChecker('if/for/do/while statements use boolean conversion', {
- '/main.dart': '''
+ testChecker(
+ 'if/for/do/while statements use boolean conversion',
+ () => {
+ '/main.dart': '''
main() {
dynamic d = 42;
Object obj = 42;
@@ -85,10 +89,12 @@ void main() {
for (;/*severe:STATIC_TYPE_ERROR*/i;) {}
}
'''
- });
+ });
- testChecker('dynamic invocation', {
- '/main.dart': '''
+ testChecker(
+ 'dynamic invocation',
+ () => {
+ '/main.dart': '''
class A {
dynamic call(dynamic x) => x;
@@ -142,14 +148,16 @@ void main() {
}
}
'''
- });
+ });
- testChecker('conversion and dynamic invoke', {
- '/helper.dart': '''
+ testChecker(
+ 'conversion and dynamic invoke',
+ () => {
+ '/helper.dart': '''
dynamic toString = (int x) => x + 42;
dynamic hashCode = "hello";
''',
- '/main.dart': '''
+ '/main.dart': '''
import 'helper.dart' as helper;
class A {
@@ -222,10 +230,12 @@ void main() {
baz().hashCode;
}
'''
- });
+ });
- testChecker('Constructors', {
- '/main.dart': '''
+ testChecker(
+ 'Constructors',
+ () => {
+ '/main.dart': '''
const num z = 25;
Object obj = "world";
@@ -256,37 +266,45 @@ void main() {
var b = new B.c2(/*severe:STATIC_TYPE_ERROR*/"hello", /*info:DOWN_CAST_IMPLICIT*/obj);
}
'''
- });
+ });
- testChecker('Unbound variable', {
- '/main.dart': '''
+ testChecker(
+ 'Unbound variable',
+ () => {
+ '/main.dart': '''
void main() {
dynamic y = /*pass should be severe:STATIC_TYPE_ERROR*/unboundVariable;
}
'''
- });
+ });
- testChecker('Unbound type name', {
- '/main.dart': '''
+ testChecker(
+ 'Unbound type name',
+ () => {
+ '/main.dart': '''
void main() {
/*pass should be severe:STATIC_TYPE_ERROR*/AToB y;
}
'''
- });
+ });
// Regression test for https://github.com/dart-lang/sdk/issues/25069
- testChecker('Void subtyping', {
- '/main.dart': '''
+ testChecker(
+ 'Void subtyping',
+ () => {
+ '/main.dart': '''
typedef int Foo();
void foo() {}
void main () {
Foo x = /*severe:STATIC_TYPE_ERROR*/foo();
}
'''
- });
+ });
- testChecker('Ground type subtyping: dynamic is top', {
- '/main.dart': '''
+ testChecker(
+ 'Ground type subtyping: dynamic is top',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -307,10 +325,12 @@ void main() {
y = b;
}
'''
- });
+ });
- testChecker('Ground type subtyping: dynamic downcasts', {
- '/main.dart': '''
+ testChecker(
+ 'Ground type subtyping: dynamic downcasts',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -331,10 +351,12 @@ void main() {
b = /*info:DYNAMIC_CAST*/y;
}
'''
- });
+ });
- testChecker('Ground type subtyping: assigning a class', {
- '/main.dart': '''
+ testChecker(
+ 'Ground type subtyping: assigning a class',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -356,10 +378,12 @@ void main() {
b = /*info:DOWN_CAST_IMPLICIT*/a;
}
'''
- });
+ });
- testChecker('Ground type subtyping: assigning a subclass', {
- '/main.dart': '''
+ testChecker(
+ 'Ground type subtyping: assigning a subclass',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -384,10 +408,12 @@ void main() {
c = /*severe:STATIC_TYPE_ERROR*/b;
}
'''
- });
+ });
- testChecker('Ground type subtyping: interfaces', {
- '/main.dart': '''
+ testChecker(
+ 'Ground type subtyping: interfaces',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -425,10 +451,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: int and object', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: int and object',
+ () => {
+ '/main.dart': '''
typedef Object Top(int x); // Top of the lattice
typedef int Left(int x); // Left branch
@@ -477,10 +505,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: classes', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: classes',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -532,10 +562,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: dynamic', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: dynamic',
+ () => {
+ '/main.dart': '''
class A {}
@@ -580,10 +612,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: function literal variance', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: function literal variance',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -626,10 +660,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: function variable variance', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: function variable variance',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -665,10 +701,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: higher order function literals', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: higher order function literals',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -728,11 +766,12 @@ void main() {
}
}
'''
- });
+ });
testChecker(
- 'Function typing and subtyping: higher order function variables', {
- '/main.dart': '''
+ 'Function typing and subtyping: higher order function variables',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -770,10 +809,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: named and optional parameters', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: named and optional parameters',
+ () => {
+ '/main.dart': '''
class A {}
@@ -889,10 +930,12 @@ void main() {
nnn = nnn;
}
'''
- });
+ });
- testChecker('Function subtyping: objects with call methods', {
- '/main.dart': '''
+ testChecker(
+ 'Function subtyping: objects with call methods',
+ () => {
+ '/main.dart': '''
typedef int I2I(int x);
typedef num N2N(num x);
@@ -952,20 +995,24 @@ void main() {
}
}
'''
- });
+ });
- testChecker('Function typing and subtyping: void', {
- '/main.dart': '''
+ testChecker(
+ 'Function typing and subtyping: void',
+ () => {
+ '/main.dart': '''
class A {
void bar() => null;
void foo() => bar; // allowed
}
'''
- });
+ });
- testChecker('Relaxed casts', {
- '/main.dart': '''
+ testChecker(
+ 'Relaxed casts',
+ () => {
+ '/main.dart': '''
class A {}
@@ -1040,10 +1087,12 @@ void main() {
}
'''
- });
+ });
- testChecker('Type checking literals', {
- '/main.dart': '''
+ testChecker(
+ 'Type checking literals',
+ () => {
+ '/main.dart': '''
test() {
num n = 3;
int i = 3;
@@ -1083,10 +1132,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('casts in constant contexts', {
- '/main.dart': '''
+ testChecker(
+ 'casts in constant contexts',
+ () => {
+ '/main.dart': '''
class A {
static const num n = 3.0;
static const int i = /*info:ASSIGNMENT_CAST*/n;
@@ -1100,10 +1151,12 @@ void main() {
var a = const A(/*info:DOWN_CAST_IMPLICIT*/o);
}
'''
- });
+ });
- testChecker('casts in conditionals', {
- '/main.dart': '''
+ testChecker(
+ 'casts in conditionals',
+ () => {
+ '/main.dart': '''
main() {
bool b = true;
num x = b ? 1 : 2.3;
@@ -1112,37 +1165,45 @@ void main() {
z = b ? null : "hello";
}
'''
- });
+ });
// This is a regression test for https://github.com/dart-lang/sdk/issues/25071
- testChecker('unbound redirecting constructor', {
- '/main.dart': '''
+ testChecker(
+ 'unbound redirecting constructor',
+ () => {
+ '/main.dart': '''
class Foo {
Foo() : this.init();
}
'''
- });
+ });
- testChecker('redirecting constructor', {
- '/main.dart': '''
+ testChecker(
+ 'redirecting constructor',
+ () => {
+ '/main.dart': '''
class A {
A(A x) {}
A.two() : this(/*severe:STATIC_TYPE_ERROR*/3);
}
'''
- });
+ });
- testChecker('super constructor', {
- '/main.dart': '''
+ testChecker(
+ 'super constructor',
+ () => {
+ '/main.dart': '''
class A { A(A x) {} }
class B extends A {
B() : super(/*severe:STATIC_TYPE_ERROR*/3);
}
'''
- });
+ });
- testChecker('factory constructor downcast', {
- '/main.dart': r'''
+ testChecker(
+ 'factory constructor downcast',
+ () => {
+ '/main.dart': r'''
class Animal {
Animal();
factory Animal.cat() => return new Cat();
@@ -1154,10 +1215,12 @@ void main() {
Cat c = /*info:ASSIGNMENT_CAST*/new Animal.cat();
c = /*severe:STATIC_TYPE_ERROR*/new Animal();
}'''
- });
+ });
- testChecker('field/field override', {
- '/main.dart': '''
+ testChecker(
+ 'field/field override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
class C extends B {}
@@ -1183,10 +1246,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE,severe:INVALID_METHOD_OVERRIDE*/dynamic f4;
}
'''
- });
+ });
- testChecker('private override', {
- '/helper.dart': '''
+ testChecker(
+ 'private override',
+ () => {
+ '/helper.dart': '''
import 'main.dart' as main;
class Base {
@@ -1206,7 +1271,7 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/String _m1();
}
''',
- '/main.dart': '''
+ '/main.dart': '''
import 'helper.dart' as helper;
class Child extends helper.Base {
@@ -1217,10 +1282,12 @@ void main() {
String _m1();
}
'''
- });
+ });
- testChecker('getter/getter override', {
- '/main.dart': '''
+ testChecker(
+ 'getter/getter override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
class C extends B {}
@@ -1239,10 +1306,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/dynamic get f4 => null;
}
'''
- });
+ });
- testChecker('field/getter override', {
- '/main.dart': '''
+ testChecker(
+ 'field/getter override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
class C extends B {}
@@ -1268,10 +1337,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/dynamic get f4 => null;
}
'''
- });
+ });
- testChecker('setter/setter override', {
- '/main.dart': '''
+ testChecker(
+ 'setter/setter override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
class C extends B {}
@@ -1292,10 +1363,12 @@ void main() {
set f5(B value) {}
}
'''
- });
+ });
- testChecker('field/setter override', {
- '/main.dart': '''
+ testChecker(
+ 'field/setter override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
class C extends B {}
@@ -1336,10 +1409,12 @@ void main() {
set f5(B value) {}
}
'''
- });
+ });
- testChecker('method override', {
- '/main.dart': '''
+ testChecker(
+ 'method override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
class C extends B {}
@@ -1362,10 +1437,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/dynamic m6(dynamic value) {}
}
'''
- });
+ });
- testChecker('generic class method override', {
- '/main.dart': '''
+ testChecker(
+ 'generic class method override',
+ () => {
+ '/main.dart': '''
class A {}
class B extends A {}
@@ -1381,10 +1458,12 @@ void main() {
S foo() => null;
}
'''
- });
+ });
- testChecker('generic method override', {
- '/main.dart': '''
+ testChecker(
+ 'generic method override',
+ () => {
+ '/main.dart': '''
class Future<T> {
/*=S*/ then/*<S>*/(/*=S*/ onValue(T t)) => null;
}
@@ -1405,10 +1484,12 @@ void main() {
/*=B*/ then/*<B>*/(Object onValue(A a)) => null;
}
'''
- });
+ });
- testChecker('generic function wrong number of arguments', {
- '/main.dart': r'''
+ testChecker(
+ 'generic function wrong number of arguments',
+ () => {
+ '/main.dart': r'''
/*=T*/ foo/*<T>*/(/*=T*/ x, /*=T*/ y) => x;
/*=T*/ bar/*<T>*/({/*=T*/ x, /*=T*/ y}) => x;
@@ -1430,10 +1511,12 @@ void main() {
x = /*severe:STATIC_TYPE_ERROR*/bar(x: 1);
}
'''
- });
+ });
- testChecker('type promotion from dynamic', {
- '/main.dart': r'''
+ testChecker(
+ 'type promotion from dynamic',
+ () => {
+ '/main.dart': r'''
f() {
dynamic x;
if (x is int) {
@@ -1449,10 +1532,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('unary operators', {
- '/main.dart': '''
+ testChecker(
+ 'unary operators',
+ () => {
+ '/main.dart': '''
class A {
A operator ~() {}
A operator +(int x) {}
@@ -1485,10 +1570,12 @@ void main() {
(/*info:DYNAMIC_INVOKE*/d++);
(/*info:DYNAMIC_INVOKE*/d--);
}'''
- });
+ });
- testChecker('binary and index operators', {
- '/main.dart': '''
+ testChecker(
+ 'binary and index operators',
+ () => {
+ '/main.dart': '''
class A {
A operator *(B b) {}
A operator /(B b) {}
@@ -1550,10 +1637,12 @@ void main() {
a[/*severe:STATIC_TYPE_ERROR*/y];
}
'''
- });
+ });
- testChecker('null coalescing operator', {
- '/main.dart': '''
+ testChecker(
+ 'null coalescing operator',
+ () => {
+ '/main.dart': '''
class A {}
class C<T> {}
main() {
@@ -1567,10 +1656,12 @@ void main() {
d = d ?? /*info:INFERRED_TYPE_ALLOCATION*/new C();
}
'''
- });
+ });
- testChecker('compound assignments', {
- '/main.dart': '''
+ testChecker(
+ 'compound assignments',
+ () => {
+ '/main.dart': '''
class A {
A operator *(B b) {}
A operator /(B b) {}
@@ -1649,10 +1740,12 @@ void main() {
(/*info:DYNAMIC_INVOKE*/(/*info:DYNAMIC_INVOKE*/c[b]) += d);
}
'''
- });
+ });
- testChecker('super call placement', {
- '/main.dart': '''
+ testChecker(
+ 'super call placement',
+ () => {
+ '/main.dart': '''
class Base {
var x;
Base() : x = print('Base.1') { print('Base.2'); }
@@ -1684,10 +1777,12 @@ void main() {
main() => new Derived();
'''
- });
+ });
- testChecker('for loop variable', {
- '/main.dart': '''
+ testChecker(
+ 'for loop variable',
+ () => {
+ '/main.dart': '''
foo() {
for (int i = 0; i < 10; i++) {
i = /*severe:STATIC_TYPE_ERROR*/"hi";
@@ -1699,20 +1794,24 @@ void main() {
}
}
'''
- });
+ });
- testChecker('loadLibrary', {
- '/lib1.dart': '''library lib1;''',
- '/main.dart': r'''
+ testChecker(
+ 'loadLibrary',
+ () => {
+ '/lib1.dart': '''library lib1;''',
+ '/main.dart': r'''
import 'lib1.dart' deferred as lib1;
main() {
Future f = lib1.loadLibrary();
}'''
- });
+ });
group('invalid overrides', () {
- testChecker('child override', {
- '/main.dart': '''
+ testChecker(
+ 'child override',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1752,10 +1851,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE,severe:INVALID_METHOD_OVERRIDE*/B f;
}
'''
- });
+ });
- testChecker('child override 2', {
- '/main.dart': '''
+ testChecker(
+ 'child override 2',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1767,9 +1868,11 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
- testChecker('grandchild override', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'grandchild override',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1785,10 +1888,12 @@ void main() {
/*severe:INVALID_FIELD_OVERRIDE*/int x;
}
'''
- });
+ });
- testChecker('double override', {
- '/main.dart': '''
+ testChecker(
+ 'double override',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1804,10 +1909,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
+ });
- testChecker('double override 2', {
- '/main.dart': '''
+ testChecker(
+ 'double override 2',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1822,10 +1929,12 @@ void main() {
m(B a) {}
}
'''
- });
+ });
- testChecker('mixin override to base', {
- '/main.dart': '''
+ testChecker(
+ 'mixin override to base',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1846,10 +1955,12 @@ void main() {
class T2 extends Base with /*severe:INVALID_METHOD_OVERRIDE*/M1, /*severe:INVALID_FIELD_OVERRIDE*/M2 {}
class T3 extends Base with /*severe:INVALID_FIELD_OVERRIDE*/M2, /*severe:INVALID_METHOD_OVERRIDE*/M1 {}
'''
- });
+ });
- testChecker('mixin override to mixin', {
- '/main.dart': '''
+ testChecker(
+ 'mixin override to mixin',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1868,13 +1979,15 @@ void main() {
class T1 extends Base with M1, /*severe:INVALID_METHOD_OVERRIDE,severe:INVALID_FIELD_OVERRIDE*/M2 {}
'''
- });
+ });
// This is a regression test for a bug in an earlier implementation were
// names were hiding errors if the first mixin override looked correct,
// but subsequent ones did not.
- testChecker('no duplicate mixin override', {
- '/main.dart': '''
+ testChecker(
+ 'no duplicate mixin override',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1897,10 +2010,12 @@ void main() {
class T1 extends Base
with M1, /*severe:INVALID_METHOD_OVERRIDE*/M2, M3 {}
'''
- });
+ });
- testChecker('class override of interface', {
- '/main.dart': '''
+ testChecker(
+ 'class override of interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1912,10 +2027,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
+ });
- testChecker('base class override to child interface', {
- '/main.dart': '''
+ testChecker(
+ 'base class override to child interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1931,10 +2048,12 @@ void main() {
class T1 /*severe:INVALID_METHOD_OVERRIDE*/extends Base implements I {
}
'''
- });
+ });
- testChecker('mixin override of interface', {
- '/main.dart': '''
+ testChecker(
+ 'mixin override of interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1949,13 +2068,14 @@ void main() {
class T1 extends Object with /*severe:INVALID_METHOD_OVERRIDE*/M
implements I {}
'''
- });
+ });
// This is a case were it is incorrect to say that the base class
// incorrectly overrides the interface.
testChecker(
- 'no errors if subclass correctly overrides base and interface', {
- '/main.dart': '''
+ 'no errors if subclass correctly overrides base and interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1981,12 +2101,14 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE,severe:INVALID_METHOD_OVERRIDE*/m(a) {}
}
'''
- });
+ });
});
group('class override of grand interface', () {
- testChecker('interface of interface of child', {
- '/main.dart': '''
+ testChecker(
+ 'interface of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -1999,9 +2121,11 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
- testChecker('superclass of interface of child', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'superclass of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2014,9 +2138,11 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
- testChecker('mixin of interface of child', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'mixin of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2029,9 +2155,11 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
- testChecker('interface of abstract superclass', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'interface of abstract superclass',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2044,9 +2172,11 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
- testChecker('interface of concrete superclass', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'interface of concrete superclass',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2065,12 +2195,14 @@ void main() {
m(B a) {}
}
'''
- });
+ });
});
group('mixin override of grand interface', () {
- testChecker('interface of interface of child', {
- '/main.dart': '''
+ testChecker(
+ 'interface of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2087,9 +2219,11 @@ void main() {
implements I2 {
}
'''
- });
- testChecker('superclass of interface of child', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'superclass of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2106,9 +2240,11 @@ void main() {
implements I2 {
}
'''
- });
- testChecker('mixin of interface of child', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'mixin of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2125,9 +2261,11 @@ void main() {
implements I2 {
}
'''
- });
- testChecker('interface of abstract superclass', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'interface of abstract superclass',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2143,9 +2281,11 @@ void main() {
class T1 extends Base with /*severe:INVALID_METHOD_OVERRIDE*/M {
}
'''
- });
- testChecker('interface of concrete superclass', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'interface of concrete superclass',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2164,12 +2304,14 @@ void main() {
class T1 extends Base with M {
}
'''
- });
+ });
});
group('superclass override of grand interface', () {
- testChecker('interface of interface of child', {
- '/main.dart': '''
+ testChecker(
+ 'interface of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2186,9 +2328,11 @@ void main() {
implements I2 {
}
'''
- });
- testChecker('superclass of interface of child', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'superclass of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2205,9 +2349,11 @@ void main() {
implements I2 {
}
'''
- });
- testChecker('mixin of interface of child', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'mixin of interface of child',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2224,9 +2370,11 @@ void main() {
implements I2 {
}
'''
- });
- testChecker('interface of abstract superclass', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'interface of abstract superclass',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2247,9 +2395,11 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
- testChecker('interface of concrete superclass', {
- '/main.dart': '''
+ });
+ testChecker(
+ 'interface of concrete superclass',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2265,12 +2415,14 @@ void main() {
m(B a) {}
}
'''
- });
+ });
});
group('no duplicate reports from overriding interfaces', () {
- testChecker('type overrides same method in multiple interfaces', {
- '/main.dart': '''
+ testChecker(
+ 'type overrides same method in multiple interfaces',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2288,10 +2440,12 @@ void main() {
/*severe:INVALID_METHOD_OVERRIDE*/m(B a) {}
}
'''
- });
+ });
- testChecker('type and base type override same method in interface', {
- '/main.dart': '''
+ testChecker(
+ 'type and base type override same method in interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2315,10 +2469,12 @@ void main() {
implements I1 {
}
'''
- });
+ });
- testChecker('type and mixin override same method in interface', {
- '/main.dart': '''
+ testChecker(
+ 'type and mixin override same method in interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2338,10 +2494,12 @@ void main() {
implements I1 {
}
'''
- });
+ });
- testChecker('two grand types override same method in interface', {
- '/main.dart': '''
+ testChecker(
+ 'two grand types override same method in interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2367,10 +2525,12 @@ void main() {
implements I1 {
}
'''
- });
+ });
- testChecker('two mixins override same method in interface', {
- '/main.dart': '''
+ testChecker(
+ 'two mixins override same method in interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2395,10 +2555,12 @@ void main() {
implements I1 {
}
'''
- });
+ });
- testChecker('base type and mixin override same method in interface', {
- '/main.dart': '''
+ testChecker(
+ 'base type and mixin override same method in interface',
+ () => {
+ '/main.dart': '''
class A {}
class B {}
@@ -2422,11 +2584,13 @@ void main() {
implements I1 {
}
'''
- });
+ });
});
- testChecker('invalid runtime checks', {
- '/main.dart': '''
+ testChecker(
+ 'invalid runtime checks',
+ () => {
+ '/main.dart': '''
typedef int I2I(int x);
typedef int D2I(x);
typedef int II2I(int x, int y);
@@ -2477,11 +2641,13 @@ void main() {
f = bar as DD2D;
}
'''
- });
+ });
group('function modifiers', () {
- testChecker('async', {
- '/main.dart': '''
+ testChecker(
+ 'async',
+ () => {
+ '/main.dart': '''
import 'dart:async';
import 'dart:math' show Random;
@@ -2518,10 +2684,12 @@ void main() {
}
}
'''
- });
+ });
- testChecker('async*', {
- '/main.dart': '''
+ testChecker(
+ 'async*',
+ () => {
+ '/main.dart': '''
import 'dart:async';
dynamic x;
@@ -2537,10 +2705,12 @@ void main() {
Stream<int> baz4() async* { yield* new Stream<int>(); }
Stream<int> baz5() async* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/new Stream()); }
'''
- });
+ });
- testChecker('sync*', {
- '/main.dart': '''
+ testChecker(
+ 'sync*',
+ () => {
+ '/main.dart': '''
import 'dart:async';
dynamic x;
@@ -2556,6 +2726,6 @@ void main() {
Iterable<int> baz4() sync* { yield* new Iterable<int>(); }
Iterable<int> baz5() sync* { yield* (/*info:INFERRED_TYPE_ALLOCATION*/new Iterable()); }
'''
- });
+ });
});
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698