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

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1327363002: Fixed the last unit test that was failing with the new task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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: pkg/analyzer/test/src/task/dart_test.dart
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index f14bbfb2e8b44cf6d9d9a24231233695014c33a5..514f126861d15f9497d65067f8e858642d1fb8cc 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -1911,25 +1911,19 @@ class Z {}
@reflectiveTest
class InferStaticVariableTypesInUnitTaskTest extends _AbstractDartTaskTest {
- void fail_perform_nestedDeclarations() {
+ void test_perform_nestedDeclarations() {
enableStrongMode();
AnalysisTarget source = newSource(
'/test.dart',
'''
-var Y = (int x, int y) {
+var f = (int x) {
int squared(int value) => value * value;
var xSquared = squared(x);
- var ySquared = squared(y);
- return Math.sqrt(xSquared + ySquared);
+ return xSquared;
};
''');
computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT6,
matcher: isInferStaticVariableTypesInUnitTask);
- CompilationUnit unit = outputs[RESOLVED_UNIT6];
- VariableDeclaration variableY = getTopLevelVariable(unit, 'Y');
-
- InterfaceType intType = context.typeProvider.intType;
- expect(variableY.initializer.staticType, intType);
}
void test_perform_recursive() {
@@ -1970,6 +1964,30 @@ class M {}
expect(variableC.element.type, typeM);
expect(variableC.initializer.staticType, typeM);
}
+
+ void test_perform_simple() {
+ enableStrongMode();
+ AnalysisTarget source = newSource(
+ '/test.dart',
+ '''
+var X = 1;
+
+var Y = () {
+ return 1 + X;
+};
+''');
+ computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT6,
+ matcher: isInferStaticVariableTypesInUnitTask);
+ CompilationUnit unit = outputs[RESOLVED_UNIT6];
+ TopLevelVariableDeclaration declaration = unit.declarations[1];
+ FunctionExpression function =
+ declaration.variables.variables[0].initializer;
+ BlockFunctionBody body = function.body;
+ ReturnStatement statement = body.block.statements[0];
+ Expression expression = statement.expression;
+ InterfaceType intType = context.typeProvider.intType;
+ expect(expression.staticType, intType);
+ }
}
@reflectiveTest
« pkg/analyzer/lib/src/task/driver.dart ('K') | « pkg/analyzer/lib/src/task/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698