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

Unified Diff: pkg/analyzer_experimental/test/generated/resolver_test.dart

Issue 25373002: Issue 13584. Fix for Java/Dart local variable scoping mismatch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer_experimental/test/generated/resolver_test.dart
diff --git a/pkg/analyzer_experimental/test/generated/resolver_test.dart b/pkg/analyzer_experimental/test/generated/resolver_test.dart
index 4197d143ef3795a5777aedab589c25387cf00652..6229a06d9a0c0bb8ea4e37032d954bc30c440c05 100644
--- a/pkg/analyzer_experimental/test/generated/resolver_test.dart
+++ b/pkg/analyzer_experimental/test/generated/resolver_test.dart
@@ -1290,6 +1290,16 @@ class NonErrorResolverTest extends ResolverTestCase {
assertNoErrors(source);
verify([source]);
}
+ void test_constructorDeclaration_scope_signature() {
+ Source source = addSource(EngineTestCase.createSource([
+ "const app = 0;",
+ "class A {",
+ " A(@app int app) {}",
+ "}"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
void test_constWithNonConstantArgument_literals() {
Source source = addSource(EngineTestCase.createSource([
"class A {",
@@ -1533,6 +1543,30 @@ class NonErrorResolverTest extends ResolverTestCase {
assertNoErrors(source);
verify([source]);
}
+ void test_functionDeclaration_scope_returnType() {
+ Source source = addSource(EngineTestCase.createSource(["int f(int) {}"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+ void test_functionDeclaration_scope_signature() {
+ Source source = addSource(EngineTestCase.createSource(["const app = 0;", "f(@app int app) {}"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+ void test_functionTypeAlias_scope_returnType() {
+ Source source = addSource(EngineTestCase.createSource(["typedef int f(int);"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+ void test_functionTypeAlias_scope_signature() {
+ Source source = addSource(EngineTestCase.createSource(["const app = 0;", "typedef int f(@app int app);"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
void test_implicitThisReferenceInInitializer_constructorName() {
Source source = addSource(EngineTestCase.createSource([
"class A {",
@@ -1684,6 +1718,21 @@ class NonErrorResolverTest extends ResolverTestCase {
assertNoErrors(source);
verify([source]);
}
+ void test_importPrefixes_withFirstLetterDifference() {
+ Source source = addSource(EngineTestCase.createSource([
+ "library L;",
+ "import 'lib1.dart' as math;",
+ "import 'lib2.dart' as path;",
+ "main() {",
+ " math.test1();",
+ " path.test2();",
+ "}"]));
+ addSource2("/lib1.dart", EngineTestCase.createSource(["library lib1;", "test1() {}"]));
+ addSource2("/lib2.dart", EngineTestCase.createSource(["library lib2;", "test2() {}"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
void test_inconsistentCaseExpressionTypes() {
Source source = addSource(EngineTestCase.createSource([
"f(var p) {",
@@ -2204,6 +2253,16 @@ class NonErrorResolverTest extends ResolverTestCase {
assertNoErrors(source);
verify([source]);
}
+ void test_methodDeclaration_scope_signature() {
+ Source source = addSource(EngineTestCase.createSource([
+ "const app = 0;",
+ "class A {",
+ " foo(@app int app) {}",
+ "}"]));
+ resolve(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
void test_misMatchedGetterAndSetterTypes_instance_sameTypes() {
Source source = addSource(EngineTestCase.createSource([
"class C {",
@@ -3452,6 +3511,10 @@ class NonErrorResolverTest extends ResolverTestCase {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_constWithUndefinedConstructorDefault);
});
+ _ut.test('test_constructorDeclaration_scope_signature', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_constructorDeclaration_scope_signature);
+ });
_ut.test('test_defaultValueInFunctionTypeAlias', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_defaultValueInFunctionTypeAlias);
@@ -3560,6 +3623,22 @@ class NonErrorResolverTest extends ResolverTestCase {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_finalNotInitialized_redirectingConstructor);
});
+ _ut.test('test_functionDeclaration_scope_returnType', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_functionDeclaration_scope_returnType);
+ });
+ _ut.test('test_functionDeclaration_scope_signature', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_functionDeclaration_scope_signature);
+ });
+ _ut.test('test_functionTypeAlias_scope_returnType', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_functionTypeAlias_scope_returnType);
+ });
+ _ut.test('test_functionTypeAlias_scope_signature', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_functionTypeAlias_scope_signature);
+ });
_ut.test('test_implicitThisReferenceInInitializer_constructorName', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_implicitThisReferenceInInitializer_constructorName);
@@ -3616,6 +3695,10 @@ class NonErrorResolverTest extends ResolverTestCase {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_importOfNonLibrary_libraryNotDeclared);
});
+ _ut.test('test_importPrefixes_withFirstLetterDifference', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_importPrefixes_withFirstLetterDifference);
+ });
_ut.test('test_inconsistentCaseExpressionTypes', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_inconsistentCaseExpressionTypes);
@@ -3812,6 +3895,10 @@ class NonErrorResolverTest extends ResolverTestCase {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_memberWithClassName_setter);
});
+ _ut.test('test_methodDeclaration_scope_signature', () {
+ final __test = new NonErrorResolverTest();
+ runJUnitTest(__test, __test.test_methodDeclaration_scope_signature);
+ });
_ut.test('test_misMatchedGetterAndSetterTypes_instance_sameTypes', () {
final __test = new NonErrorResolverTest();
runJUnitTest(__test, __test.test_misMatchedGetterAndSetterTypes_instance_sameTypes);
@@ -6618,7 +6705,7 @@ class ResolverTestCase extends EngineTestCase {
* @throws AssertionFailedError if any errors have been reported
*/
void assertNoErrors(Source source) {
- EngineTestCase.assertLength(0, analysisContext.computeErrors(source));
+ assertErrors(source, []);
}
/**
@@ -16664,16 +16751,16 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
* @param body the body of the function
* @return a resolved function expression
*/
- FunctionExpression resolvedFunctionExpression(FormalParameterList parameters2, FunctionBody body) {
+ FunctionExpression resolvedFunctionExpression(FormalParameterList parameters, FunctionBody body) {
List<ParameterElement> parameterElements = new List<ParameterElement>();
- for (FormalParameter parameter in parameters2.parameters) {
+ for (FormalParameter parameter in parameters.parameters) {
ParameterElementImpl element = new ParameterElementImpl.con1(parameter.identifier);
element.parameterKind = parameter.kind;
element.type = _typeProvider.dynamicType;
parameter.identifier.staticElement = element;
parameterElements.add(element);
}
- FunctionExpression node = ASTFactory.functionExpression2(parameters2, body);
+ FunctionExpression node = ASTFactory.functionExpression2(parameters, body);
FunctionElementImpl element = new FunctionElementImpl.con1(null);
element.parameters = new List.from(parameterElements);
element.type = new FunctionTypeImpl.con1(element);
@@ -16712,12 +16799,12 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
* @param variableName the name of the variable
* @return a simple identifier that has been resolved to a variable element with the given type
*/
- SimpleIdentifier resolvedVariable(InterfaceType type2, String variableName) {
+ SimpleIdentifier resolvedVariable(InterfaceType type, String variableName) {
SimpleIdentifier identifier = ASTFactory.identifier3(variableName);
VariableElementImpl element = ElementFactory.localVariableElement(identifier);
- element.type = type2;
+ element.type = type;
identifier.staticElement = element;
- identifier.staticType = type2;
+ identifier.staticType = type;
return identifier;
}
@@ -16727,14 +16814,14 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
* @param parameter the parameter whose type is to be set
* @param type the new type of the given parameter
*/
- void setType(FormalParameter parameter, Type2 type2) {
+ void setType(FormalParameter parameter, Type2 type) {
SimpleIdentifier identifier = parameter.identifier;
Element element = identifier.staticElement;
if (element is! ParameterElement) {
element = new ParameterElementImpl.con1(identifier);
identifier.staticElement = element;
}
- ((element as ParameterElementImpl)).type = type2;
+ ((element as ParameterElementImpl)).type = type;
}
static dartSuite() {
_ut.group('StaticTypeAnalyzerTest', () {

Powered by Google App Engine
This is Rietveld 408576698