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

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

Issue 2413403002: Allow new public names in patches for the dart:_internal library. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « pkg/analyzer/lib/src/dart/sdk/patch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 r''' 272 r'''
273 @patch 273 @patch
274 class A { 274 class A {
275 @patch 275 @patch
276 int b; 276 int b;
277 } 277 }
278 '''); 278 ''');
279 }, throwsArgumentError); 279 }, throwsArgumentError);
280 } 280 }
281 281
282 test_class_field_append_publiInPrivateClass() { 282 test_class_field_append_publicInPrivateClass() {
283 CompilationUnit unit = _doTopLevelPatching( 283 CompilationUnit unit = _doTopLevelPatching(
284 r''' 284 r'''
285 class _C { 285 class _C {
286 void a() {} 286 void a() {}
287 } 287 }
288 ''', 288 ''',
289 r''' 289 r'''
290 @patch 290 @patch
291 class _C { 291 class _C {
292 int b = 42; 292 int b = 42;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 patches: {VM_PLATFORM: ['does_not_exists.dart']}), 473 patches: {VM_PLATFORM: ['does_not_exists.dart']}),
474 };'''); 474 };''');
475 _createSdk(); 475 _createSdk();
476 File file = provider.newFile(_p('/sdk/lib/test/test.dart'), ''); 476 File file = provider.newFile(_p('/sdk/lib/test/test.dart'), '');
477 Source source = file.createSource(FastUri.parse('dart:test')); 477 Source source = file.createSource(FastUri.parse('dart:test'));
478 CompilationUnit unit = SdkPatcher.parse(source, true, listener); 478 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
479 patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit); 479 patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
480 }, throwsArgumentError); 480 }, throwsArgumentError);
481 } 481 }
482 482
483 test_internal_allowNewPublicNames() {
484 _setSdkLibraries(r'''
485 final Map<String, LibraryInfo> LIBRARIES = const <String, LibraryInfo> {
486 '_internal' : const LibraryInfo(
487 'internal/internal.dart',
488 patches: {VM_PLATFORM: ['internal/internal_patch.dart']}),
489 };''');
490 File file = provider.newFile(
491 _p('/sdk/lib/internal/internal.dart'),
492 r'''
493 library dart._internal;
494 class A {}
495 class B {
496 B();
497 }
498 ''');
499 provider.newFile(
500 _p('/sdk/lib/internal/internal_patch.dart'),
501 r'''
502 @patch
503 class B {
504 int newField;
505 B.newConstructor();
506 int newMethod() => 1;
507 }
508 class NewClass {}
509 int newFunction() => 2;
510 ''');
511
512 _createSdk();
513
514 Source source = file.createSource(FastUri.parse('dart:_internal'));
515 CompilationUnit unit = SdkPatcher.parse(source, true, listener);
516 patcher.patch(sdk, SdkLibraryImpl.VM_PLATFORM, listener, source, unit);
517 _assertUnitCode(
518 unit,
519 'library dart._internal; class A {} '
520 'class B {B(); int newField; B.newConstructor(); int newMethod() => 1;} '
521 'class NewClass {} int newFunction() => 2;');
522 }
523
483 test_part() { 524 test_part() {
484 String baseLibCode = r''' 525 String baseLibCode = r'''
485 library test; 526 library test;
486 part 'test_part.dart'; 527 part 'test_part.dart';
487 class A {} 528 class A {}
488 '''; 529 ''';
489 String basePartCode = r''' 530 String basePartCode = r'''
490 part of test; 531 part of test;
491 class B {} 532 class B {}
492 '''; 533 ''';
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 void _setSdkLibraries(String code) { 828 void _setSdkLibraries(String code) {
788 provider.newFile( 829 provider.newFile(
789 _p('/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart'), code); 830 _p('/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart'), code);
790 } 831 }
791 832
792 static void _assertPrevNextToken(Token prev, Token next) { 833 static void _assertPrevNextToken(Token prev, Token next) {
793 expect(prev.next, same(next)); 834 expect(prev.next, same(next));
794 expect(next.previous, same(prev)); 835 expect(next.previous, same(prev));
795 } 836 }
796 } 837 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/sdk/patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698