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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 904743003: Fix analyzer type checking of "await" expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 9833 matching lines...) Expand 10 before | Expand all | Expand 10 after
9844 // i = 0 9844 // i = 0
9845 InterfaceType intType = _typeProvider.intType; 9845 InterfaceType intType = _typeProvider.intType;
9846 Expression node = AstFactory.assignmentExpression( 9846 Expression node = AstFactory.assignmentExpression(
9847 _resolvedVariable(intType, "i"), 9847 _resolvedVariable(intType, "i"),
9848 TokenType.EQ, 9848 TokenType.EQ,
9849 _resolvedInteger(0)); 9849 _resolvedInteger(0));
9850 expect(_analyze(node), same(intType)); 9850 expect(_analyze(node), same(intType));
9851 _listener.assertNoErrors(); 9851 _listener.assertNoErrors();
9852 } 9852 }
9853 9853
9854 void test_visitAwaitExpression_flattened() {
9855 // await e, where e has type Future<Future<int>>
9856 InterfaceType intType = _typeProvider.intType;
9857 InterfaceType futureIntType =
9858 _typeProvider.futureType.substitute4(<DartType>[intType]);
9859 InterfaceType futureFutureIntType =
9860 _typeProvider.futureType.substitute4(<DartType>[futureIntType]);
9861 Expression node =
9862 AstFactory.awaitExpression(_resolvedVariable(futureFutureIntType, 'e'));
9863 expect(_analyze(node), same(intType));
9864 _listener.assertNoErrors();
9865 }
9866
9867 void test_visitAwaitExpression_simple() {
9868 // await e, where e has type Future<int>
9869 InterfaceType intType = _typeProvider.intType;
9870 InterfaceType futureIntType =
9871 _typeProvider.futureType.substitute4(<DartType>[intType]);
9872 Expression node =
9873 AstFactory.awaitExpression(_resolvedVariable(futureIntType, 'e'));
9874 expect(_analyze(node), same(intType));
9875 _listener.assertNoErrors();
9876 }
9877
9854 void test_visitBinaryExpression_equals() { 9878 void test_visitBinaryExpression_equals() {
9855 // 2 == 3 9879 // 2 == 3
9856 Expression node = AstFactory.binaryExpression( 9880 Expression node = AstFactory.binaryExpression(
9857 _resolvedInteger(2), 9881 _resolvedInteger(2),
9858 TokenType.EQ_EQ, 9882 TokenType.EQ_EQ,
9859 _resolvedInteger(3)); 9883 _resolvedInteger(3));
9860 expect(_analyze(node), same(_typeProvider.boolType)); 9884 expect(_analyze(node), same(_typeProvider.boolType));
9861 _listener.assertNoErrors(); 9885 _listener.assertNoErrors();
9862 } 9886 }
9863 9887
(...skipping 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after
13704 // check propagated type 13728 // check propagated type
13705 FunctionType propagatedType = node.propagatedType as FunctionType; 13729 FunctionType propagatedType = node.propagatedType as FunctionType;
13706 expect(propagatedType.returnType, test.typeProvider.stringType); 13730 expect(propagatedType.returnType, test.typeProvider.stringType);
13707 } on AnalysisException catch (e, stackTrace) { 13731 } on AnalysisException catch (e, stackTrace) {
13708 thrownException[0] = new CaughtException(e, stackTrace); 13732 thrownException[0] = new CaughtException(e, stackTrace);
13709 } 13733 }
13710 } 13734 }
13711 return null; 13735 return null;
13712 } 13736 }
13713 } 13737 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698