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

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

Issue 16256021: Remove trailing spaces in analyzer_experimental (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3
4 library engine.resolver_test; 3 library engine.resolver_test;
5
6 import 'dart:collection'; 4 import 'dart:collection';
7 import 'package:analyzer_experimental/src/generated/java_core.dart'; 5 import 'package:analyzer_experimental/src/generated/java_core.dart';
8 import 'package:analyzer_experimental/src/generated/java_engine.dart'; 6 import 'package:analyzer_experimental/src/generated/java_engine.dart';
9 import 'package:analyzer_experimental/src/generated/java_junit.dart'; 7 import 'package:analyzer_experimental/src/generated/java_junit.dart';
10 import 'package:analyzer_experimental/src/generated/source_io.dart'; 8 import 'package:analyzer_experimental/src/generated/source_io.dart';
11 import 'package:analyzer_experimental/src/generated/error.dart'; 9 import 'package:analyzer_experimental/src/generated/error.dart';
12 import 'package:analyzer_experimental/src/generated/scanner.dart'; 10 import 'package:analyzer_experimental/src/generated/scanner.dart';
13 import 'package:analyzer_experimental/src/generated/ast.dart' hide Annotation; 11 import 'package:analyzer_experimental/src/generated/ast.dart' hide Annotation;
14 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode; 12 import 'package:analyzer_experimental/src/generated/parser.dart' show ParserErro rCode;
15 import 'package:analyzer_experimental/src/generated/element.dart'; 13 import 'package:analyzer_experimental/src/generated/element.dart';
16 import 'package:analyzer_experimental/src/generated/resolver.dart'; 14 import 'package:analyzer_experimental/src/generated/resolver.dart';
17 import 'package:analyzer_experimental/src/generated/engine.dart'; 15 import 'package:analyzer_experimental/src/generated/engine.dart';
18 import 'package:analyzer_experimental/src/generated/java_engine_io.dart'; 16 import 'package:analyzer_experimental/src/generated/java_engine_io.dart';
19 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk; 17 import 'package:analyzer_experimental/src/generated/sdk.dart' show DartSdk;
20 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk; 18 import 'package:analyzer_experimental/src/generated/sdk_io.dart' show DirectoryB asedDartSdk;
21 import 'package:unittest/unittest.dart' as _ut; 19 import 'package:unittest/unittest.dart' as _ut;
22 import 'test_support.dart'; 20 import 'test_support.dart';
23 import 'ast_test.dart' show ASTFactory; 21 import 'ast_test.dart' show ASTFactory;
24 import 'element_test.dart' show ElementFactory; 22 import 'element_test.dart' show ElementFactory;
25
26 class TypePropagationTest extends ResolverTestCase { 23 class TypePropagationTest extends ResolverTestCase {
27 void test_as() { 24 void test_as() {
28 Source source = addSource(EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"])); 25 Source source = addSource(EngineTestCase.createSource(["class A {", " bool get g => true;", "}", "A f(var p) {", " if ((p as A).g) {", " return p;", " } else {", " return null;", " }", "}"]));
29 LibraryElement library = resolve(source); 26 LibraryElement library = resolve(source);
30 assertNoErrors(); 27 assertNoErrors();
31 verify([source]); 28 verify([source]);
32 CompilationUnit unit = resolveCompilationUnit(source, library); 29 CompilationUnit unit = resolveCompilationUnit(source, library);
33 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 30 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
34 InterfaceType typeA = classA.element.type; 31 InterfaceType typeA = classA.element.type;
35 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 32 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
(...skipping 4151 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 resolve(source); 4184 resolve(source);
4188 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]); 4185 assertErrors([CompileTimeErrorCode.CONST_FORMAL_PARAMETER]);
4189 verify([source]); 4186 verify([source]);
4190 } 4187 }
4191 void test_constInitializedWithNonConstValue() { 4188 void test_constInitializedWithNonConstValue() {
4192 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C = p;", "}"])); 4189 Source source = addSource(EngineTestCase.createSource(["f(p) {", " const C = p;", "}"]));
4193 resolve(source); 4190 resolve(source);
4194 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]); 4191 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
4195 verify([source]); 4192 verify([source]);
4196 } 4193 }
4194 void test_constInitializedWithNonConstValue_missingConstInListLiteral() {
4195 Source source = addSource("const List L = [0];");
4196 resolve(source);
4197 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
4198 verify([source]);
4199 }
4200 void test_constInitializedWithNonConstValue_missingConstInMapLiteral() {
4201 Source source = addSource("const Map M = {'a' : 0};");
4202 resolve(source);
4203 assertErrors([CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE ]);
4204 verify([source]);
4205 }
4197 void test_constWithInvalidTypeParameters() { 4206 void test_constWithInvalidTypeParameters() {
4198 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() { return const A<A>(); }"])); 4207 Source source = addSource(EngineTestCase.createSource(["class A {", " const A();", "}", "f() { return const A<A>(); }"]));
4199 resolve(source); 4208 resolve(source);
4200 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]); 4209 assertErrors([CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS]);
4201 verify([source]); 4210 verify([source]);
4202 } 4211 }
4203 void test_constWithNonConst() { 4212 void test_constWithNonConst() {
4204 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"])); 4213 Source source = addSource(EngineTestCase.createSource(["class T {", " T(a, b, {c, d}) {}", "}", "f() { return const T(0, 1, c: 2, d: 3); }"]));
4205 resolve(source); 4214 resolve(source);
4206 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]); 4215 assertErrors([CompileTimeErrorCode.CONST_WITH_NON_CONST]);
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
5560 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er); 5569 runJUnitTest(__test, __test.test_constFormalParameter_fieldFormalParamet er);
5561 }); 5570 });
5562 _ut.test('test_constFormalParameter_simpleFormalParameter', () { 5571 _ut.test('test_constFormalParameter_simpleFormalParameter', () {
5563 final __test = new CompileTimeErrorCodeTest(); 5572 final __test = new CompileTimeErrorCodeTest();
5564 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter); 5573 runJUnitTest(__test, __test.test_constFormalParameter_simpleFormalParame ter);
5565 }); 5574 });
5566 _ut.test('test_constInitializedWithNonConstValue', () { 5575 _ut.test('test_constInitializedWithNonConstValue', () {
5567 final __test = new CompileTimeErrorCodeTest(); 5576 final __test = new CompileTimeErrorCodeTest();
5568 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue); 5577 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue);
5569 }); 5578 });
5579 _ut.test('test_constInitializedWithNonConstValue_missingConstInListLiteral ', () {
5580 final __test = new CompileTimeErrorCodeTest();
5581 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInListLiteral);
5582 });
5583 _ut.test('test_constInitializedWithNonConstValue_missingConstInMapLiteral' , () {
5584 final __test = new CompileTimeErrorCodeTest();
5585 runJUnitTest(__test, __test.test_constInitializedWithNonConstValue_missi ngConstInMapLiteral);
5586 });
5570 _ut.test('test_constWithInvalidTypeParameters', () { 5587 _ut.test('test_constWithInvalidTypeParameters', () {
5571 final __test = new CompileTimeErrorCodeTest(); 5588 final __test = new CompileTimeErrorCodeTest();
5572 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters); 5589 runJUnitTest(__test, __test.test_constWithInvalidTypeParameters);
5573 }); 5590 });
5574 _ut.test('test_constWithNonConst', () { 5591 _ut.test('test_constWithNonConst', () {
5575 final __test = new CompileTimeErrorCodeTest(); 5592 final __test = new CompileTimeErrorCodeTest();
5576 runJUnitTest(__test, __test.test_constWithNonConst); 5593 runJUnitTest(__test, __test.test_constWithNonConst);
5577 }); 5594 });
5578 _ut.test('test_constWithNonConstantArgument', () { 5595 _ut.test('test_constWithNonConstantArgument', () {
5579 final __test = new CompileTimeErrorCodeTest(); 5596 final __test = new CompileTimeErrorCodeTest();
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
6343 final __test = new CompileTimeErrorCodeTest(); 6360 final __test = new CompileTimeErrorCodeTest();
6344 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew); 6361 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooFew);
6345 }); 6362 });
6346 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () { 6363 _ut.test('test_wrongNumberOfParametersForSetter_method_tooMany', () {
6347 final __test = new CompileTimeErrorCodeTest(); 6364 final __test = new CompileTimeErrorCodeTest();
6348 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany); 6365 runJUnitTest(__test, __test.test_wrongNumberOfParametersForSetter_method _tooMany);
6349 }); 6366 });
6350 }); 6367 });
6351 } 6368 }
6352 } 6369 }
6353
6354 /** 6370 /**
6355 * Instances of the class {@code StaticTypeVerifier} verify that all of the node s in an AST 6371 * Instances of the class {@code StaticTypeVerifier} verify that all of the node s in an AST
6356 * structure that should have a static type associated with them do have a stati c type. 6372 * structure that should have a static type associated with them do have a stati c type.
6357 */ 6373 */
6358 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> { 6374 class StaticTypeVerifier extends GeneralizingASTVisitor<Object> {
6359 6375
6360 /** 6376 /**
6361 * A list containing all of the AST Expression nodes that were not resolved. 6377 * A list containing all of the AST Expression nodes that were not resolved.
6362 */ 6378 */
6363 List<Expression> _unresolvedExpressions = new List<Expression>(); 6379 List<Expression> _unresolvedExpressions = new List<Expression>();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
6478 } else { 6494 } else {
6479 return "<unknown file- CompilationUnit.getElement() returned null>"; 6495 return "<unknown file- CompilationUnit.getElement() returned null>";
6480 } 6496 }
6481 } else { 6497 } else {
6482 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 6498 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
6483 } 6499 }
6484 } 6500 }
6485 return "<unknown file- ASTNode is null>"; 6501 return "<unknown file- ASTNode is null>";
6486 } 6502 }
6487 } 6503 }
6504 /**
6505 * The class {@code StrictModeTest} contains tests to ensure that the correct er rors and warnings
6506 * are reported when the analysis engine is run in strict mode.
6507 */
6508 class StrictModeTest extends ResolverTestCase {
6509 void fail_for() {
6510 Source source = addSource(EngineTestCase.createSource(["int f(List<int> list ) {", " num sum = 0;", " for (num i = 0; i < list.length; i++) {", " sum += list[i];", " }", "}"]));
6511 resolve(source);
6512 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6513 }
6514 void setUp() {
6515 super.setUp();
6516 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
6517 options.strictMode = true;
6518 analysisContext.analysisOptions = options;
6519 }
6520 void test_assert_is() {
6521 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " assert (n is int);", " return n & 0x0F;", "}"]));
6522 resolve(source);
6523 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6524 }
6525 void test_conditional_and_is() {
6526 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " return (n is int && n > 0) ? n & 0x0F : 0;", "}"]));
6527 resolve(source);
6528 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6529 }
6530 void test_conditional_is() {
6531 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " return (n is int) ? n & 0x0F : 0;", "}"]));
6532 resolve(source);
6533 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6534 }
6535 void test_conditional_isNot() {
6536 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " return (n is! int) ? 0 : n & 0x0F;", "}"]));
6537 resolve(source);
6538 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6539 }
6540 void test_conditional_or_is() {
6541 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " return (n is! int || n < 0) ? 0 : n & 0x0F;", "}"]));
6542 resolve(source);
6543 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6544 }
6545 void test_forEach() {
6546 Source source = addSource(EngineTestCase.createSource(["int f(List<int> list ) {", " num sum = 0;", " for (num n in list) {", " sum += n & 0x0F;", " }" , "}"]));
6547 resolve(source);
6548 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6549 }
6550 void test_if_and_is() {
6551 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " if (n is int && n > 0) {", " return n & 0x0F;", " }", " return 0;", "}"]));
6552 resolve(source);
6553 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6554 }
6555 void test_if_is() {
6556 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " if (n is int) {", " return n & 0x0F;", " }", " return 0;", "}"]));
6557 resolve(source);
6558 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6559 }
6560 void test_if_isNot() {
6561 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " if (n is! int) {", " return 0;", " } else {", " return n & 0x0F;", " }", "}"]));
6562 resolve(source);
6563 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6564 }
6565 void test_if_isNot_abrupt() {
6566 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " if (n is! int) {", " return 0;", " }", " return n & 0x0F;", "}"]));
6567 resolve(source);
6568 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6569 }
6570 void test_if_or_is() {
6571 Source source = addSource(EngineTestCase.createSource(["int f(num n) {", " if (n is! int || n < 0) {", " return 0;", " } else {", " return n & 0x0F; ", " }", "}"]));
6572 resolve(source);
6573 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6574 }
6575 void test_localVar() {
6576 Source source = addSource(EngineTestCase.createSource(["int f() {", " num n = 1234;", " return n & 0x0F;", "}"]));
6577 resolve(source);
6578 assertErrors([StaticTypeWarningCode.UNDEFINED_OPERATOR]);
6579 }
6580 static dartSuite() {
6581 _ut.group('StrictModeTest', () {
6582 _ut.test('test_assert_is', () {
6583 final __test = new StrictModeTest();
6584 runJUnitTest(__test, __test.test_assert_is);
6585 });
6586 _ut.test('test_conditional_and_is', () {
6587 final __test = new StrictModeTest();
6588 runJUnitTest(__test, __test.test_conditional_and_is);
6589 });
6590 _ut.test('test_conditional_is', () {
6591 final __test = new StrictModeTest();
6592 runJUnitTest(__test, __test.test_conditional_is);
6593 });
6594 _ut.test('test_conditional_isNot', () {
6595 final __test = new StrictModeTest();
6596 runJUnitTest(__test, __test.test_conditional_isNot);
6597 });
6598 _ut.test('test_conditional_or_is', () {
6599 final __test = new StrictModeTest();
6600 runJUnitTest(__test, __test.test_conditional_or_is);
6601 });
6602 _ut.test('test_forEach', () {
6603 final __test = new StrictModeTest();
6604 runJUnitTest(__test, __test.test_forEach);
6605 });
6606 _ut.test('test_if_and_is', () {
6607 final __test = new StrictModeTest();
6608 runJUnitTest(__test, __test.test_if_and_is);
6609 });
6610 _ut.test('test_if_is', () {
6611 final __test = new StrictModeTest();
6612 runJUnitTest(__test, __test.test_if_is);
6613 });
6614 _ut.test('test_if_isNot', () {
6615 final __test = new StrictModeTest();
6616 runJUnitTest(__test, __test.test_if_isNot);
6617 });
6618 _ut.test('test_if_isNot_abrupt', () {
6619 final __test = new StrictModeTest();
6620 runJUnitTest(__test, __test.test_if_isNot_abrupt);
6621 });
6622 _ut.test('test_if_or_is', () {
6623 final __test = new StrictModeTest();
6624 runJUnitTest(__test, __test.test_if_or_is);
6625 });
6626 _ut.test('test_localVar', () {
6627 final __test = new StrictModeTest();
6628 runJUnitTest(__test, __test.test_localVar);
6629 });
6630 });
6631 }
6632 }
6488 class ElementResolverTest extends EngineTestCase { 6633 class ElementResolverTest extends EngineTestCase {
6489 6634
6490 /** 6635 /**
6491 * The error listener to which errors will be reported. 6636 * The error listener to which errors will be reported.
6492 */ 6637 */
6493 GatheringErrorListener _listener; 6638 GatheringErrorListener _listener;
6494 6639
6495 /** 6640 /**
6496 * The type provider used to access the types. 6641 * The type provider used to access the types.
6497 */ 6642 */
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
7241 final __test = new TypeOverrideManagerTest(); 7386 final __test = new TypeOverrideManagerTest();
7242 runJUnitTest(__test, __test.test_getType_noOverride); 7387 runJUnitTest(__test, __test.test_getType_noOverride);
7243 }); 7388 });
7244 _ut.test('test_getType_noScope', () { 7389 _ut.test('test_getType_noScope', () {
7245 final __test = new TypeOverrideManagerTest(); 7390 final __test = new TypeOverrideManagerTest();
7246 runJUnitTest(__test, __test.test_getType_noScope); 7391 runJUnitTest(__test, __test.test_getType_noScope);
7247 }); 7392 });
7248 }); 7393 });
7249 } 7394 }
7250 } 7395 }
7396 class PubSuggestionCodeTest extends ResolverTestCase {
7397 void test_import_packageWithDotDot() {
7398 Source source = addSource(EngineTestCase.createSource(["import 'package:some package/../other.dart';"]));
7399 resolve(source);
7400 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST, PubSuggestionCode.PAC KAGE_IMPORT_CONTAINS_DOT_DOT]);
7401 }
7402 void test_import_referenceIntoLibDirectory() {
7403 Source source = addSource(EngineTestCase.createSource(["import '../lib/other .dart';"]));
7404 resolve(source);
7405 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST, PubSuggestionCode.FIL E_IMPORT_OUTSIDE_LIB_REFERENCES_FILE_INSIDE]);
7406 }
7407 void test_import_referenceOutOfLibDirectory() {
7408 Source source = addSource2("lib/test.dart", EngineTestCase.createSource(["im port '../web/other.dart';"]));
7409 resolve(source);
7410 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST, PubSuggestionCode.FIL E_IMPORT_INSIDE_LIB_REFERENCES_FILE_OUTSIDE]);
7411 }
7412 void test_import_valid() {
7413 Source source = addSource2("lib2/test.dart", EngineTestCase.createSource(["i mport '../web/other.dart';"]));
7414 resolve(source);
7415 assertErrors([CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
7416 }
7417 static dartSuite() {
7418 _ut.group('PubSuggestionCodeTest', () {
7419 _ut.test('test_import_packageWithDotDot', () {
7420 final __test = new PubSuggestionCodeTest();
7421 runJUnitTest(__test, __test.test_import_packageWithDotDot);
7422 });
7423 _ut.test('test_import_referenceIntoLibDirectory', () {
7424 final __test = new PubSuggestionCodeTest();
7425 runJUnitTest(__test, __test.test_import_referenceIntoLibDirectory);
7426 });
7427 _ut.test('test_import_referenceOutOfLibDirectory', () {
7428 final __test = new PubSuggestionCodeTest();
7429 runJUnitTest(__test, __test.test_import_referenceOutOfLibDirectory);
7430 });
7431 _ut.test('test_import_valid', () {
7432 final __test = new PubSuggestionCodeTest();
7433 runJUnitTest(__test, __test.test_import_valid);
7434 });
7435 });
7436 }
7437 }
7251 class StaticWarningCodeTest extends ResolverTestCase { 7438 class StaticWarningCodeTest extends ResolverTestCase {
7252 void fail_argumentTypeNotAssignable_invocation_functionParameter_generic() { 7439 void fail_argumentTypeNotAssignable_invocation_functionParameter_generic() {
7253 Source source = addSource(EngineTestCase.createSource(["class A<K, V> {", " m(f(K k), V v) {", " f(v);", " }", "}"])); 7440 Source source = addSource(EngineTestCase.createSource(["class A<K, V> {", " m(f(K k), V v) {", " f(v);", " }", "}"]));
7254 resolve(source); 7441 resolve(source);
7255 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]); 7442 assertErrors([StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE]);
7256 verify([source]); 7443 verify([source]);
7257 } 7444 }
7258 void fail_castToNonType() { 7445 void fail_castToNonType() {
7259 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri ng s) { var x = s as A; }"])); 7446 Source source = addSource(EngineTestCase.createSource(["var A = 0;", "f(Stri ng s) { var x = s as A; }"]));
7260 resolve(source); 7447 resolve(source);
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after
8459 final __test = new ErrorResolverTest(); 8646 final __test = new ErrorResolverTest();
8460 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember); 8647 runJUnitTest(__test, __test.test_breakLabelOnSwitchMember);
8461 }); 8648 });
8462 _ut.test('test_continueLabelOnSwitch', () { 8649 _ut.test('test_continueLabelOnSwitch', () {
8463 final __test = new ErrorResolverTest(); 8650 final __test = new ErrorResolverTest();
8464 runJUnitTest(__test, __test.test_continueLabelOnSwitch); 8651 runJUnitTest(__test, __test.test_continueLabelOnSwitch);
8465 }); 8652 });
8466 }); 8653 });
8467 } 8654 }
8468 } 8655 }
8469
8470 /** 8656 /**
8471 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by 8657 * Instances of the class {@code TestTypeProvider} implement a type provider tha t can be used by
8472 * tests without creating the element model for the core library. 8658 * tests without creating the element model for the core library.
8473 */ 8659 */
8474 class TestTypeProvider implements TypeProvider { 8660 class TestTypeProvider implements TypeProvider {
8475 8661
8476 /** 8662 /**
8477 * The type representing the built-in type 'bool'. 8663 * The type representing the built-in type 'bool'.
8478 */ 8664 */
8479 InterfaceType _boolType; 8665 InterfaceType _boolType;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
8602 return _iteratorType; 8788 return _iteratorType;
8603 } 8789 }
8604 InterfaceType get listType { 8790 InterfaceType get listType {
8605 if (_listType == null) { 8791 if (_listType == null) {
8606 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ; 8792 ClassElementImpl listElement = ElementFactory.classElement2("List", ["E"]) ;
8607 listElement.constructors = <ConstructorElement> [ElementFactory.constructo rElement(listElement, null)]; 8793 listElement.constructors = <ConstructorElement> [ElementFactory.constructo rElement(listElement, null)];
8608 _listType = listElement.type; 8794 _listType = listElement.type;
8609 Type2 eType = listElement.typeVariables[0].type; 8795 Type2 eType = listElement.typeVariables[0].type;
8610 InterfaceType supertype = iterableType.substitute5(<Type2> [eType]); 8796 InterfaceType supertype = iterableType.substitute5(<Type2> [eType]);
8611 listElement.supertype = supertype; 8797 listElement.supertype = supertype;
8612 listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [_intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [ _intType, eType])]; 8798 listElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEl ement("length", false, intType)];
8799 listElement.methods = <MethodElement> [ElementFactory.methodElement("[]", eType, [intType]), ElementFactory.methodElement("[]=", VoidTypeImpl.instance, [i ntType, eType])];
8613 } 8800 }
8614 return _listType; 8801 return _listType;
8615 } 8802 }
8616 InterfaceType get mapType { 8803 InterfaceType get mapType {
8617 if (_mapType == null) { 8804 if (_mapType == null) {
8618 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V "]); 8805 ClassElementImpl mapElement = ElementFactory.classElement2("Map", ["K", "V "]);
8619 _mapType = mapElement.type; 8806 _mapType = mapElement.type;
8620 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle ment("length", false, _intType)]; 8807 mapElement.accessors = <PropertyAccessorElement> [ElementFactory.getterEle ment("length", false, intType)];
8621 } 8808 }
8622 return _mapType; 8809 return _mapType;
8623 } 8810 }
8624 InterfaceType get numType { 8811 InterfaceType get numType {
8625 if (_numType == null) { 8812 if (_numType == null) {
8626 initializeNumericTypes(); 8813 initializeNumericTypes();
8627 } 8814 }
8628 return _numType; 8815 return _numType;
8629 } 8816 }
8630 InterfaceType get objectType { 8817 InterfaceType get objectType {
8631 if (_objectType == null) { 8818 if (_objectType == null) {
8632 ClassElementImpl objectElement = ElementFactory.object; 8819 ClassElementImpl objectElement = ElementFactory.object;
8633 _objectType = objectElement.type; 8820 _objectType = objectElement.type;
8634 if (objectElement.methods.length == 0) { 8821 if (objectElement.methods.length == 0) {
8635 objectElement.constructors = <ConstructorElement> [ElementFactory.constr uctorElement(objectElement, null)]; 8822 objectElement.constructors = <ConstructorElement> [ElementFactory.constr uctorElement(objectElement, null)];
8636 objectElement.methods = <MethodElement> [ElementFactory.methodElement("t oString", stringType, []), ElementFactory.methodElement("==", _boolType, [_objec tType]), ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType] )]; 8823 objectElement.methods = <MethodElement> [ElementFactory.methodElement("t oString", stringType, []), ElementFactory.methodElement("==", boolType, [_object Type]), ElementFactory.methodElement("noSuchMethod", dynamicType, [dynamicType]) ];
8637 objectElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("hashCode", false, intType), ElementFactory.getterElement("runtimeType ", false, typeType)]; 8824 objectElement.accessors = <PropertyAccessorElement> [ElementFactory.gett erElement("hashCode", false, intType), ElementFactory.getterElement("runtimeType ", false, typeType)];
8638 } 8825 }
8639 } 8826 }
8640 return _objectType; 8827 return _objectType;
8641 } 8828 }
8642 InterfaceType get stackTraceType { 8829 InterfaceType get stackTraceType {
8643 if (_stackTraceType == null) { 8830 if (_stackTraceType == null) {
8644 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type; 8831 _stackTraceType = ElementFactory.classElement2("StackTrace", []).type;
8645 } 8832 }
8646 return _stackTraceType; 8833 return _stackTraceType;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
8680 doubleElement.fields = fields; 8867 doubleElement.fields = fields;
8681 int fieldCount = fields.length; 8868 int fieldCount = fields.length;
8682 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount); 8869 List<PropertyAccessorElement> accessors = new List<PropertyAccessorElement>( fieldCount);
8683 for (int i = 0; i < fieldCount; i++) { 8870 for (int i = 0; i < fieldCount; i++) {
8684 accessors[i] = fields[i].getter; 8871 accessors[i] = fields[i].getter;
8685 } 8872 }
8686 doubleElement.accessors = accessors; 8873 doubleElement.accessors = accessors;
8687 doubleElement.methods = <MethodElement> [ElementFactory.methodElement("remai nder", _doubleType, [_numType]), ElementFactory.methodElement("+", _doubleType, [_numType]), ElementFactory.methodElement("-", _doubleType, [_numType]), Element Factory.methodElement("*", _doubleType, [_numType]), ElementFactory.methodElemen t("%", _doubleType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_numType]), ElementFactory.methodElement("~/", _doubleType, [_numType]), Elemen tFactory.methodElement("-", _doubleType, []), ElementFactory.methodElement("abs" , _doubleType, []), ElementFactory.methodElement("round", _doubleType, []), Elem entFactory.methodElement("floor", _doubleType, []), ElementFactory.methodElement ("ceil", _doubleType, []), ElementFactory.methodElement("truncate", _doubleType, []), ElementFactory.methodElement("toString", _stringType, [])]; 8874 doubleElement.methods = <MethodElement> [ElementFactory.methodElement("remai nder", _doubleType, [_numType]), ElementFactory.methodElement("+", _doubleType, [_numType]), ElementFactory.methodElement("-", _doubleType, [_numType]), Element Factory.methodElement("*", _doubleType, [_numType]), ElementFactory.methodElemen t("%", _doubleType, [_numType]), ElementFactory.methodElement("/", _doubleType, [_numType]), ElementFactory.methodElement("~/", _doubleType, [_numType]), Elemen tFactory.methodElement("-", _doubleType, []), ElementFactory.methodElement("abs" , _doubleType, []), ElementFactory.methodElement("round", _doubleType, []), Elem entFactory.methodElement("floor", _doubleType, []), ElementFactory.methodElement ("ceil", _doubleType, []), ElementFactory.methodElement("truncate", _doubleType, []), ElementFactory.methodElement("toString", _stringType, [])];
8688 } 8875 }
8689 } 8876 }
8690
8691 /** 8877 /**
8692 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts 8878 * The class {@code AnalysisContextFactory} defines utility methods used to crea te analysis contexts
8693 * for testing purposes. 8879 * for testing purposes.
8694 */ 8880 */
8695 class AnalysisContextFactory { 8881 class AnalysisContextFactory {
8696 8882
8697 /** 8883 /**
8698 * Create an analysis context that has a fake core library already resolved. 8884 * Create an analysis context that has a fake core library already resolved.
8699 * @return the analysis context that was created 8885 * @return the analysis context that was created
8700 */ 8886 */
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
8854 final __test = new LibraryImportScopeTest(); 9040 final __test = new LibraryImportScopeTest();
8855 runJUnitTest(__test, __test.test_getErrorListener); 9041 runJUnitTest(__test, __test.test_getErrorListener);
8856 }); 9042 });
8857 _ut.test('test_prefixedAndNonPrefixed', () { 9043 _ut.test('test_prefixedAndNonPrefixed', () {
8858 final __test = new LibraryImportScopeTest(); 9044 final __test = new LibraryImportScopeTest();
8859 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed); 9045 runJUnitTest(__test, __test.test_prefixedAndNonPrefixed);
8860 }); 9046 });
8861 }); 9047 });
8862 } 9048 }
8863 } 9049 }
8864
8865 /** 9050 /**
8866 * Instances of the class {@code ResolutionVerifier} verify that all of the node s in an AST 9051 * Instances of the class {@code ResolutionVerifier} verify that all of the node s in an AST
8867 * structure that should have been resolved were resolved. 9052 * structure that should have been resolved were resolved.
8868 */ 9053 */
8869 class ResolutionVerifier extends RecursiveASTVisitor<Object> { 9054 class ResolutionVerifier extends RecursiveASTVisitor<Object> {
8870 9055
8871 /** 9056 /**
8872 * A set containing nodes that are known to not be resolvable and should there fore not cause the 9057 * A set containing nodes that are known to not be resolvable and should there fore not cause the
8873 * test to fail. 9058 * test to fail.
8874 */ 9059 */
8875 Set<ASTNode> _knownExceptions; 9060 Set<ASTNode> _knownExceptions;
8876 9061
8877 /** 9062 /**
8878 * A list containing all of the AST nodes that were not resolved. 9063 * A list containing all of the AST nodes that were not resolved.
8879 */ 9064 */
8880 List<ASTNode> _unresolvedNodes = new List<ASTNode>(); 9065 List<ASTNode> _unresolvedNodes = new List<ASTNode>();
8881 9066
8882 /** 9067 /**
8883 * A list containing all of the AST nodes that were resolved to an element of the wrong type. 9068 * A list containing all of the AST nodes that were resolved to an element of the wrong type.
8884 */ 9069 */
8885 List<ASTNode> _wrongTypedNodes = new List<ASTNode>(); 9070 List<ASTNode> _wrongTypedNodes = new List<ASTNode>();
8886 9071
8887 /** 9072 /**
8888 * Initialize a newly created verifier to verify that all of the nodes in the visited AST 9073 * Initialize a newly created verifier to verify that all of the nodes in the visited AST
8889 * structures that are expected to have been resolved have an element associat ed with them. 9074 * structures that are expected to have been resolved have an element associat ed with them.
8890 */ 9075 */
8891 ResolutionVerifier() { 9076 ResolutionVerifier() {
8892 _jtd_constructor_359_impl(); 9077 _jtd_constructor_361_impl();
8893 } 9078 }
8894 _jtd_constructor_359_impl() { 9079 _jtd_constructor_361_impl() {
8895 _jtd_constructor_360_impl(null); 9080 _jtd_constructor_362_impl(null);
8896 } 9081 }
8897 9082
8898 /** 9083 /**
8899 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST 9084 * Initialize a newly created verifier to verify that all of the identifiers i n the visited AST
8900 * structures that are expected to have been resolved have an element associat ed with them. Nodes 9085 * structures that are expected to have been resolved have an element associat ed with them. Nodes
8901 * in the set of known exceptions are not expected to have been resolved, even if they normally 9086 * in the set of known exceptions are not expected to have been resolved, even if they normally
8902 * would have been expected to have been resolved. 9087 * would have been expected to have been resolved.
8903 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should 9088 * @param knownExceptions a set containing nodes that are known to not be reso lvable and should
8904 * therefore not cause the test to fail 9089 * therefore not cause the test to fail
8905 */ 9090 */
8906 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) { 9091 ResolutionVerifier.con1(Set<ASTNode> knownExceptions2) {
8907 _jtd_constructor_360_impl(knownExceptions2); 9092 _jtd_constructor_362_impl(knownExceptions2);
8908 } 9093 }
8909 _jtd_constructor_360_impl(Set<ASTNode> knownExceptions2) { 9094 _jtd_constructor_362_impl(Set<ASTNode> knownExceptions2) {
8910 this._knownExceptions = knownExceptions2; 9095 this._knownExceptions = knownExceptions2;
8911 } 9096 }
8912 9097
8913 /** 9098 /**
8914 * Assert that all of the visited identifiers were resolved. 9099 * Assert that all of the visited identifiers were resolved.
8915 */ 9100 */
8916 void assertResolved() { 9101 void assertResolved() {
8917 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) { 9102 if (!_unresolvedNodes.isEmpty || !_wrongTypedNodes.isEmpty) {
8918 PrintStringWriter writer = new PrintStringWriter(); 9103 PrintStringWriter writer = new PrintStringWriter();
8919 if (!_unresolvedNodes.isEmpty) { 9104 if (!_unresolvedNodes.isEmpty) {
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after
10399 final __test = new ScopeTest(); 10584 final __test = new ScopeTest();
10400 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate); 10585 runJUnitTest(__test, __test.test_isPrivateName_nonPrivate);
10401 }); 10586 });
10402 _ut.test('test_isPrivateName_private', () { 10587 _ut.test('test_isPrivateName_private', () {
10403 final __test = new ScopeTest(); 10588 final __test = new ScopeTest();
10404 runJUnitTest(__test, __test.test_isPrivateName_private); 10589 runJUnitTest(__test, __test.test_isPrivateName_private);
10405 }); 10590 });
10406 }); 10591 });
10407 } 10592 }
10408 } 10593 }
10409
10410 /** 10594 /**
10411 * A non-abstract subclass that can be used for testing purposes. 10595 * A non-abstract subclass that can be used for testing purposes.
10412 */ 10596 */
10413 class ScopeTest_TestScope extends Scope { 10597 class ScopeTest_TestScope extends Scope {
10414 10598
10415 /** 10599 /**
10416 * The element representing the library in which this scope is enclosed. 10600 * The element representing the library in which this scope is enclosed.
10417 */ 10601 */
10418 LibraryElement _definingLibrary; 10602 LibraryElement _definingLibrary;
10419 10603
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
10968 // TypeOverrideManagerTest.dartSuite(); 11152 // TypeOverrideManagerTest.dartSuite();
10969 // TypeProviderImplTest.dartSuite(); 11153 // TypeProviderImplTest.dartSuite();
10970 // TypeResolverVisitorTest.dartSuite(); 11154 // TypeResolverVisitorTest.dartSuite();
10971 // EnclosedScopeTest.dartSuite(); 11155 // EnclosedScopeTest.dartSuite();
10972 // LibraryImportScopeTest.dartSuite(); 11156 // LibraryImportScopeTest.dartSuite();
10973 // LibraryScopeTest.dartSuite(); 11157 // LibraryScopeTest.dartSuite();
10974 // ScopeTest.dartSuite(); 11158 // ScopeTest.dartSuite();
10975 // CompileTimeErrorCodeTest.dartSuite(); 11159 // CompileTimeErrorCodeTest.dartSuite();
10976 // ErrorResolverTest.dartSuite(); 11160 // ErrorResolverTest.dartSuite();
10977 // NonErrorResolverTest.dartSuite(); 11161 // NonErrorResolverTest.dartSuite();
11162 // PubSuggestionCodeTest.dartSuite();
10978 // SimpleResolverTest.dartSuite(); 11163 // SimpleResolverTest.dartSuite();
10979 // StaticTypeWarningCodeTest.dartSuite(); 11164 // StaticTypeWarningCodeTest.dartSuite();
10980 // StaticWarningCodeTest.dartSuite(); 11165 // StaticWarningCodeTest.dartSuite();
11166 // StrictModeTest.dartSuite();
10981 // TypePropagationTest.dartSuite(); 11167 // TypePropagationTest.dartSuite();
10982 } 11168 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/test/generated/parser_test.dart ('k') | pkg/analyzer_experimental/test/generated/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698