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

Side by Side Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverCompilerTest.java

Issue 10548002: Fix for issue 2351 - checking assignability on top level getters and setters (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Attempting to reapply patch with setElement() calls. Created 8 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.resolver; 4 package com.google.dart.compiler.resolver;
5 5
6 import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
7 import static com.google.dart.compiler.common.ErrorExpectation.errEx;
8
9 import com.google.common.base.Joiner; 6 import com.google.common.base.Joiner;
10 import com.google.common.collect.Lists; 7 import com.google.common.collect.Lists;
11 import com.google.common.io.CharStreams; 8 import com.google.common.io.CharStreams;
12 import com.google.dart.compiler.CompilerTestCase; 9 import com.google.dart.compiler.CompilerTestCase;
13 import com.google.dart.compiler.DartCompilationError; 10 import com.google.dart.compiler.DartCompilationError;
14 import com.google.dart.compiler.Source; 11 import com.google.dart.compiler.Source;
15 import com.google.dart.compiler.ast.ASTVisitor; 12 import com.google.dart.compiler.ast.ASTVisitor;
16 import com.google.dart.compiler.ast.DartClass; 13 import com.google.dart.compiler.ast.DartClass;
17 import com.google.dart.compiler.ast.DartDeclaration; 14 import com.google.dart.compiler.ast.DartDeclaration;
18 import com.google.dart.compiler.ast.DartExprStmt; 15 import com.google.dart.compiler.ast.DartExprStmt;
19 import com.google.dart.compiler.ast.DartExpression; 16 import com.google.dart.compiler.ast.DartExpression;
17 import com.google.dart.compiler.ast.DartField;
20 import com.google.dart.compiler.ast.DartFieldDefinition; 18 import com.google.dart.compiler.ast.DartFieldDefinition;
21 import com.google.dart.compiler.ast.DartFunctionExpression; 19 import com.google.dart.compiler.ast.DartFunctionExpression;
22 import com.google.dart.compiler.ast.DartFunctionTypeAlias; 20 import com.google.dart.compiler.ast.DartFunctionTypeAlias;
23 import com.google.dart.compiler.ast.DartIdentifier; 21 import com.google.dart.compiler.ast.DartIdentifier;
24 import com.google.dart.compiler.ast.DartLabel; 22 import com.google.dart.compiler.ast.DartLabel;
25 import com.google.dart.compiler.ast.DartMethodDefinition; 23 import com.google.dart.compiler.ast.DartMethodDefinition;
26 import com.google.dart.compiler.ast.DartNewExpression; 24 import com.google.dart.compiler.ast.DartNewExpression;
27 import com.google.dart.compiler.ast.DartNode; 25 import com.google.dart.compiler.ast.DartNode;
28 import com.google.dart.compiler.ast.DartParameter; 26 import com.google.dart.compiler.ast.DartParameter;
29 import com.google.dart.compiler.ast.DartStatement; 27 import com.google.dart.compiler.ast.DartStatement;
30 import com.google.dart.compiler.ast.DartTypeNode; 28 import com.google.dart.compiler.ast.DartTypeNode;
31 import com.google.dart.compiler.ast.DartTypeParameter; 29 import com.google.dart.compiler.ast.DartTypeParameter;
32 import com.google.dart.compiler.ast.DartUnit; 30 import com.google.dart.compiler.ast.DartUnit;
33 import com.google.dart.compiler.ast.DartVariableStatement; 31 import com.google.dart.compiler.ast.DartVariableStatement;
34 import com.google.dart.compiler.common.SourceInfo; 32 import com.google.dart.compiler.common.SourceInfo;
35 import com.google.dart.compiler.type.FunctionAliasType; 33 import com.google.dart.compiler.type.FunctionAliasType;
36 import com.google.dart.compiler.type.Type; 34 import com.google.dart.compiler.type.Type;
37 import com.google.dart.compiler.type.TypeVariable; 35 import com.google.dart.compiler.type.TypeVariable;
38 36
37 import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
38 import static com.google.dart.compiler.common.ErrorExpectation.errEx;
39
39 import java.io.Reader; 40 import java.io.Reader;
40 import java.util.LinkedList; 41 import java.util.LinkedList;
41 import java.util.List; 42 import java.util.List;
42 43
43 /** 44 /**
44 * Variant of {@link ResolverTest}, which is based on {@link CompilerTestCase}. It is probably 45 * Variant of {@link ResolverTest}, which is based on {@link CompilerTestCase}. It is probably
45 * slower, not actually unit test, but easier to use if you need access to DartN ode's. 46 * slower, not actually unit test, but easier to use if you need access to DartN ode's.
46 */ 47 */
47 public class ResolverCompilerTest extends CompilerTestCase { 48 public class ResolverCompilerTest extends CompilerTestCase {
48 49
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 { 805 {
805 DartTypeParameter typeParameter = classA.getTypeParameters().get(0); 806 DartTypeParameter typeParameter = classA.getTypeParameters().get(0);
806 assertDeclarationNameElement(typeParameter, "B"); 807 assertDeclarationNameElement(typeParameter, "B");
807 } 808 }
808 { 809 {
809 DartFieldDefinition fieldDef = (DartFieldDefinition) classA.getMembers() .get(0); 810 DartFieldDefinition fieldDef = (DartFieldDefinition) classA.getMembers() .get(0);
810 assertDeclarationNameElement(fieldDef.getFields().get(0), "a1"); 811 assertDeclarationNameElement(fieldDef.getFields().get(0), "a1");
811 } 812 }
812 { 813 {
813 DartFieldDefinition fieldDef = (DartFieldDefinition) classA.getMembers() .get(1); 814 DartFieldDefinition fieldDef = (DartFieldDefinition) classA.getMembers() .get(1);
814 assertDeclarationNameElement(fieldDef.getFields().get(0), "a2"); 815 // since this is a getter, its actually a method element different from the original.
816 DartField f = fieldDef.getFields().get(0);
817 assertNotNull(f);
818 Element e = f.getElement();
819 assertNotNull(e);
820 assertTrue(f.getName().getName().equals("a2"));
821 assertTrue(e.getName().equals("a2"));
815 } 822 }
816 { 823 {
817 DartMethodDefinition constructor = (DartMethodDefinition) classA.getMemb ers().get(2); 824 DartMethodDefinition constructor = (DartMethodDefinition) classA.getMemb ers().get(2);
818 assertDeclarationNameElement(constructor, ""); 825 assertDeclarationNameElement(constructor, "");
819 } 826 }
820 } 827 }
821 // top level "c" 828 // top level "c"
822 { 829 {
823 DartFieldDefinition fieldDef = (DartFieldDefinition) unit.getTopLevelNodes ().get(1); 830 DartFieldDefinition fieldDef = (DartFieldDefinition) unit.getTopLevelNodes ().get(1);
824 assertDeclarationNameElement(fieldDef.getFields().get(0), "c"); 831 assertDeclarationNameElement(fieldDef.getFields().get(0), "c");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 /** 898 /**
892 * Asserts that given nodes have same not <code>null</code> {@link Element}. 899 * Asserts that given nodes have same not <code>null</code> {@link Element}.
893 */ 900 */
894 private static void assertNameHasSameElement(DartNode node, DartExpression nam eNode, String name) { 901 private static void assertNameHasSameElement(DartNode node, DartExpression nam eNode, String name) {
895 Element expectedElement = node.getElement(); 902 Element expectedElement = node.getElement();
896 assertNotNull(expectedElement); 903 assertNotNull(expectedElement);
897 assertEquals(name, expectedElement.getName()); 904 assertEquals(name, expectedElement.getName());
898 assertSame(expectedElement, nameNode.getElement()); 905 assertSame(expectedElement, nameNode.getElement());
899 } 906 }
900 } 907 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698