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

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

Issue 2288983002: Move error checking from scope creation to error reporter (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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 192 }
193 } 193 }
194 194
195 @reflectiveTest 195 @reflectiveTest
196 class EnclosedScopeTest extends ResolverTestCase { 196 class EnclosedScopeTest extends ResolverTestCase {
197 void test_define_duplicate() { 197 void test_define_duplicate() {
198 GatheringErrorListener listener = new GatheringErrorListener(); 198 GatheringErrorListener listener = new GatheringErrorListener();
199 Scope rootScope = 199 Scope rootScope =
200 new Scope_EnclosedScopeTest_test_define_duplicate(listener); 200 new Scope_EnclosedScopeTest_test_define_duplicate(listener);
201 EnclosedScope scope = new EnclosedScope(rootScope); 201 EnclosedScope scope = new EnclosedScope(rootScope);
202 VariableElement element1 = 202 SimpleIdentifier identifier = AstFactory.identifier3("v1");
203 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 203 VariableElement element1 = ElementFactory.localVariableElement(identifier);
204 VariableElement element2 = 204 VariableElement element2 = ElementFactory.localVariableElement(identifier);
205 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
206 scope.define(element1); 205 scope.define(element1);
207 scope.define(element2); 206 scope.define(element2);
208 listener.assertErrorsWithSeverities([ErrorSeverity.ERROR]); 207 expect(scope.lookup(identifier, null), element1);
209 } 208 }
210 209
211 void test_define_normal() { 210 void test_define_normal() {
212 GatheringErrorListener listener = new GatheringErrorListener(); 211 GatheringErrorListener listener = new GatheringErrorListener();
213 Scope rootScope = new Scope_EnclosedScopeTest_test_define_normal(listener); 212 Scope rootScope = new Scope_EnclosedScopeTest_test_define_normal(listener);
214 EnclosedScope outerScope = new EnclosedScope(rootScope); 213 EnclosedScope outerScope = new EnclosedScope(rootScope);
215 EnclosedScope innerScope = new EnclosedScope(outerScope); 214 EnclosedScope innerScope = new EnclosedScope(outerScope);
216 VariableElement element1 = 215 VariableElement element1 =
217 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 216 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
218 VariableElement element2 = 217 VariableElement element2 =
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 Element internalLookup(Identifier identifier, String name, 592 Element internalLookup(Identifier identifier, String name,
594 LibraryElement referencingLibrary) => 593 LibraryElement referencingLibrary) =>
595 null; 594 null;
596 } 595 }
597 596
598 @reflectiveTest 597 @reflectiveTest
599 class ScopeTest extends ResolverTestCase { 598 class ScopeTest extends ResolverTestCase {
600 void test_define_duplicate() { 599 void test_define_duplicate() {
601 GatheringErrorListener errorListener = new GatheringErrorListener(); 600 GatheringErrorListener errorListener = new GatheringErrorListener();
602 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); 601 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
603 VariableElement element1 = 602 SimpleIdentifier identifier = AstFactory.identifier3("v1");
604 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 603 VariableElement element1 = ElementFactory.localVariableElement(identifier);
605 VariableElement element2 = 604 VariableElement element2 = ElementFactory.localVariableElement(identifier);
606 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
607 scope.define(element1); 605 scope.define(element1);
608 scope.define(element2); 606 scope.define(element2);
609 errorListener.assertErrorsWithSeverities([ErrorSeverity.ERROR]); 607 expect(scope.lookup(identifier, null), element1);
610 } 608 }
611 609
612 void test_define_normal() { 610 void test_define_normal() {
613 GatheringErrorListener errorListener = new GatheringErrorListener(); 611 GatheringErrorListener errorListener = new GatheringErrorListener();
614 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener); 612 ScopeTest_TestScope scope = new ScopeTest_TestScope(errorListener);
615 VariableElement element1 = 613 VariableElement element1 =
616 ElementFactory.localVariableElement(AstFactory.identifier3("v1")); 614 ElementFactory.localVariableElement(AstFactory.identifier3("v1"));
617 VariableElement element2 = 615 VariableElement element2 =
618 ElementFactory.localVariableElement(AstFactory.identifier3("v2")); 616 ElementFactory.localVariableElement(AstFactory.identifier3("v2"));
619 scope.define(element1); 617 scope.define(element1);
(...skipping 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after
3636 */ 3634 */
3637 class _StaleElement extends ElementImpl { 3635 class _StaleElement extends ElementImpl {
3638 _StaleElement() : super("_StaleElement", -1); 3636 _StaleElement() : super("_StaleElement", -1);
3639 3637
3640 @override 3638 @override
3641 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3639 get kind => throw "_StaleElement's kind shouldn't be accessed";
3642 3640
3643 @override 3641 @override
3644 accept(_) => throw "_StaleElement shouldn't be visited"; 3642 accept(_) => throw "_StaleElement shouldn't be visited";
3645 } 3643 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698