| 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import "package:compiler/implementation/dart2jslib.dart"; | 8 import "package:compiler/implementation/dart2jslib.dart"; |
| 9 import "package:compiler/implementation/elements/elements.dart"; | 9 import "package:compiler/implementation/elements/elements.dart"; |
| 10 import "package:compiler/implementation/tree/tree.dart"; | 10 import "package:compiler/implementation/tree/tree.dart"; |
| 11 import "package:compiler/implementation/util/util.dart"; | |
| 12 import "mock_compiler.dart"; | 11 import "mock_compiler.dart"; |
| 13 import "mock_libraries.dart"; | 12 import "mock_libraries.dart"; |
| 14 import "parser_helper.dart"; | 13 import 'package:compiler/implementation/elements/modelx.dart'; |
| 15 | 14 |
| 16 Future<Compiler> applyPatch(String script, String patch, | 15 Future<Compiler> applyPatch(String script, String patch, |
| 17 {bool analyzeAll: false, bool analyzeOnly: false}) { | 16 {bool analyzeAll: false, bool analyzeOnly: false}) { |
| 18 Map<String, String> core = <String, String>{'script': script}; | 17 Map<String, String> core = <String, String>{'script': script}; |
| 19 MockCompiler compiler = new MockCompiler.internal(coreSource: core, | 18 MockCompiler compiler = new MockCompiler.internal(coreSource: core, |
| 20 analyzeAll: analyzeAll, | 19 analyzeAll: analyzeAll, |
| 21 analyzeOnly: analyzeOnly); | 20 analyzeOnly: analyzeOnly); |
| 22 var uri = Uri.parse("patch:core"); | 21 var uri = Uri.parse("patch:core"); |
| 23 compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch"); | 22 compiler.registerSource(uri, "$DEFAULT_PATCH_CORE_SOURCE\n$patch"); |
| 24 return compiler.init().then((_) => compiler); | 23 return compiler.init().then((_) => compiler); |
| 25 } | 24 } |
| 26 | 25 |
| 27 void expectHasBody(compiler, Element element) { | 26 void expectHasBody(compiler, ElementX element) { |
| 28 var node = element.parseNode(compiler); | 27 var node = element.parseNode(compiler); |
| 29 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 28 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
| 30 Expect.isNotNull(node.body); | 29 Expect.isNotNull(node.body); |
| 31 // If the element has a body it is either a Block or a Return statement, | 30 // If the element has a body it is either a Block or a Return statement, |
| 32 // both with different begin and end tokens. | 31 // both with different begin and end tokens. |
| 33 Expect.isTrue(node.body is Block || node.body is Return); | 32 Expect.isTrue(node.body is Block || node.body is Return); |
| 34 Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken()); | 33 Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken()); |
| 35 } | 34 } |
| 36 | 35 |
| 37 void expectHasNoBody(compiler, Element element) { | 36 void expectHasNoBody(compiler, ElementX element) { |
| 38 var node = element.parseNode(compiler); | 37 var node = element.parseNode(compiler); |
| 39 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 38 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
| 40 Expect.isFalse(node.hasBody()); | 39 Expect.isFalse(node.hasBody()); |
| 41 } | 40 } |
| 42 | 41 |
| 43 Element ensure(compiler, | 42 Element ensure(compiler, |
| 44 String name, | 43 String name, |
| 45 Element lookup(name), | 44 Element lookup(name), |
| 46 {bool expectIsPatched: false, | 45 {bool expectIsPatched: false, |
| 47 bool expectIsPatch: false, | 46 bool expectIsPatch: false, |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 testPatchNoGetter(); | 880 testPatchNoGetter(); |
| 882 testPatchNonSetter(); | 881 testPatchNonSetter(); |
| 883 testPatchNoSetter(); | 882 testPatchNoSetter(); |
| 884 testPatchNonFunction(); | 883 testPatchNonFunction(); |
| 885 | 884 |
| 886 testPatchAndSelector(); | 885 testPatchAndSelector(); |
| 887 | 886 |
| 888 testAnalyzeAllInjectedMembers(); | 887 testAnalyzeAllInjectedMembers(); |
| 889 testTypecheckPatchedMembers(); | 888 testTypecheckPatchedMembers(); |
| 890 } | 889 } |
| OLD | NEW |