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

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

Issue 2290373003: Move error checking from scope creation to error reporter (take 2) (Closed)
Patch Set: Created 4 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 unified diff | Download patch
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 analyzer.test.generated.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 } 192 }
193 193
194 @reflectiveTest 194 @reflectiveTest
195 class EnclosedScopeTest extends ResolverTestCase { 195 class EnclosedScopeTest extends ResolverTestCase {
196 void test_define_duplicate() { 196 void test_define_duplicate() {
197 GatheringErrorListener listener = new GatheringErrorListener(); 197 GatheringErrorListener listener = new GatheringErrorListener();
198 Scope rootScope = 198 Scope rootScope =
199 new Scope_EnclosedScopeTest_test_define_duplicate(listener); 199 new Scope_EnclosedScopeTest_test_define_duplicate(listener);
200 EnclosedScope scope = new EnclosedScope(rootScope); 200 EnclosedScope scope = new EnclosedScope(rootScope);
201 VariableElement element1 = 201 SimpleIdentifier identifier = AstFactory.identifier3("v1");
202 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 202 VariableElement element1 = ElementFactory.localVariableElement(identifier);
203 VariableElement element2 = 203 VariableElement element2 = ElementFactory.localVariableElement(identifier);
204 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
205 scope.define(element1); 204 scope.define(element1);
206 scope.define(element2); 205 scope.define(element2);
207 listener.assertErrorsWithSeverities([ErrorSeverity.ERROR]); 206 expect(scope.lookup(identifier, null), element1);
208 } 207 }
209 208
210 void test_define_normal() { 209 void test_define_normal() {
211 GatheringErrorListener listener = new GatheringErrorListener(); 210 GatheringErrorListener listener = new GatheringErrorListener();
212 Scope rootScope = new Scope_EnclosedScopeTest_test_define_normal(listener); 211 Scope rootScope = new Scope_EnclosedScopeTest_test_define_normal(listener);
213 EnclosedScope outerScope = new EnclosedScope(rootScope); 212 EnclosedScope outerScope = new EnclosedScope(rootScope);
214 EnclosedScope innerScope = new EnclosedScope(outerScope); 213 EnclosedScope innerScope = new EnclosedScope(outerScope);
215 VariableElement element1 = 214 VariableElement element1 =
216 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 215 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
217 VariableElement element2 = 216 VariableElement element2 =
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 Element internalLookup(Identifier identifier, String name, 591 Element internalLookup(Identifier identifier, String name,
593 LibraryElement referencingLibrary) => 592 LibraryElement referencingLibrary) =>
594 null; 593 null;
595 } 594 }
596 595
597 @reflectiveTest 596 @reflectiveTest
598 class ScopeTest extends ResolverTestCase { 597 class ScopeTest extends ResolverTestCase {
599 void test_define_duplicate() { 598 void test_define_duplicate() {
600 GatheringErrorListener errorListener = new GatheringErrorListener(); 599 GatheringErrorListener errorListener = new GatheringErrorListener();
601 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); 600 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
602 VariableElement element1 = 601 SimpleIdentifier identifier = AstFactory.identifier3("v1");
603 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 602 VariableElement element1 = ElementFactory.localVariableElement(identifier);
604 VariableElement element2 = 603 VariableElement element2 = ElementFactory.localVariableElement(identifier);
605 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
606 scope.define(element1); 604 scope.define(element1);
607 scope.define(element2); 605 scope.define(element2);
608 errorListener.assertErrorsWithSeverities([ErrorSeverity.ERROR]); 606 expect(scope.lookup(identifier, null), element1);
609 } 607 }
610 608
611 void test_define_normal() { 609 void test_define_normal() {
612 GatheringErrorListener errorListener = new GatheringErrorListener(); 610 GatheringErrorListener errorListener = new GatheringErrorListener();
613 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); 611 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
614 VariableElement element1 = 612 VariableElement element1 =
615 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 613 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
616 VariableElement element2 = 614 VariableElement element2 =
617 ElementFactory.localVariableElement(AstFactory.identifier3("v2")); 615 ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
618 scope.define(element1); 616 scope.define(element1);
(...skipping 2913 matching lines...) Expand 10 before | Expand all | Expand 10 after
3532 */ 3530 */
3533 class _StaleElement extends ElementImpl { 3531 class _StaleElement extends ElementImpl {
3534 _StaleElement() : super("_StaleElement", -1); 3532 _StaleElement() : super("_StaleElement", -1);
3535 3533
3536 @override 3534 @override
3537 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3535 get kind => throw "_StaleElement's kind shouldn't be accessed";
3538 3536
3539 @override 3537 @override
3540 accept(_) => throw "_StaleElement shouldn't be visited"; 3538 accept(_) => throw "_StaleElement shouldn't be visited";
3541 } 3539 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/non_error_resolver_test.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698