| OLD | NEW |
| 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 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import "package:compiler/implementation/resolution/resolution.dart"; | 10 import "package:compiler/implementation/resolution/resolution.dart"; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 locals.add(buildIdentifier(name)); | 32 locals.add(buildIdentifier(name)); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 var definitions = new NodeList(null, LinkFromList(locals), null, null); | 35 var definitions = new NodeList(null, LinkFromList(locals), null, null); |
| 36 return new VariableDefinitions(null, Modifiers.EMPTY, definitions); | 36 return new VariableDefinitions(null, Modifiers.EMPTY, definitions); |
| 37 } | 37 } |
| 38 | 38 |
| 39 Future testLocals(List variables) { | 39 Future testLocals(List variables) { |
| 40 return MockCompiler.create((MockCompiler compiler) { | 40 return MockCompiler.create((MockCompiler compiler) { |
| 41 ResolverVisitor visitor = compiler.resolverVisitor(); | 41 ResolverVisitor visitor = compiler.resolverVisitor(); |
| 42 Element element = visitor.visit(createLocals(variables)); | 42 ResolutionResult result = visitor.visit(createLocals(variables)); |
| 43 Element element = result != null ? result.element : null; |
| 43 // A VariableDefinitions does not have an element. | 44 // A VariableDefinitions does not have an element. |
| 44 Expect.equals(null, element); | 45 Expect.equals(null, element); |
| 45 Expect.equals(variables.length, map(visitor).length); | 46 Expect.equals(variables.length, map(visitor).length); |
| 46 | 47 |
| 47 for (final variable in variables) { | 48 for (final variable in variables) { |
| 48 final name = variable[0]; | 49 final name = variable[0]; |
| 49 Identifier id = buildIdentifier(name); | 50 Identifier id = buildIdentifier(name); |
| 50 final VariableElement variableElement = visitor.visit(id); | 51 ResolutionResult result = visitor.visit(id); |
| 52 final VariableElement variableElement = |
| 53 result != null ? result.element : null; |
| 51 MethodScope scope = visitor.scope; | 54 MethodScope scope = visitor.scope; |
| 52 Expect.equals(variableElement, scope.elements[name]); | 55 Expect.equals(variableElement, scope.elements[name]); |
| 53 } | 56 } |
| 54 return compiler; | 57 return compiler; |
| 55 }); | 58 }); |
| 56 } | 59 } |
| 57 | 60 |
| 58 main() { | 61 main() { |
| 59 asyncTest(() => Future.forEach([ | 62 asyncTest(() => Future.forEach([ |
| 60 testLocalsOne, | 63 testLocalsOne, |
| (...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 }"""; | 1084 }"""; |
| 1082 asyncTest(() => compileScript(script2).then((compiler) { | 1085 asyncTest(() => compileScript(script2).then((compiler) { |
| 1083 expect(compiler, | 1086 expect(compiler, |
| 1084 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1087 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1085 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1088 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1086 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1089 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1087 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1090 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1088 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1091 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1089 })); | 1092 })); |
| 1090 } | 1093 } |
| OLD | NEW |