| 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 test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 resynthesized.entryPoint, original.entryPoint, '(entry point)'); | 112 resynthesized.entryPoint, original.entryPoint, '(entry point)'); |
| 113 } | 113 } |
| 114 // The libraries `dart:core` and `dart:async` cannot create their | 114 // The libraries `dart:core` and `dart:async` cannot create their |
| 115 // `loadLibrary` functions until after both are created. | 115 // `loadLibrary` functions until after both are created. |
| 116 if (original.name != 'dart.core' && original.name != 'dart.async') { | 116 if (original.name != 'dart.core' && original.name != 'dart.async') { |
| 117 compareExecutableElements( | 117 compareExecutableElements( |
| 118 resynthesized.loadLibraryFunction as ExecutableElementImpl, | 118 resynthesized.loadLibraryFunction as ExecutableElementImpl, |
| 119 original.loadLibraryFunction as ExecutableElementImpl, | 119 original.loadLibraryFunction as ExecutableElementImpl, |
| 120 '(loadLibraryFunction)'); | 120 '(loadLibraryFunction)'); |
| 121 } | 121 } |
| 122 expect(resynthesized.libraryCycle.toSet(), original.libraryCycle.toSet()); |
| 122 } | 123 } |
| 123 | 124 |
| 124 /** | 125 /** |
| 125 * Verify that the [resynthesizer] didn't do any unnecessary work when | 126 * Verify that the [resynthesizer] didn't do any unnecessary work when |
| 126 * resynthesizing [library]. | 127 * resynthesizing [library]. |
| 127 */ | 128 */ |
| 128 void checkMinimalResynthesisWork( | 129 void checkMinimalResynthesisWork( |
| 129 _TestSummaryResynthesizer resynthesizer, LibraryElement library) { | 130 _TestSummaryResynthesizer resynthesizer, LibraryElement library) { |
| 130 // Check that no other summaries needed to be resynthesized to resynthesize | 131 // Check that no other summaries needed to be resynthesized to resynthesize |
| 131 // the library element. | 132 // the library element. |
| (...skipping 3831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3963 | 3964 |
| 3964 test_variable_inferred_type_implicit_initialized() { | 3965 test_variable_inferred_type_implicit_initialized() { |
| 3965 checkLibrary('var v = 0;'); | 3966 checkLibrary('var v = 0;'); |
| 3966 } | 3967 } |
| 3967 | 3968 |
| 3968 test_variable_propagatedType_const_noDep() { | 3969 test_variable_propagatedType_const_noDep() { |
| 3969 checkLibrary('const i = 0;'); | 3970 checkLibrary('const i = 0;'); |
| 3970 } | 3971 } |
| 3971 | 3972 |
| 3972 test_variable_propagatedType_final_dep_inLib() { | 3973 test_variable_propagatedType_final_dep_inLib() { |
| 3973 addNamedSource('/a.dart', 'final a = 1;'); | 3974 addLibrarySource('/a.dart', 'final a = 1;'); |
| 3974 checkLibrary('import "a.dart"; final b = a / 2;'); | 3975 checkLibrary('import "a.dart"; final b = a / 2;'); |
| 3975 } | 3976 } |
| 3976 | 3977 |
| 3977 test_variable_propagatedType_final_dep_inPart() { | 3978 test_variable_propagatedType_final_dep_inPart() { |
| 3978 addNamedSource('/a.dart', 'part of lib; final a = 1;'); | 3979 addNamedSource('/a.dart', 'part of lib; final a = 1;'); |
| 3979 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); | 3980 checkLibrary('library lib; part "a.dart"; final b = a / 2;'); |
| 3980 } | 3981 } |
| 3981 | 3982 |
| 3982 test_variable_propagatedType_final_noDep() { | 3983 test_variable_propagatedType_final_noDep() { |
| 3983 checkLibrary('final i = 0;'); | 3984 checkLibrary('final i = 0;'); |
| 3984 } | 3985 } |
| 3985 | 3986 |
| 3986 test_variable_propagatedType_implicit_dep() { | 3987 test_variable_propagatedType_implicit_dep() { |
| 3987 // The propagated type is defined in a library that is not imported. | 3988 // The propagated type is defined in a library that is not imported. |
| 3988 addNamedSource('/a.dart', 'class C {}'); | 3989 addLibrarySource('/a.dart', 'class C {}'); |
| 3989 addNamedSource('/b.dart', 'import "a.dart"; C f() => null;'); | 3990 addLibrarySource('/b.dart', 'import "a.dart"; C f() => null;'); |
| 3990 checkLibrary('import "b.dart"; final x = f();'); | 3991 checkLibrary('import "b.dart"; final x = f();'); |
| 3991 } | 3992 } |
| 3992 | 3993 |
| 3993 test_variable_setterInPart_getterInPart() { | 3994 test_variable_setterInPart_getterInPart() { |
| 3994 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}'); | 3995 addNamedSource('/a.dart', 'part of my.lib; void set x(int _) {}'); |
| 3995 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;'); | 3996 addNamedSource('/b.dart', 'part of my.lib; int get x => 42;'); |
| 3996 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); | 3997 checkLibrary('library my.lib; part "a.dart"; part "b.dart";'); |
| 3997 } | 3998 } |
| 3998 | 3999 |
| 3999 test_variables() { | 4000 test_variables() { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4068 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4069 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 4069 } | 4070 } |
| 4070 return serializedUnit; | 4071 return serializedUnit; |
| 4071 } | 4072 } |
| 4072 | 4073 |
| 4073 @override | 4074 @override |
| 4074 bool hasLibrarySummary(String uri) { | 4075 bool hasLibrarySummary(String uri) { |
| 4075 return true; | 4076 return true; |
| 4076 } | 4077 } |
| 4077 } | 4078 } |
| OLD | NEW |