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

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

Issue 1455693002: Add summary tests for cascaded show/hide combinators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | 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) 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:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/java_engine_io.dart'; 10 import 'package:analyzer/src/generated/java_engine_io.dart';
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 /** 430 /**
431 * Serialize the given library [text] and return the summary of the variable 431 * Serialize the given library [text] and return the summary of the variable
432 * with the given [variableName]. 432 * with the given [variableName].
433 */ 433 */
434 UnlinkedVariable serializeVariableText(String text, 434 UnlinkedVariable serializeVariableText(String text,
435 {String variableName: 'v', bool allowErrors: false}) { 435 {String variableName: 'v', bool allowErrors: false}) {
436 serializeLibraryText(text, allowErrors: allowErrors); 436 serializeLibraryText(text, allowErrors: allowErrors);
437 return findVariable(variableName, failIfAbsent: true); 437 return findVariable(variableName, failIfAbsent: true);
438 } 438 }
439 439
440 test_cascaded_export_hide_hide() {
441 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C hide B, C;');
442 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
443 serializeLibraryText(
444 '''
445 import 'lib1.dart';
446 A a;
447 B b;
448 C c;
449 ''',
450 allowErrors: true);
451 checkTypeRef(
452 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A');
453 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
454 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
455 }
456
457 test_cascaded_export_hide_show() {
458 addNamedSource('/lib1.dart', 'export "lib2.dart" hide C show A, C;');
459 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
460 serializeLibraryText(
461 '''
462 import 'lib1.dart';
463 A a;
464 B b;
465 C c;
466 ''',
467 allowErrors: true);
468 checkTypeRef(
469 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A');
470 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
471 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
472 }
473
474 test_cascaded_export_show_hide() {
475 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B hide B, C;');
476 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
477 serializeLibraryText(
478 '''
479 import 'lib1.dart';
480 A a;
481 B b;
482 C c;
483 ''',
484 allowErrors: true);
485 checkTypeRef(
486 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A');
487 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
488 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
489 }
490
491 test_cascaded_export_show_show() {
492 addNamedSource('/lib1.dart', 'export "lib2.dart" show A, B show A, C;');
493 addNamedSource('/lib2.dart', 'class A {} class B {} class C {}');
494 serializeLibraryText(
495 '''
496 import 'lib1.dart';
497 A a;
498 B b;
499 C c;
500 ''',
501 allowErrors: true);
502 checkTypeRef(
503 findVariable('a').type, absUri('/lib2.dart'), 'lib2.dart', 'A');
504 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
505 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
506 }
507
508 test_cascaded_import_hide_hide() {
509 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
510 serializeLibraryText(
511 '''
512 import 'lib.dart' hide C hide B, C;
513 A a;
514 B b;
515 C c;
516 ''',
517 allowErrors: true);
518 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A');
519 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
520 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
521 }
522
523 test_cascaded_import_hide_show() {
524 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
525 serializeLibraryText(
526 '''
527 import 'lib.dart' hide C show A, C;
528 A a;
529 B b;
530 C c;
531 ''',
532 allowErrors: true);
533 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A');
534 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
535 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
536 }
537
538 test_cascaded_import_show_hide() {
539 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
540 serializeLibraryText(
541 '''
542 import 'lib.dart' show A, B hide B, C;
543 A a;
544 B b;
545 C c;
546 ''',
547 allowErrors: true);
548 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A');
549 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
550 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
551 }
552
553 test_cascaded_import_show_show() {
554 addNamedSource('/lib.dart', 'class A {} class B {} class C {}');
555 serializeLibraryText(
556 '''
557 import 'lib.dart' show A, B show A, C;
558 A a;
559 B b;
560 C c;
561 ''',
562 allowErrors: true);
563 checkTypeRef(findVariable('a').type, absUri('/lib.dart'), 'lib.dart', 'A');
564 checkUnresolvedTypeRef(findVariable('b').type, null, 'B');
565 checkUnresolvedTypeRef(findVariable('c').type, null, 'C');
566 }
567
440 test_class_abstract() { 568 test_class_abstract() {
441 UnlinkedClass cls = serializeClassText('abstract class C {}'); 569 UnlinkedClass cls = serializeClassText('abstract class C {}');
442 expect(cls.isAbstract, true); 570 expect(cls.isAbstract, true);
443 } 571 }
444 572
445 test_class_alias_abstract() { 573 test_class_alias_abstract() {
446 UnlinkedClass cls = serializeClassText( 574 UnlinkedClass cls = serializeClassText(
447 'abstract class C = D with E; class D {} class E {}'); 575 'abstract class C = D with E; class D {} class E {}');
448 expect(cls.isAbstract, true); 576 expect(cls.isAbstract, true);
449 } 577 }
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 serializeClassText('class C { static int i; }').fields[0]; 1788 serializeClassText('class C { static int i; }').fields[0];
1661 expect(variable.isStatic, isTrue); 1789 expect(variable.isStatic, isTrue);
1662 } 1790 }
1663 1791
1664 test_variable_type() { 1792 test_variable_type() {
1665 UnlinkedVariable variable = 1793 UnlinkedVariable variable =
1666 serializeVariableText('int i;', variableName: 'i'); 1794 serializeVariableText('int i;', variableName: 'i');
1667 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int'); 1795 checkTypeRef(variable.type, 'dart:core', 'dart:core', 'int');
1668 } 1796 }
1669 } 1797 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698