Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1561073007: Set LibraryElement.entryPoint properly during summary resynthesis. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'package:analyzer/src/generated/element.dart'; 7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/summary/base.dart'; 10 import 'package:analyzer/src/summary/base.dart';
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 for (int i = 0; i < resynthesized.imports.length; i++) { 57 for (int i = 0; i < resynthesized.imports.length; i++) {
58 compareImportElements(resynthesized.imports[i], original.imports[i], 58 compareImportElements(resynthesized.imports[i], original.imports[i],
59 'import ${original.imports[i].uri}'); 59 'import ${original.imports[i].uri}');
60 } 60 }
61 expect(resynthesized.exports.length, original.exports.length); 61 expect(resynthesized.exports.length, original.exports.length);
62 for (int i = 0; i < resynthesized.exports.length; i++) { 62 for (int i = 0; i < resynthesized.exports.length; i++) {
63 compareExportElements(resynthesized.exports[i], original.exports[i], 63 compareExportElements(resynthesized.exports[i], original.exports[i],
64 'export ${original.exports[i].uri}'); 64 'export ${original.exports[i].uri}');
65 } 65 }
66 expect(resynthesized.nameLength, original.nameLength); 66 expect(resynthesized.nameLength, original.nameLength);
67 // TODO(paulberry): test entryPoint, exportNamespace, publicNamespace, 67 if (original.entryPoint == null) {
68 expect(resynthesized.entryPoint, isNull);
69 } else {
70 expect(resynthesized.entryPoint, isNotNull);
71 compareFunctionElements(
72 resynthesized.entryPoint, original.entryPoint, '(entry point)');
73 }
74 // TODO(paulberry): test exportNamespace, publicNamespace,
68 // and metadata. 75 // and metadata.
69 } 76 }
70 77
71 void compareClassElements( 78 void compareClassElements(
72 ClassElementImpl resynthesized, ClassElementImpl original, String desc) { 79 ClassElementImpl resynthesized, ClassElementImpl original, String desc) {
73 compareElements(resynthesized, original, desc); 80 compareElements(resynthesized, original, desc);
74 expect(resynthesized.fields.length, original.fields.length, 81 expect(resynthesized.fields.length, original.fields.length,
75 reason: '$desc fields.length'); 82 reason: '$desc fields.length');
76 for (int i = 0; i < resynthesized.fields.length; i++) { 83 for (int i = 0; i < resynthesized.fields.length; i++) {
77 String name = original.fields[i].name; 84 String name = original.fields[i].name;
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 addLibrary('dart:async'); 799 addLibrary('dart:async');
793 checkLibrary('export "dart:async" show Future, Stream;'); 800 checkLibrary('export "dart:async" show Future, Stream;');
794 } 801 }
795 802
796 test_exports() { 803 test_exports() {
797 addLibrarySource('/a.dart', 'library a;'); 804 addLibrarySource('/a.dart', 'library a;');
798 addLibrarySource('/b.dart', 'library b;'); 805 addLibrarySource('/b.dart', 'library b;');
799 checkLibrary('export "a.dart"; export "b.dart";'); 806 checkLibrary('export "a.dart"; export "b.dart";');
800 } 807 }
801 808
809 test_function_entry_point() {
810 checkLibrary('main() {}');
811 }
812
813 test_function_entry_point_in_part() {
814 addNamedSource('/a.dart', 'part of my.lib; main() {}');
815 checkLibrary('library my.lib; part "a.dart";');
816 }
817
802 test_function_external() { 818 test_function_external() {
803 checkLibrary('external f();'); 819 checkLibrary('external f();');
804 } 820 }
805 821
806 test_function_parameter_kind_named() { 822 test_function_parameter_kind_named() {
807 // TODO(paulberry): also test default value. 823 // TODO(paulberry): also test default value.
808 checkLibrary('f({x}) {}'); 824 checkLibrary('f({x}) {}');
809 } 825 }
810 826
811 test_function_parameter_kind_positional() { 827 test_function_parameter_kind_positional() {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1197 }
1182 1198
1183 test_variable_implicit_type() { 1199 test_variable_implicit_type() {
1184 checkLibrary('var x;'); 1200 checkLibrary('var x;');
1185 } 1201 }
1186 1202
1187 test_variables() { 1203 test_variables() {
1188 checkLibrary('int i; int j;'); 1204 checkLibrary('int i; int j;');
1189 } 1205 }
1190 } 1206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698