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

Side by Side Diff: pkg/analyzer/test/src/dart/sdk/patch_test.dart

Issue 2667633004: Remove class FastUri from analyzer. (Closed)
Patch Set: Created 3 years, 10 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) 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/token.dart'; 6 import 'package:analyzer/dart/ast/token.dart';
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/src/dart/sdk/patch.dart'; 9 import 'package:analyzer/src/dart/sdk/patch.dart';
10 import 'package:analyzer/src/dart/sdk/sdk.dart'; 10 import 'package:analyzer/src/dart/sdk/sdk.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 11 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
13 import 'package:analyzer/src/util/fast_uri.dart';
14 import 'package:test/test.dart'; 13 import 'package:test/test.dart';
15 import 'package:test_reflective_loader/test_reflective_loader.dart'; 14 import 'package:test_reflective_loader/test_reflective_loader.dart';
16 15
17 main() { 16 main() {
18 defineReflectiveSuite(() { 17 defineReflectiveSuite(() {
19 defineReflectiveTests(SdkPatcherTest); 18 defineReflectiveTests(SdkPatcherTest);
20 }); 19 });
21 } 20 }
22 21
23 @reflectiveTest 22 @reflectiveTest
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 _setSdkLibraries(r''' 797 _setSdkLibraries(r'''
799 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { 798 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
800 'test' : const LibraryInfo( 799 'test' : const LibraryInfo(
801 'test/test.dart'), 800 'test/test.dart'),
802 };'''); 801 };''');
803 _createSdk(); 802 _createSdk();
804 var patchPaths = { 803 var patchPaths = {
805 'dart:test': [_p('/sdk/lib/does_not_exist.dart')] 804 'dart:test': [_p('/sdk/lib/does_not_exist.dart')]
806 }; 805 };
807 File file = provider.newFile(_p('/sdk/lib/test/test.dart'), ''); 806 File file = provider.newFile(_p('/sdk/lib/test/test.dart'), '');
808 Source source = file.createSource(FastUri.parse('dart:test')); 807 Source source = file.createSource(Uri.parse('dart:test'));
809 CompilationUnit unit = SdkPatcher.parse(source, true, listener); 808 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
810 patcher.patch(provider, true, patchPaths, listener, source, unit); 809 patcher.patch(provider, true, patchPaths, listener, source, unit);
811 }, throwsArgumentError); 810 }, throwsArgumentError);
812 } 811 }
813 812
814 test_internal_allowNewPublicNames() { 813 test_internal_allowNewPublicNames() {
815 _setSdkLibraries(r''' 814 _setSdkLibraries(r'''
816 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> { 815 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
817 '_internal' : const LibraryInfo( 816 '_internal' : const LibraryInfo(
818 'internal/internal.dart'), 817 'internal/internal.dart'),
(...skipping 18 matching lines...) Expand all
837 int newField; 836 int newField;
838 B.newConstructor(); 837 B.newConstructor();
839 int newMethod() => 1; 838 int newMethod() => 1;
840 } 839 }
841 class NewClass {} 840 class NewClass {}
842 int newFunction() => 2; 841 int newFunction() => 2;
843 '''); 842 ''');
844 843
845 _createSdk(); 844 _createSdk();
846 845
847 Source source = file.createSource(FastUri.parse('dart:_internal')); 846 Source source = file.createSource(Uri.parse('dart:_internal'));
848 CompilationUnit unit = SdkPatcher.parse(source, true, listener); 847 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
849 patcher.patch(provider, true, patchPaths, listener, source, unit); 848 patcher.patch(provider, true, patchPaths, listener, source, unit);
850 _assertUnitCode( 849 _assertUnitCode(
851 unit, 850 unit,
852 'library dart._internal; class A {} ' 851 'library dart._internal; class A {} '
853 'class B {B(); int newField; B.newConstructor(); int newMethod() => 1;} ' 852 'class B {B(); int newField; B.newConstructor(); int newMethod() => 1;} '
854 'class NewClass {} int newFunction() => 2;'); 853 'class NewClass {} int newFunction() => 2;');
855 } 854 }
856 855
857 test_part() { 856 test_part() {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 class B { 889 class B {
891 int _b() => 1; 890 int _b() => 1;
892 } 891 }
893 892
894 class _C {} 893 class _C {}
895 '''); 894 ''');
896 895
897 _createSdk(); 896 _createSdk();
898 897
899 { 898 {
900 Uri uri = FastUri.parse('dart:test'); 899 Uri uri = Uri.parse('dart:test');
901 Source source = fileLib.createSource(uri); 900 Source source = fileLib.createSource(uri);
902 CompilationUnit unit = SdkPatcher.parse(source, true, listener); 901 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
903 patcher.patch(provider, true, patchPaths, listener, source, unit); 902 patcher.patch(provider, true, patchPaths, listener, source, unit);
904 _assertUnitCode( 903 _assertUnitCode(
905 unit, 904 unit,
906 "library test; part 'test_part.dart'; import 'foo.dart'; " 905 "library test; part 'test_part.dart'; import 'foo.dart'; "
907 "class A {int _a() => 1;} class _C {}"); 906 "class A {int _a() => 1;} class _C {}");
908 } 907 }
909 908
910 { 909 {
911 Uri uri = FastUri.parse('dart:test/test_part.dart'); 910 Uri uri = Uri.parse('dart:test/test_part.dart');
912 Source source = filePart.createSource(uri); 911 Source source = filePart.createSource(uri);
913 CompilationUnit unit = SdkPatcher.parse(source, true, listener); 912 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
914 patcher.patch(provider, true, patchPaths, listener, source, unit); 913 patcher.patch(provider, true, patchPaths, listener, source, unit);
915 _assertUnitCode(unit, "part of test; class B {int _b() => 1;}"); 914 _assertUnitCode(unit, "part of test; class B {int _b() => 1;}");
916 } 915 }
917 } 916 }
918 917
919 test_topLevel_class_append() { 918 test_topLevel_class_append() {
920 CompilationUnit unit = _doTopLevelPatching( 919 CompilationUnit unit = _doTopLevelPatching(
921 r''' 920 r'''
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 'test/test.dart'), 1188 'test/test.dart'),
1190 };'''); 1189 };''');
1191 var patchPaths = { 1190 var patchPaths = {
1192 'dart:test': [_p('/sdk/lib/test/test_patch.dart')] 1191 'dart:test': [_p('/sdk/lib/test/test_patch.dart')]
1193 }; 1192 };
1194 File file = provider.newFile(_p('/sdk/lib/test/test.dart'), baseCode); 1193 File file = provider.newFile(_p('/sdk/lib/test/test.dart'), baseCode);
1195 provider.newFile(_p('/sdk/lib/test/test_patch.dart'), patchCode); 1194 provider.newFile(_p('/sdk/lib/test/test_patch.dart'), patchCode);
1196 1195
1197 _createSdk(); 1196 _createSdk();
1198 1197
1199 Source source = file.createSource(FastUri.parse('dart:test')); 1198 Source source = file.createSource(Uri.parse('dart:test'));
1200 CompilationUnit unit = SdkPatcher.parse(source, true, listener); 1199 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
1201 patcher.patch(provider, true, patchPaths, listener, source, unit); 1200 patcher.patch(provider, true, patchPaths, listener, source, unit);
1202 return unit; 1201 return unit;
1203 } 1202 }
1204 1203
1205 String _p(String path) => provider.convertPath(path); 1204 String _p(String path) => provider.convertPath(path);
1206 1205
1207 void _setSdkLibraries(String code) { 1206 void _setSdkLibraries(String code) {
1208 provider.newFile( 1207 provider.newFile(
1209 _p('/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart'), code); 1208 _p('/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart'), code);
1210 } 1209 }
1211 1210
1212 static void _assertPrevNextToken(Token prev, Token next) { 1211 static void _assertPrevNextToken(Token prev, Token next) {
1213 expect(prev.next, same(next)); 1212 expect(prev.next, same(next));
1214 expect(next.previous, same(prev)); 1213 expect(next.previous, same(prev));
1215 } 1214 }
1216 } 1215 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698