| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.kernel.impact_test; | 5 library dart2js.kernel.impact_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/common.dart'; | 10 import 'package:compiler/src/common.dart'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 testEmptyMapLiteralTyped(); | 47 testEmptyMapLiteralTyped(); |
| 48 testEmptyMapLiteralConstant(); | 48 testEmptyMapLiteralConstant(); |
| 49 testNonEmptyMapLiteral(); | 49 testNonEmptyMapLiteral(); |
| 50 testNot(); | 50 testNot(); |
| 51 testUnaryMinus(); | 51 testUnaryMinus(); |
| 52 testConditional(); | 52 testConditional(); |
| 53 testPostInc(null); | 53 testPostInc(null); |
| 54 testPostDec(null); | 54 testPostDec(null); |
| 55 testPreInc(null); | 55 testPreInc(null); |
| 56 testPreDec(null); | 56 testPreDec(null); |
| 57 testIs(null); |
| 58 testIsGeneric(null); |
| 59 testIsGenericRaw(null); |
| 60 testIsGenericDynamic(null); |
| 61 testIsNot(null); |
| 62 testIsNotGeneric(null); |
| 63 testIsNotGenericRaw(null); |
| 64 testIsNotGenericDynamic(null); |
| 65 testAs(null); |
| 66 testAsGeneric(null); |
| 67 testAsGenericRaw(null); |
| 68 testAsGenericDynamic(null); |
| 69 testThrow(); |
| 70 testSyncStar(); |
| 71 testAsync(); |
| 72 testAsyncStar(); |
| 57 testIfThen(); | 73 testIfThen(); |
| 58 testIfThenElse(); | 74 testIfThenElse(); |
| 75 testForIn(null); |
| 76 testForInTyped(null); |
| 77 testAsyncForIn(null); |
| 78 testAsyncForInTyped(null); |
| 59 testTopLevelInvoke(); | 79 testTopLevelInvoke(); |
| 60 testTopLevelInvokeTyped(); | 80 testTopLevelInvokeTyped(); |
| 61 testTopLevelFunctionTyped(); | 81 testTopLevelFunctionTyped(); |
| 62 testTopLevelFunctionGet(); | 82 testTopLevelFunctionGet(); |
| 63 testTopLevelField(); | 83 testTopLevelField(); |
| 64 testTopLevelFieldLazy(); | 84 testTopLevelFieldLazy(); |
| 65 testTopLevelFieldConst(); | 85 testTopLevelFieldConst(); |
| 66 testTopLevelFieldFinal(); | 86 testTopLevelFieldFinal(); |
| 67 testTopLevelFieldTyped(); | 87 testTopLevelFieldTyped(); |
| 68 testTopLevelFieldGeneric1(); | 88 testTopLevelFieldGeneric1(); |
| 69 testTopLevelFieldGeneric2(); | 89 testTopLevelFieldGeneric2(); |
| 70 testTopLevelFieldGeneric3(); | 90 testTopLevelFieldGeneric3(); |
| 71 testDynamicInvoke(null); | 91 testDynamicInvoke(null); |
| 72 testDynamicGet(null); | 92 testDynamicGet(null); |
| 73 testDynamicSet(null); | 93 testDynamicSet(null); |
| 74 testLocalWithoutInitializer(); | 94 testLocalWithoutInitializer(); |
| 75 testLocalWithInitializer(); | 95 testLocalWithInitializer(); |
| 76 testLocalWithInitializerTyped(); | 96 testLocalWithInitializerTyped(); |
| 77 testLocalFunction(); | 97 testLocalFunction(); |
| 78 testLocalFunctionTyped(); | 98 testLocalFunctionTyped(); |
| 79 testLocalFunctionInvoke(); | 99 testLocalFunctionInvoke(); |
| 80 testLocalFunctionGet(); | 100 testLocalFunctionGet(); |
| 81 testClosure(); | 101 testClosure(); |
| 82 testClosureInvoke(); | 102 testClosureInvoke(); |
| 83 testInvokeIndex(null); | 103 testInvokeIndex(null); |
| 84 testInvokeIndexSet(null); | 104 testInvokeIndexSet(null); |
| 85 testAssert(); | 105 testAssert(); |
| 86 testAssertWithMessage(); | 106 testAssertWithMessage(); |
| 107 testConstructorInvoke(); |
| 108 testConstructorInvokeGeneric(); |
| 109 testConstructorInvokeGenericRaw(); |
| 110 testConstructorInvokeGenericDynamic(); |
| 87 testFactoryInvoke(); | 111 testFactoryInvoke(); |
| 88 testFactoryInvokeGeneric(); | 112 testFactoryInvokeGeneric(); |
| 89 testFactoryInvokeGenericRaw(); | 113 testFactoryInvokeGenericRaw(); |
| 90 testFactoryInvokeGenericDynamic(); | 114 testFactoryInvokeGenericDynamic(); |
| 91 testRedirectingFactoryInvoke(); | 115 testRedirectingFactoryInvoke(); |
| 92 testRedirectingFactoryInvokeGeneric(); | 116 testRedirectingFactoryInvokeGeneric(); |
| 93 testRedirectingFactoryInvokeGenericRaw(); | 117 testRedirectingFactoryInvokeGenericRaw(); |
| 94 testRedirectingFactoryInvokeGenericDynamic(); | 118 testRedirectingFactoryInvokeGenericDynamic(); |
| 95 } | 119 } |
| 96 | 120 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 117 testEmptyMapLiteralTyped() => <String, int>{}; | 141 testEmptyMapLiteralTyped() => <String, int>{}; |
| 118 testEmptyMapLiteralConstant() => const {}; | 142 testEmptyMapLiteralConstant() => const {}; |
| 119 testNonEmptyMapLiteral() => {0: true}; | 143 testNonEmptyMapLiteral() => {0: true}; |
| 120 testNot() => !false; | 144 testNot() => !false; |
| 121 testUnaryMinus() => -1; | 145 testUnaryMinus() => -1; |
| 122 testConditional() => true ? 1 : ''; | 146 testConditional() => true ? 1 : ''; |
| 123 testPostInc(o) => o++; | 147 testPostInc(o) => o++; |
| 124 testPostDec(o) => o--; | 148 testPostDec(o) => o--; |
| 125 testPreInc(o) => ++o; | 149 testPreInc(o) => ++o; |
| 126 testPreDec(o) => --o; | 150 testPreDec(o) => --o; |
| 151 |
| 152 testIs(o) => o is Class; |
| 153 testIsGeneric(o) => o is GenericClass<int, String>; |
| 154 testIsGenericRaw(o) => o is GenericClass; |
| 155 testIsGenericDynamic(o) => o is GenericClass<dynamic, dynamic>; |
| 156 testIsNot(o) => o is! Class; |
| 157 testIsNotGeneric(o) => o is! GenericClass<int, String>; |
| 158 testIsNotGenericRaw(o) => o is! GenericClass; |
| 159 testIsNotGenericDynamic(o) => o is! GenericClass<dynamic, dynamic>; |
| 160 testAs(o) => o as Class; |
| 161 testAsGeneric(o) => o as GenericClass<int, String>; |
| 162 testAsGenericRaw(o) => o as GenericClass; |
| 163 testAsGenericDynamic(o) => o as GenericClass<dynamic, dynamic>; |
| 164 testThrow() => throw ''; |
| 165 |
| 166 testSyncStar() sync* {} |
| 167 testAsync() async {} |
| 168 testAsyncStar() async* {} |
| 127 testIfThen() { | 169 testIfThen() { |
| 128 if (false) return 42; | 170 if (false) return 42; |
| 129 return 1; | 171 return 1; |
| 130 } | 172 } |
| 131 testIfThenElse() { | 173 testIfThenElse() { |
| 132 if (true) { | 174 if (true) { |
| 133 return 42; | 175 return 42; |
| 134 } else { | 176 } else { |
| 135 return 1; | 177 return 1; |
| 136 } | 178 } |
| 137 } | 179 } |
| 180 testForIn(o) { |
| 181 for (var e in o) {} |
| 182 } |
| 183 testForInTyped(o) { |
| 184 for (int e in o) {} |
| 185 } |
| 186 testAsyncForIn(o) async { |
| 187 await for (var e in o) {} |
| 188 } |
| 189 testAsyncForInTyped(o) async { |
| 190 await for (int e in o) {} |
| 191 } |
| 138 topLevelFunction1(a) {} | 192 topLevelFunction1(a) {} |
| 139 topLevelFunction2(a, [b, c]) {} | 193 topLevelFunction2(a, [b, c]) {} |
| 140 topLevelFunction3(a, {b, c}) {} | 194 topLevelFunction3(a, {b, c}) {} |
| 141 testTopLevelInvoke() { | 195 testTopLevelInvoke() { |
| 142 topLevelFunction1(0); | 196 topLevelFunction1(0); |
| 143 topLevelFunction2(1); | 197 topLevelFunction2(1); |
| 144 topLevelFunction2(2, 3); | 198 topLevelFunction2(2, 3); |
| 145 topLevelFunction2(4, 5, 6); | 199 topLevelFunction2(4, 5, 6); |
| 146 topLevelFunction3(7); | 200 topLevelFunction3(7); |
| 147 topLevelFunction3(8, b: 9); | 201 topLevelFunction3(8, b: 9); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 () {} (); | 292 () {} (); |
| 239 } | 293 } |
| 240 testInvokeIndex(o) => o[42]; | 294 testInvokeIndex(o) => o[42]; |
| 241 testInvokeIndexSet(o) => o[42] = null; | 295 testInvokeIndexSet(o) => o[42] = null; |
| 242 testAssert() { | 296 testAssert() { |
| 243 assert(true); | 297 assert(true); |
| 244 } | 298 } |
| 245 testAssertWithMessage() { | 299 testAssertWithMessage() { |
| 246 assert(true, 'ok'); | 300 assert(true, 'ok'); |
| 247 } | 301 } |
| 302 testConstructorInvoke() { |
| 303 new Class.generative(); |
| 304 } |
| 305 testConstructorInvokeGeneric() { |
| 306 new GenericClass<int, String>.generative(); |
| 307 } |
| 308 testConstructorInvokeGenericRaw() { |
| 309 new GenericClass.generative(); |
| 310 } |
| 311 testConstructorInvokeGenericDynamic() { |
| 312 new GenericClass<dynamic, dynamic>.generative(); |
| 313 } |
| 248 testFactoryInvoke() { | 314 testFactoryInvoke() { |
| 249 new Class.fact(); | 315 new Class.fact(); |
| 250 } | 316 } |
| 251 testFactoryInvokeGeneric() { | 317 testFactoryInvokeGeneric() { |
| 252 new GenericClass<int, String>.fact(); | 318 new GenericClass<int, String>.fact(); |
| 253 } | 319 } |
| 254 testFactoryInvokeGenericRaw() { | 320 testFactoryInvokeGenericRaw() { |
| 255 new GenericClass.fact(); | 321 new GenericClass.fact(); |
| 256 } | 322 } |
| 257 testFactoryInvokeGenericDynamic() { | 323 testFactoryInvokeGenericDynamic() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 compiler.resolution.retainCachesForTesting = true; | 365 compiler.resolution.retainCachesForTesting = true; |
| 300 await compiler.run(entryPoint); | 366 await compiler.run(entryPoint); |
| 301 checkLibrary(compiler, compiler.mainApp); | 367 checkLibrary(compiler, compiler.mainApp); |
| 302 }); | 368 }); |
| 303 } | 369 } |
| 304 | 370 |
| 305 void checkLibrary(Compiler compiler, LibraryElement library) { | 371 void checkLibrary(Compiler compiler, LibraryElement library) { |
| 306 library.forEachLocalMember((AstElement element) { | 372 library.forEachLocalMember((AstElement element) { |
| 307 if (element.isClass) { | 373 if (element.isClass) { |
| 308 // TODO(johnniwinther): Handle class members. | 374 // TODO(johnniwinther): Handle class members. |
| 375 } else if (element.isTypedef) { |
| 376 // Skip typedefs. |
| 309 } else { | 377 } else { |
| 310 checkElement(compiler, element); | 378 checkElement(compiler, element); |
| 311 } | 379 } |
| 312 }); | 380 }); |
| 313 } | 381 } |
| 314 | 382 |
| 315 void checkElement(Compiler compiler, AstElement element) { | 383 void checkElement(Compiler compiler, AstElement element) { |
| 316 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); | 384 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); |
| 317 astImpact = laxImpact(element, astImpact); | 385 astImpact = laxImpact(element, astImpact); |
| 318 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); | 386 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 342 // we cannot tell the diferrence. | 410 // we cannot tell the diferrence. |
| 343 builder.registerFeature(Feature.STRING_INTERPOLATION); | 411 builder.registerFeature(Feature.STRING_INTERPOLATION); |
| 344 builder.registerFeature(Feature.STRING_JUXTAPOSITION); | 412 builder.registerFeature(Feature.STRING_JUXTAPOSITION); |
| 345 break; | 413 break; |
| 346 default: | 414 default: |
| 347 } | 415 } |
| 348 } | 416 } |
| 349 impact.nativeData.forEach(builder.registerNativeData); | 417 impact.nativeData.forEach(builder.registerNativeData); |
| 350 return builder; | 418 return builder; |
| 351 } | 419 } |
| OLD | NEW |