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/src/dart2jslib.dart"; | 8 import "package:compiler/src/dart2jslib.dart"; |
9 import "package:compiler/src/elements/elements.dart"; | 9 import "package:compiler/src/elements/elements.dart"; |
10 import "package:compiler/src/tree/tree.dart"; | 10 import "package:compiler/src/tree/tree.dart"; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 Expect.isTrue(compiler.warnings.isEmpty, | 130 Expect.isTrue(compiler.warnings.isEmpty, |
131 "Unexpected warnings: ${compiler.warnings}"); | 131 "Unexpected warnings: ${compiler.warnings}"); |
132 Expect.isTrue(compiler.errors.isEmpty, | 132 Expect.isTrue(compiler.errors.isEmpty, |
133 "Unexpected errors: ${compiler.errors}"); | 133 "Unexpected errors: ${compiler.errors}"); |
134 })); | 134 })); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 testPatchVersioned() { | 138 testPatchVersioned() { |
139 String oldPatch = "test(){return 'string';}"; | 139 String fullPatch = "test(){return 'string';}"; |
140 String newPatch = "test(){return 'new and improved string';}"; | 140 String lazyPatch = "test(){return 'new and improved string';}"; |
141 | 141 |
142 String patchSource = | 142 String patchSource = |
143 """ | 143 """ |
144 @patch_old $oldPatch | 144 @patch_full $fullPatch |
145 @patch_new $newPatch | 145 @patch_lazy $lazyPatch |
146 """; | 146 """; |
147 | 147 |
148 test(String patchVersion, | 148 test(String patchVersion, |
149 {String patchText, | 149 {String patchText, |
150 bool expectIsPatched: true, | 150 bool expectIsPatched: true, |
151 String expectedError, | 151 String expectedError, |
152 String defaultPatch: '', | 152 String defaultPatch: '', |
153 String expectedInternalError}) { | 153 String expectedInternalError}) { |
154 asyncTest(() => applyPatch( | 154 asyncTest(() => applyPatch( |
155 "external test();", | 155 "external test();", |
(...skipping 29 matching lines...) Expand all Loading... |
185 }).catchError((error) { | 185 }).catchError((error) { |
186 if (expectedInternalError != null) { | 186 if (expectedInternalError != null) { |
187 Expect.equals( | 187 Expect.equals( |
188 'Internal Error: $expectedInternalError', error.toString()); | 188 'Internal Error: $expectedInternalError', error.toString()); |
189 } else { | 189 } else { |
190 throw error; | 190 throw error; |
191 } | 191 } |
192 })); | 192 })); |
193 } | 193 } |
194 | 194 |
195 test('old', patchText: oldPatch); | 195 test('full', patchText: fullPatch); |
196 test('new', patchText: newPatch); | 196 test('lazy', patchText: lazyPatch); |
197 test('unknown', expectIsPatched: false, | 197 test('unknown', expectIsPatched: false, |
198 expectedError: 'External method without an implementation.'); | 198 expectedError: 'External method without an implementation.'); |
199 test('old', | 199 test('full', |
200 defaultPatch: "@patch test(){}", | 200 defaultPatch: "@patch test(){}", |
201 expectedInternalError: "Trying to patch a function more than once."); | 201 expectedInternalError: "Trying to patch a function more than once."); |
202 } | 202 } |
203 | 203 |
204 testPatchConstructor() { | 204 testPatchConstructor() { |
205 asyncTest(() => applyPatch( | 205 asyncTest(() => applyPatch( |
206 """ | 206 """ |
207 class Class { | 207 class Class { |
208 external Class(); | 208 external Class(); |
209 } | 209 } |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 testPatchNoSetter(); | 1015 testPatchNoSetter(); |
1016 testPatchNonFunction(); | 1016 testPatchNonFunction(); |
1017 | 1017 |
1018 testPatchAndSelector(); | 1018 testPatchAndSelector(); |
1019 | 1019 |
1020 testEffectiveTarget(); /// bug: ok | 1020 testEffectiveTarget(); /// bug: ok |
1021 | 1021 |
1022 testAnalyzeAllInjectedMembers(); | 1022 testAnalyzeAllInjectedMembers(); |
1023 testTypecheckPatchedMembers(); | 1023 testTypecheckPatchedMembers(); |
1024 } | 1024 } |
OLD | NEW |