| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer.test.src.summary.summary_test; | 5 library analyzer.test.src.summary.summary_test; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 expect(referenceResolution.kind, expectedKind); | 575 expect(referenceResolution.kind, expectedKind); |
| 576 expect(referenceResolution.unit, expectedTargetUnit); | 576 expect(referenceResolution.unit, expectedTargetUnit); |
| 577 expect(referenceResolution.numTypeParameters, numTypeParameters); | 577 expect(referenceResolution.numTypeParameters, numTypeParameters); |
| 578 } | 578 } |
| 579 | 579 |
| 580 /** | 580 /** |
| 581 * Verify that the given [typeRef] represents a reference to an unresolved | 581 * Verify that the given [typeRef] represents a reference to an unresolved |
| 582 * type. | 582 * type. |
| 583 */ | 583 */ |
| 584 void checkUnresolvedTypeRef( | 584 void checkUnresolvedTypeRef( |
| 585 TypeRef typeRef, String expectedPrefix, String expectedName) { | 585 TypeRef typeRef, String expectedPrefix, String expectedName, |
| 586 {LinkedUnit linkedSourceUnit, UnlinkedUnit unlinkedSourceUnit}) { |
| 586 // When serializing from the element model, unresolved type refs lose their | 587 // When serializing from the element model, unresolved type refs lose their |
| 587 // name. | 588 // name. |
| 588 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, | 589 checkTypeRef(typeRef, null, null, checkAstDerivedData ? expectedName : null, |
| 589 expectedPrefix: expectedPrefix, expectedKind: ReferenceKind.unresolved); | 590 expectedPrefix: expectedPrefix, |
| 591 expectedKind: ReferenceKind.unresolved, |
| 592 linkedSourceUnit: linkedSourceUnit, |
| 593 unlinkedSourceUnit: unlinkedSourceUnit); |
| 590 } | 594 } |
| 591 | 595 |
| 592 fail_constExpr_pushInt_shiftOr() { | 596 fail_constExpr_pushInt_shiftOr() { |
| 593 UnlinkedVariable variable = | 597 UnlinkedVariable variable = |
| 594 serializeVariableText('const v = 0x111222333444555666;'); | 598 serializeVariableText('const v = 0x111222333444555666;'); |
| 595 // ^^!!!!^^^^!!!!^^^^ | 599 // ^^!!!!^^^^!!!!^^^^ |
| 596 _assertUnlinkedConst(variable.constExpr, operators: [ | 600 _assertUnlinkedConst(variable.constExpr, operators: [ |
| 597 UnlinkedConstOperation.pushInt, | 601 UnlinkedConstOperation.pushInt, |
| 598 UnlinkedConstOperation.shiftOr, | 602 UnlinkedConstOperation.shiftOr, |
| 599 UnlinkedConstOperation.shiftOr | 603 UnlinkedConstOperation.shiftOr |
| (...skipping 3302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3902 expect(type.typeParameters, isEmpty); | 3906 expect(type.typeParameters, isEmpty); |
| 3903 } | 3907 } |
| 3904 | 3908 |
| 3905 test_typedef_type_param_order() { | 3909 test_typedef_type_param_order() { |
| 3906 UnlinkedTypedef type = serializeTypedefText('typedef F<T, U>();'); | 3910 UnlinkedTypedef type = serializeTypedefText('typedef F<T, U>();'); |
| 3907 expect(type.typeParameters, hasLength(2)); | 3911 expect(type.typeParameters, hasLength(2)); |
| 3908 expect(type.typeParameters[0].name, 'T'); | 3912 expect(type.typeParameters[0].name, 'T'); |
| 3909 expect(type.typeParameters[1].name, 'U'); | 3913 expect(type.typeParameters[1].name, 'U'); |
| 3910 } | 3914 } |
| 3911 | 3915 |
| 3916 test_unresolved_reference_in_multiple_parts() { |
| 3917 addNamedSource('/a.dart', 'part of foo; int x; Unresolved y;'); |
| 3918 serializeLibraryText('library foo; part "a.dart"; Unresolved z;', |
| 3919 allowErrors: true); |
| 3920 // The unresolved types in the defining compilation unit and the part |
| 3921 // should both work correctly even though they use different reference |
| 3922 // indices. |
| 3923 checkUnresolvedTypeRef( |
| 3924 unlinkedUnits[0].variables[0].type, null, 'Unresolved'); |
| 3925 checkUnresolvedTypeRef( |
| 3926 unlinkedUnits[1].variables[1].type, null, 'Unresolved', |
| 3927 linkedSourceUnit: linked.units[1], |
| 3928 unlinkedSourceUnit: unlinkedUnits[1]); |
| 3929 } |
| 3930 |
| 3912 test_variable() { | 3931 test_variable() { |
| 3913 String text = 'int i;'; | 3932 String text = 'int i;'; |
| 3914 UnlinkedVariable v = serializeVariableText(text, variableName: 'i'); | 3933 UnlinkedVariable v = serializeVariableText(text, variableName: 'i'); |
| 3915 expect(v.nameOffset, text.indexOf('i;')); | 3934 expect(v.nameOffset, text.indexOf('i;')); |
| 3916 expect(findExecutable('i'), isNull); | 3935 expect(findExecutable('i'), isNull); |
| 3917 expect(findExecutable('i='), isNull); | 3936 expect(findExecutable('i='), isNull); |
| 3918 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); | 3937 expect(unlinkedUnits[0].publicNamespace.names, hasLength(2)); |
| 3919 expect(unlinkedUnits[0].publicNamespace.names[0].kind, | 3938 expect(unlinkedUnits[0].publicNamespace.names[0].kind, |
| 3920 ReferenceKind.topLevelPropertyAccessor); | 3939 ReferenceKind.topLevelPropertyAccessor); |
| 3921 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i'); | 3940 expect(unlinkedUnits[0].publicNamespace.names[0].name, 'i'); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4117 CompilationUnit _parseText(String text) { | 4136 CompilationUnit _parseText(String text) { |
| 4118 CharSequenceReader reader = new CharSequenceReader(text); | 4137 CharSequenceReader reader = new CharSequenceReader(text); |
| 4119 Scanner scanner = | 4138 Scanner scanner = |
| 4120 new Scanner(null, reader, AnalysisErrorListener.NULL_LISTENER); | 4139 new Scanner(null, reader, AnalysisErrorListener.NULL_LISTENER); |
| 4121 Token token = scanner.tokenize(); | 4140 Token token = scanner.tokenize(); |
| 4122 Parser parser = new Parser(null, AnalysisErrorListener.NULL_LISTENER); | 4141 Parser parser = new Parser(null, AnalysisErrorListener.NULL_LISTENER); |
| 4123 parser.parseGenericMethods = true; | 4142 parser.parseGenericMethods = true; |
| 4124 return parser.parseCompilationUnit(token); | 4143 return parser.parseCompilationUnit(token); |
| 4125 } | 4144 } |
| 4126 } | 4145 } |
| OLD | NEW |