| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.semantics_visitor_test; | 5 library dart2js.semantics_visitor_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
| 9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 if (initializers != null) { | 136 if (initializers != null) { |
| 137 sb.write(',initializers=$initializers'); | 137 sb.write(',initializers=$initializers'); |
| 138 } | 138 } |
| 139 return sb.toString(); | 139 return sb.toString(); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 class Test { | 143 class Test { |
| 144 final String codeByPrefix; | 144 final String codeByPrefix; |
| 145 final bool isDeferred; |
| 145 final String code; | 146 final String code; |
| 146 final /*Visit | List<Visit>*/ expectedVisits; | 147 final /*Visit | List<Visit>*/ expectedVisits; |
| 147 final String cls; | 148 final String cls; |
| 148 final String method; | 149 final String method; |
| 149 | 150 |
| 150 const Test(this.code, this.expectedVisits) | 151 const Test(this.code, this.expectedVisits) |
| 151 : cls = null, method = 'm', codeByPrefix = null; | 152 : cls = null, method = 'm', codeByPrefix = null, isDeferred = false; |
| 152 const Test.clazz(this.code, this.expectedVisits, | 153 const Test.clazz(this.code, this.expectedVisits, |
| 153 {this.cls: 'C', this.method: 'm'}) | 154 {this.cls: 'C', this.method: 'm'}) |
| 154 : codeByPrefix = null; | 155 : codeByPrefix = null, isDeferred = false; |
| 155 const Test.prefix(this.codeByPrefix, this.code, this.expectedVisits) | 156 const Test.prefix(this.codeByPrefix, this.code, this.expectedVisits, |
| 157 {this.isDeferred: false}) |
| 156 : cls = null, method = 'm'; | 158 : cls = null, method = 'm'; |
| 157 | 159 |
| 158 String toString() { | 160 String toString() { |
| 159 StringBuffer sb = new StringBuffer(); | 161 StringBuffer sb = new StringBuffer(); |
| 160 sb.writeln(); | 162 sb.writeln(); |
| 161 sb.writeln(code); | 163 sb.writeln(code); |
| 162 if (codeByPrefix != null) { | 164 if (codeByPrefix != null) { |
| 163 sb.writeln('imported by prefix:'); | 165 sb.writeln('imported by prefix:'); |
| 164 sb.writeln(codeByPrefix); | 166 sb.writeln(codeByPrefix); |
| 165 } | 167 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 StringBuffer mainSource = new StringBuffer(); | 271 StringBuffer mainSource = new StringBuffer(); |
| 270 int index = 0; | 272 int index = 0; |
| 271 TESTS.forEach((String group, List<Test> tests) { | 273 TESTS.forEach((String group, List<Test> tests) { |
| 272 if (arguments.isNotEmpty && !arguments.contains(group)) return; | 274 if (arguments.isNotEmpty && !arguments.contains(group)) return; |
| 273 | 275 |
| 274 tests.forEach((Test test) { | 276 tests.forEach((Test test) { |
| 275 StringBuffer testSource = new StringBuffer(); | 277 StringBuffer testSource = new StringBuffer(); |
| 276 if (test.codeByPrefix != null) { | 278 if (test.codeByPrefix != null) { |
| 277 String prefixFilename = 'pre$index.dart'; | 279 String prefixFilename = 'pre$index.dart'; |
| 278 sourceFiles[prefixFilename] = test.codeByPrefix; | 280 sourceFiles[prefixFilename] = test.codeByPrefix; |
| 279 testSource.writeln("import '$prefixFilename' as p;"); | 281 if (test.isDeferred) { |
| 282 testSource.writeln("import '$prefixFilename' deferred as p;"); |
| 283 } else { |
| 284 testSource.writeln("import '$prefixFilename' as p;"); |
| 285 } |
| 280 } | 286 } |
| 281 | 287 |
| 282 String filename = 'lib$index.dart'; | 288 String filename = 'lib$index.dart'; |
| 283 testSource.writeln(test.code); | 289 testSource.writeln(test.code); |
| 284 sourceFiles[filename] = testSource.toString(); | 290 sourceFiles[filename] = testSource.toString(); |
| 285 mainSource.writeln("import '$filename';"); | 291 mainSource.writeln("import '$filename';"); |
| 286 testMap[filename] = test; | 292 testMap[filename] = test; |
| 287 index++; | 293 index++; |
| 288 }); | 294 }); |
| 289 }); | 295 }); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND, | 702 VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_COMPOUND, |
| 697 VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX, | 703 VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_PREFIX, |
| 698 VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX, | 704 VISIT_IF_NOT_NULL_DYNAMIC_PROPERTY_POSTFIX, |
| 699 | 705 |
| 700 ERROR_INVALID_ASSERT, | 706 ERROR_INVALID_ASSERT, |
| 701 ERROR_UNDEFINED_UNARY_EXPRESSION, | 707 ERROR_UNDEFINED_UNARY_EXPRESSION, |
| 702 ERROR_UNDEFINED_BINARY_EXPRESSION, | 708 ERROR_UNDEFINED_BINARY_EXPRESSION, |
| 703 | 709 |
| 704 VISIT_CONSTANT_GET, | 710 VISIT_CONSTANT_GET, |
| 705 VISIT_CONSTANT_INVOKE, | 711 VISIT_CONSTANT_INVOKE, |
| 712 |
| 713 PREVISIT_DEFERRED_ACCESS, |
| 706 } | 714 } |
| OLD | NEW |