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

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

Issue 1842533002: Don't serialize Label in NamedExpression as a label declaration. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/summary/summarize_ast.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) 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 analyzer.test.src.summary.summary_common; 5 library analyzer.test.src.summary.summary_common;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 4655 matching lines...) Expand 10 before | Expand all | Expand 10 after
4666 } 4666 }
4667 } 4667 }
4668 4668
4669 test_executable_localLabels_inTopLevelFunction() { 4669 test_executable_localLabels_inTopLevelFunction() {
4670 String code = r''' 4670 String code = r'''
4671 f() { 4671 f() {
4672 aaa: while (true) {} 4672 aaa: while (true) {}
4673 bbb: switch (42) { 4673 bbb: switch (42) {
4674 ccc: case 0: 4674 ccc: case 0:
4675 break; 4675 break;
4676 ddd: default:
4677 break;
4676 } 4678 }
4677 } 4679 }
4678 '''; 4680 ''';
4679 UnlinkedExecutable executable = serializeExecutableText(code); 4681 UnlinkedExecutable executable = serializeExecutableText(code);
4680 List<UnlinkedLabel> labels = executable.localLabels; 4682 List<UnlinkedLabel> labels = executable.localLabels;
4681 expect(labels, hasLength(3)); 4683 expect(labels, hasLength(4));
4682 { 4684 {
4683 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa'); 4685 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
4684 expect(aaa, isNotNull); 4686 expect(aaa, isNotNull);
4685 expect(aaa.isOnSwitchMember, isFalse); 4687 expect(aaa.isOnSwitchMember, isFalse);
4686 expect(aaa.isOnSwitchStatement, isFalse); 4688 expect(aaa.isOnSwitchStatement, isFalse);
4687 } 4689 }
4688 { 4690 {
4689 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb'); 4691 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
4690 expect(bbb, isNotNull); 4692 expect(bbb, isNotNull);
4691 expect(bbb.isOnSwitchMember, isFalse); 4693 expect(bbb.isOnSwitchMember, isFalse);
4692 expect(bbb.isOnSwitchStatement, isTrue); 4694 expect(bbb.isOnSwitchStatement, isTrue);
4693 } 4695 }
4694 { 4696 {
4695 UnlinkedLabel ccc = labels.singleWhere((l) => l.name == 'ccc'); 4697 UnlinkedLabel ccc = labels.singleWhere((l) => l.name == 'ccc');
4696 expect(ccc, isNotNull); 4698 expect(ccc, isNotNull);
4697 expect(ccc.isOnSwitchMember, isTrue); 4699 expect(ccc.isOnSwitchMember, isTrue);
4698 expect(ccc.isOnSwitchStatement, isFalse); 4700 expect(ccc.isOnSwitchStatement, isFalse);
4699 } 4701 }
4702 {
4703 UnlinkedLabel ccc = labels.singleWhere((l) => l.name == 'ddd');
4704 expect(ccc, isNotNull);
4705 expect(ccc.isOnSwitchMember, isTrue);
4706 expect(ccc.isOnSwitchStatement, isFalse);
4707 }
4700 } 4708 }
4701 4709
4702 test_executable_localLabels_inTopLevelGetter() { 4710 test_executable_localLabels_inTopLevelGetter() {
4703 String code = r''' 4711 String code = r'''
4704 get g { 4712 get g {
4705 aaa: while (true) {} 4713 aaa: while (true) {}
4706 bbb: while (true) {} 4714 bbb: while (true) {}
4707 } 4715 }
4708 '''; 4716 ''';
4709 UnlinkedExecutable executable = 4717 UnlinkedExecutable executable =
4710 serializeExecutableText(code, executableName: 'g'); 4718 serializeExecutableText(code, executableName: 'g');
4711 List<UnlinkedLabel> labels = executable.localLabels; 4719 List<UnlinkedLabel> labels = executable.localLabels;
4712 expect(labels, hasLength(2)); 4720 expect(labels, hasLength(2));
4713 { 4721 {
4714 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa'); 4722 UnlinkedLabel aaa = labels.singleWhere((l) => l.name == 'aaa');
4715 expect(aaa, isNotNull); 4723 expect(aaa, isNotNull);
4716 expect(aaa.isOnSwitchMember, isFalse); 4724 expect(aaa.isOnSwitchMember, isFalse);
4717 expect(aaa.isOnSwitchStatement, isFalse); 4725 expect(aaa.isOnSwitchStatement, isFalse);
4718 } 4726 }
4719 { 4727 {
4720 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb'); 4728 UnlinkedLabel bbb = labels.singleWhere((l) => l.name == 'bbb');
4721 expect(bbb, isNotNull); 4729 expect(bbb, isNotNull);
4722 expect(bbb.isOnSwitchMember, isFalse); 4730 expect(bbb.isOnSwitchMember, isFalse);
4723 expect(bbb.isOnSwitchStatement, isFalse); 4731 expect(bbb.isOnSwitchStatement, isFalse);
4724 } 4732 }
4725 } 4733 }
4726 4734
4735 test_executable_localLabels_namedExpressionLabel() {
4736 String code = r'''
4737 f() {
4738 foo(p: 42);
4739 }
4740 foo({int p}) {}
4741 ''';
4742 UnlinkedExecutable executable = serializeExecutableText(code);
4743 List<UnlinkedLabel> labels = executable.localLabels;
4744 expect(labels, isEmpty);
4745 }
4746
4727 test_executable_localVariables_catch() { 4747 test_executable_localVariables_catch() {
4728 String code = r''' 4748 String code = r'''
4729 f() { // 1 4749 f() { // 1
4730 try { 4750 try {
4731 throw 42; 4751 throw 42;
4732 } on int catch (e, st) { // 2 4752 } on int catch (e, st) { // 2
4733 print(e); 4753 print(e);
4734 print(st); 4754 print(st);
4735 } // 3 4755 } // 3
4736 } // 4 4756 } // 4
(...skipping 3366 matching lines...) Expand 10 before | Expand all | Expand 10 after
8103 class _PrefixExpectation { 8123 class _PrefixExpectation {
8104 final ReferenceKind kind; 8124 final ReferenceKind kind;
8105 final String name; 8125 final String name;
8106 final String absoluteUri; 8126 final String absoluteUri;
8107 final String relativeUri; 8127 final String relativeUri;
8108 final int numTypeParameters; 8128 final int numTypeParameters;
8109 8129
8110 _PrefixExpectation(this.kind, this.name, 8130 _PrefixExpectation(this.kind, this.name,
8111 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0}); 8131 {this.absoluteUri, this.relativeUri, this.numTypeParameters: 0});
8112 } 8132 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698