| 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.serialization.native_data_test; | 5 library dart2js.serialization.native_data_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/common/names.dart'; | 9 import 'package:compiler/src/common/names.dart'; |
| 10 import 'package:compiler/src/commandline_options.dart'; | 10 import 'package:compiler/src/commandline_options.dart'; |
| 11 import 'package:compiler/src/compiler.dart'; | 11 import 'package:compiler/src/compiler.dart'; |
| 12 import 'package:compiler/src/js_backend/js_backend.dart'; | 12 import 'package:compiler/src/js_backend/js_backend.dart'; |
| 13 import 'package:compiler/src/js_backend/native_data.dart'; | 13 import 'package:compiler/src/js_backend/native_data.dart'; |
| 14 import 'package:compiler/src/filenames.dart'; | 14 import 'package:compiler/src/filenames.dart'; |
| 15 import 'package:compiler/src/serialization/equivalence.dart'; | 15 import 'package:compiler/src/serialization/equivalence.dart'; |
| 16 import 'package:compiler/src/world.dart'; |
| 16 import '../memory_compiler.dart'; | 17 import '../memory_compiler.dart'; |
| 17 import 'helper.dart'; | 18 import 'helper.dart'; |
| 18 import 'test_helper.dart'; | 19 import 'test_helper.dart'; |
| 19 | 20 |
| 20 main(List<String> args) { | 21 main(List<String> args) { |
| 21 asyncTest(() async { | 22 asyncTest(() async { |
| 22 Arguments arguments = new Arguments.from(args); | 23 Arguments arguments = new Arguments.from(args); |
| 23 Uri uri = Uris.dart_html; | 24 Uri uri = Uris.dart_html; |
| 24 if (arguments.filename != null) { | 25 if (arguments.filename != null) { |
| 25 uri = Uri.base.resolve(nativeToUriPath(arguments.filename)); | 26 uri = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
| 26 } | 27 } |
| 27 await checkNativeData(uri, verbose: arguments.verbose); | 28 await checkNativeData(uri, verbose: arguments.verbose); |
| 28 }); | 29 }); |
| 29 } | 30 } |
| 30 | 31 |
| 31 Future checkNativeData(Uri uri, {bool verbose: false}) async { | 32 Future checkNativeData(Uri uri, {bool verbose: false}) async { |
| 32 print('------------------------------------------------------------------'); | 33 print('------------------------------------------------------------------'); |
| 33 print('analyze normal: $uri'); | 34 print('analyze normal: $uri'); |
| 34 print('------------------------------------------------------------------'); | 35 print('------------------------------------------------------------------'); |
| 35 SerializationResult result = await serialize(uri); | 36 SerializationResult result = await serialize(uri); |
| 36 Compiler compiler1 = result.compiler; | 37 Compiler compiler1 = result.compiler; |
| 37 SerializedData serializedData = result.serializedData; | 38 SerializedData serializedData = result.serializedData; |
| 39 ClosedWorld closedWorld1 = compiler1.closeResolution().closedWorld; |
| 38 | 40 |
| 39 print('------------------------------------------------------------------'); | 41 print('------------------------------------------------------------------'); |
| 40 print('analyze deserialized: $uri'); | 42 print('analyze deserialized: $uri'); |
| 41 print('------------------------------------------------------------------'); | 43 print('------------------------------------------------------------------'); |
| 42 Compiler compiler2 = compilerFor( | 44 Compiler compiler2 = compilerFor( |
| 43 memorySourceFiles: serializedData.toMemorySourceFiles(), | 45 memorySourceFiles: serializedData.toMemorySourceFiles(), |
| 44 resolutionInputs: serializedData.toUris(), | 46 resolutionInputs: serializedData.toUris(), |
| 45 options: [Flags.analyzeAll]); | 47 options: [Flags.analyzeAll]); |
| 46 await compiler2.run(uri); | 48 await compiler2.run(uri); |
| 49 ClosedWorld closedWorld2 = compiler2.closeResolution().closedWorld; |
| 47 | 50 |
| 48 JavaScriptBackend backend1 = compiler1.backend; | 51 JavaScriptBackend backend1 = compiler1.backend; |
| 49 JavaScriptBackend backend2 = compiler2.backend; | 52 JavaScriptBackend backend2 = compiler2.backend; |
| 50 NativeBasicDataImpl nativeBasicData1 = backend1.nativeBasicData; | 53 NativeBasicDataImpl nativeBasicData1 = backend1.nativeBasicData; |
| 51 NativeBasicDataImpl nativeBasicData2 = backend2.nativeBasicData; | 54 NativeBasicDataImpl nativeBasicData2 = backend2.nativeBasicData; |
| 52 NativeDataImpl nativeData1 = backend1.nativeData; | 55 NativeDataImpl nativeData1 = closedWorld1.nativeData; |
| 53 NativeDataImpl nativeData2 = backend2.nativeData; | 56 NativeDataImpl nativeData2 = closedWorld2.nativeData; |
| 54 | 57 |
| 55 checkMaps( | 58 checkMaps( |
| 56 nativeData1.jsInteropLibraryNames, | 59 nativeData1.jsInteropLibraryNames, |
| 57 nativeData2.jsInteropLibraryNames, | 60 nativeData2.jsInteropLibraryNames, |
| 58 "NativeData.jsInteropLibraryNames", | 61 "NativeData.jsInteropLibraryNames", |
| 59 areElementsEquivalent, | 62 areElementsEquivalent, |
| 60 equality, | 63 equality, |
| 61 verbose: verbose); | 64 verbose: verbose); |
| 62 | 65 |
| 63 checkMaps(nativeData1.jsInteropClassNames, nativeData2.jsInteropClassNames, | 66 checkMaps(nativeData1.jsInteropClassNames, nativeData2.jsInteropClassNames, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 verbose: verbose); | 100 verbose: verbose); |
| 98 | 101 |
| 99 checkMaps( | 102 checkMaps( |
| 100 nativeData1.nativeFieldStoreBehavior, | 103 nativeData1.nativeFieldStoreBehavior, |
| 101 nativeData2.nativeFieldStoreBehavior, | 104 nativeData2.nativeFieldStoreBehavior, |
| 102 "NativeData.nativeFieldStoreBehavior", | 105 "NativeData.nativeFieldStoreBehavior", |
| 103 areElementsEquivalent, | 106 areElementsEquivalent, |
| 104 testNativeBehavior, | 107 testNativeBehavior, |
| 105 verbose: verbose); | 108 verbose: verbose); |
| 106 } | 109 } |
| OLD | NEW |