OLD | NEW |
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/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
10 import 'package:analyzer/src/dart/scanner/reader.dart'; | 10 import 'package:analyzer/src/dart/scanner/reader.dart'; |
(...skipping 5322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5333 { | 5333 { |
5334 f2() {} | 5334 f2() {} |
5335 } | 5335 } |
5336 } | 5336 } |
5337 '''; | 5337 '''; |
5338 UnlinkedExecutable executable = serializeExecutableText(code); | 5338 UnlinkedExecutable executable = serializeExecutableText(code); |
5339 List<UnlinkedExecutable> functions = executable.localFunctions; | 5339 List<UnlinkedExecutable> functions = executable.localFunctions; |
5340 expect(functions, isEmpty); | 5340 expect(functions, isEmpty); |
5341 } | 5341 } |
5342 | 5342 |
5343 test_executable_localLabels_inMethod() { | |
5344 String code = r''' | |
5345 class C { | |
5346 m() { | |
5347 aaa: while (true) {} | |
5348 bbb: while (true) {} | |
5349 } | |
5350 } | |
5351 '''; | |
5352 UnlinkedExecutable executable = | |
5353 findExecutable('m', executables: serializeClassText(code).executables); | |
5354 List<UnlinkedLabel> labels = executable.localLabels; | |
5355 expect(labels, isEmpty); | |
5356 } | |
5357 | |
5358 test_executable_localLabels_inTopLevelFunction() { | |
5359 String code = r''' | |
5360 f() { | |
5361 aaa: while (true) {} | |
5362 bbb: switch (42) { | |
5363 ccc: case 0: | |
5364 break; | |
5365 ddd: default: | |
5366 break; | |
5367 } | |
5368 } | |
5369 '''; | |
5370 UnlinkedExecutable executable = serializeExecutableText(code); | |
5371 List<UnlinkedLabel> labels = executable.localLabels; | |
5372 expect(labels, isEmpty); | |
5373 } | |
5374 | |
5375 test_executable_localLabels_inTopLevelGetter() { | |
5376 String code = r''' | |
5377 get g { | |
5378 aaa: while (true) {} | |
5379 bbb: while (true) {} | |
5380 } | |
5381 '''; | |
5382 UnlinkedExecutable executable = | |
5383 serializeExecutableText(code, executableName: 'g'); | |
5384 List<UnlinkedLabel> labels = executable.localLabels; | |
5385 expect(labels, isEmpty); | |
5386 } | |
5387 | |
5388 test_executable_localLabels_namedExpressionLabel() { | |
5389 String code = r''' | |
5390 f() { | |
5391 foo(p: 42); | |
5392 } | |
5393 foo({int p}) {} | |
5394 '''; | |
5395 UnlinkedExecutable executable = serializeExecutableText(code); | |
5396 List<UnlinkedLabel> labels = executable.localLabels; | |
5397 expect(labels, isEmpty); | |
5398 } | |
5399 | |
5400 test_executable_member_function() { | 5343 test_executable_member_function() { |
5401 UnlinkedExecutable executable = findExecutable('f', | 5344 UnlinkedExecutable executable = findExecutable('f', |
5402 executables: serializeClassText('class C { f() {} }').executables); | 5345 executables: serializeClassText('class C { f() {} }').executables); |
5403 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); | 5346 expect(executable.kind, UnlinkedExecutableKind.functionOrMethod); |
5404 expect(executable.returnType, isNull); | 5347 expect(executable.returnType, isNull); |
5405 expect(executable.isAsynchronous, isFalse); | 5348 expect(executable.isAsynchronous, isFalse); |
5406 expect(executable.isExternal, isFalse); | 5349 expect(executable.isExternal, isFalse); |
5407 expect(executable.isGenerator, isFalse); | 5350 expect(executable.isGenerator, isFalse); |
5408 if (includeInformative) { | 5351 if (includeInformative) { |
5409 expect(executable.visibleOffset, 0); | 5352 expect(executable.visibleOffset, 0); |
(...skipping 4946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10356 */ | 10299 */ |
10357 class _PrefixExpectation { | 10300 class _PrefixExpectation { |
10358 final ReferenceKind kind; | 10301 final ReferenceKind kind; |
10359 final String name; | 10302 final String name; |
10360 final String absoluteUri; | 10303 final String absoluteUri; |
10361 final int numTypeParameters; | 10304 final int numTypeParameters; |
10362 | 10305 |
10363 _PrefixExpectation(this.kind, this.name, | 10306 _PrefixExpectation(this.kind, this.name, |
10364 {this.absoluteUri, this.numTypeParameters: 0}); | 10307 {this.absoluteUri, this.numTypeParameters: 0}); |
10365 } | 10308 } |
OLD | NEW |