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

Unified Diff: pkg/analyzer2dart/test/identifier_semantics_test.dart

Issue 702473002: Fix access semantics for foreach loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer2dart/test/identifier_semantics_test.dart
diff --git a/pkg/analyzer2dart/test/identifier_semantics_test.dart b/pkg/analyzer2dart/test/identifier_semantics_test.dart
index 3ccc46fd5eae15baa06d30aa707e270fe8e23e87..b9a3044cd3de56a832ac6f954a2e166780646aae 100644
--- a/pkg/analyzer2dart/test/identifier_semantics_test.dart
+++ b/pkg/analyzer2dart/test/identifier_semantics_test.dart
@@ -1103,6 +1103,17 @@ f() {
helper.checkStaticField('x', null, 'x', isWrite: true);
});
+ test('Set variable defined at top level in foreach loop', () {
+ Helper helper = new Helper('''
+var x;
+
+f() {
+ for (x in []) {}
+}
+''');
+ helper.checkStaticField('x', null, 'x', isWrite: true);
+ });
+
test('Set variable defined at top level via prefix', () {
Helper helper = new Helper('''
import 'lib.dart' as l;
@@ -1132,6 +1143,20 @@ class A {
helper.checkStaticField('x', 'A', 'x', isWrite: true);
});
+ test('Set field defined statically in class from inside class in foreach' +
+ ' loop', () {
+ Helper helper = new Helper('''
+class A {
+ static var x;
+
+ f() {
+ for (x in []) {}
+ }
+}
+''');
+ helper.checkStaticField('x', 'A', 'x', isWrite: true);
+ });
+
test('Set field defined statically in class from outside class', () {
Helper helper = new Helper('''
class A {
@@ -1178,6 +1203,20 @@ class A {
helper.checkDynamic('x', null, 'x', isWrite: true);
});
+ test('Set field defined dynamically in class from inside class in foreach' +
+ ' loop', () {
+ Helper helper = new Helper('''
+class A {
+ var x;
+
+ f() {
+ for (x in []) {}
+ }
+}
+''');
+ helper.checkDynamic('x', null, 'x', isWrite: true);
+ });
+
test(
'Set field defined dynamically in class from outside class via typed var',
() {
@@ -1220,6 +1259,16 @@ f() {
helper.checkLocalVariable('x', 'x', isWrite: true);
});
+ test('Set variable defined locally in foreach loop', () {
+ Helper helper = new Helper('''
+f() {
+ var x;
+ for (x in []) {}
+}
+''');
+ helper.checkLocalVariable('x', 'x', isWrite: true);
+ });
+
test('Set variable defined in parameter', () {
Helper helper = new Helper('''
f(x) {
@@ -1229,6 +1278,15 @@ f(x) {
helper.checkParameter('x', 'x', isWrite: true);
});
+ test('Set variable defined in parameter in foreach loop', () {
+ Helper helper = new Helper('''
+f(x) {
+ for (x in []) {}
+}
+''');
+ helper.checkParameter('x', 'x', isWrite: true);
+ });
+
test('Set accessor defined at top level', () {
Helper helper = new Helper('''
set x(value) {};
@@ -1240,6 +1298,17 @@ f() {
helper.checkStaticProperty('x', null, 'x', true, isWrite: true);
});
+ test('Set accessor defined at top level in foreach loop', () {
+ Helper helper = new Helper('''
+set x(value) {};
+
+f() {
+ for (x in []) {}
+}
+''');
+ helper.checkStaticProperty('x', null, 'x', true, isWrite: true);
+ });
+
test('Set accessor defined at top level via prefix', () {
Helper helper = new Helper('''
import 'lib.dart' as l;
@@ -1269,6 +1338,20 @@ class A {
helper.checkStaticProperty('x', 'A', 'x', true, isWrite: true);
});
+ test('Set accessor defined statically in class from inside class in' +
+ ' foreach loop', () {
+ Helper helper = new Helper('''
+class A {
+ static set x(value) {}
+
+ f() {
+ for (x in []) {}
+ }
+}
+''');
+ helper.checkStaticProperty('x', 'A', 'x', true, isWrite: true);
+ });
+
test('Set accessor defined statically in class from outside class', () {
Helper helper = new Helper('''
class A {
@@ -1315,6 +1398,20 @@ class A {
helper.checkDynamic('x', null, 'x', isWrite: true);
});
+ test('Set accessor defined dynamically in class from inside class in' +
+ ' foreach loop', () {
+ Helper helper = new Helper('''
+class A {
+ set x(value) {}
+
+ f() {
+ for (x in []) {}
+ }
+}
+''');
+ helper.checkDynamic('x', null, 'x', isWrite: true);
+ });
+
test(
'Set accessor defined dynamically in class from outside class via typed var',
() {
@@ -1380,6 +1477,15 @@ f() {
helper.checkDynamic('x', null, 'x', isWrite: true);
});
+ test('Set accessor undefined at top level in foreach loop', () {
+ Helper helper = new Helper('''
+f() {
+ for (x in []) {}
+}
+''');
+ helper.checkDynamic('x', null, 'x', isWrite: true);
+ });
+
test('Set accessor undefined at top level via prefix', () {
Helper helper = new Helper('''
import 'lib.dart' as l;
@@ -1434,6 +1540,18 @@ class A {
helper.checkDynamic('x', null, 'x', isWrite: true);
});
+ test('Set accessor undefined dynamically in class from inside class in' +
+ ' foreach loop', () {
+ Helper helper = new Helper('''
+class A {
+ f() {
+ for (x in []) {}
+ }
+}
+''');
+ helper.checkDynamic('x', null, 'x', isWrite: true);
+ });
+
test(
'Set accessor undefined dynamically in class from outside class via typed var',
() {
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698