| 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 "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; | 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; |
| 11 import "compiler_helper.dart"; | 11 import "compiler_helper.dart"; |
| 12 import "parser_helper.dart"; | 12 import "parser_helper.dart"; |
| 13 | 13 |
| 14 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; | 14 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; |
| 15 import '../../../sdk/lib/_internal/compiler/implementation/elements/modelx.dart'
; |
| 15 | 16 |
| 16 Node buildIdentifier(String name) => new Identifier(scan(name)); | 17 Node buildIdentifier(String name) => new Identifier(scan(name)); |
| 17 | 18 |
| 18 Node buildInitialization(String name) => | 19 Node buildInitialization(String name) => |
| 19 parseBodyCode('$name = 1', | 20 parseBodyCode('$name = 1', |
| 20 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); | 21 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); |
| 21 | 22 |
| 22 createLocals(List variables) { | 23 createLocals(List variables) { |
| 23 var locals = []; | 24 var locals = []; |
| 24 for (final variable in variables) { | 25 for (final variable in variables) { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 compiler.resolver.resolve(fooElement); | 607 compiler.resolver.resolve(fooElement); |
| 607 | 608 |
| 608 compareWarningKinds( | 609 compareWarningKinds( |
| 609 script, [MessageKind.INVALID_ARGUMENTS], compiler.warnings); | 610 script, [MessageKind.INVALID_ARGUMENTS], compiler.warnings); |
| 610 compareWarningKinds(script, [], compiler.errors); | 611 compareWarningKinds(script, [], compiler.errors); |
| 611 } | 612 } |
| 612 | 613 |
| 613 testTopLevelFields() { | 614 testTopLevelFields() { |
| 614 MockCompiler compiler = new MockCompiler(); | 615 MockCompiler compiler = new MockCompiler(); |
| 615 compiler.parseScript("int a;"); | 616 compiler.parseScript("int a;"); |
| 616 VariableElement element = compiler.mainApp.find("a"); | 617 VariableElementX element = compiler.mainApp.find("a"); |
| 617 Expect.equals(ElementKind.FIELD, element.kind); | 618 Expect.equals(ElementKind.FIELD, element.kind); |
| 618 VariableDefinitions node = element.variables.parseNode(element, compiler); | 619 VariableDefinitions node = element.variables.parseNode(element, compiler); |
| 619 Identifier typeName = node.type.typeName; | 620 Identifier typeName = node.type.typeName; |
| 620 Expect.equals(typeName.source, 'int'); | 621 Expect.equals(typeName.source, 'int'); |
| 621 | 622 |
| 622 compiler.parseScript("var b, c;"); | 623 compiler.parseScript("var b, c;"); |
| 623 VariableElement bElement = compiler.mainApp.find("b"); | 624 VariableElementX bElement = compiler.mainApp.find("b"); |
| 624 VariableElement cElement = compiler.mainApp.find("c"); | 625 VariableElementX cElement = compiler.mainApp.find("c"); |
| 625 Expect.equals(ElementKind.FIELD, bElement.kind); | 626 Expect.equals(ElementKind.FIELD, bElement.kind); |
| 626 Expect.equals(ElementKind.FIELD, cElement.kind); | 627 Expect.equals(ElementKind.FIELD, cElement.kind); |
| 627 Expect.isTrue(bElement != cElement); | 628 Expect.isTrue(bElement != cElement); |
| 628 | 629 |
| 629 VariableDefinitions bNode = bElement.variables.parseNode(bElement, compiler); | 630 VariableDefinitions bNode = bElement.variables.parseNode(bElement, compiler); |
| 630 VariableDefinitions cNode = cElement.variables.parseNode(cElement, compiler); | 631 VariableDefinitions cNode = cElement.variables.parseNode(cElement, compiler); |
| 631 Expect.equals(bNode, cNode); | 632 Expect.equals(bNode, cNode); |
| 632 Expect.isNull(bNode.type); | 633 Expect.isNull(bNode.type); |
| 633 Expect.isTrue(bNode.modifiers.isVar()); | 634 Expect.isTrue(bNode.modifiers.isVar()); |
| 634 } | 635 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 }"""; | 1011 }"""; |
| 1011 asyncTest(() => compileScript(script2).then((compiler) { | 1012 asyncTest(() => compileScript(script2).then((compiler) { |
| 1012 expect(compiler, | 1013 expect(compiler, |
| 1013 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1014 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1014 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1015 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1015 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1016 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1016 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1017 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1017 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1018 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1018 })); | 1019 })); |
| 1019 } | 1020 } |
| OLD | NEW |