OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.all_the_rest_test; | 5 library analyzer.test.generated.all_the_rest_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 3944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3955 return; | 3955 return; |
3956 if (1 < 2) { | 3956 if (1 < 2) { |
3957 break x; | 3957 break x; |
3958 } | 3958 } |
3959 } | 3959 } |
3960 } | 3960 } |
3961 '''); | 3961 '''); |
3962 _assertNthStatementExits(source, 0); | 3962 _assertNthStatementExits(source, 0); |
3963 } | 3963 } |
3964 | 3964 |
3965 void _assertHasReturn(bool expectedResult, String source, int n) { | 3965 void _assertHasReturn(bool expectedResult, Source source, int n) { |
3966 LibraryElement element = resolve2(source); | 3966 LibraryElement element = resolve2(source); |
3967 CompilationUnit unit = resolveCompilationUnit(source, element); | 3967 CompilationUnit unit = resolveCompilationUnit(source, element); |
3968 FunctionDeclaration function = unit.declarations.last; | 3968 FunctionDeclaration function = unit.declarations.last; |
3969 BlockFunctionBody body = function.functionExpression.body; | 3969 BlockFunctionBody body = function.functionExpression.body; |
3970 Statement statement = body.block.statements[n]; | 3970 Statement statement = body.block.statements[n]; |
3971 expect(ExitDetector.exits(statement), expectedResult); | 3971 expect(ExitDetector.exits(statement), expectedResult); |
3972 } | 3972 } |
3973 | 3973 |
3974 // Assert that the [n]th statement in the last function declaration of | 3974 // Assert that the [n]th statement in the last function declaration of |
3975 // [source] exits. | 3975 // [source] exits. |
3976 void _assertNthStatementExits(String source, int n) { | 3976 void _assertNthStatementExits(Source source, int n) { |
3977 _assertHasReturn(true, source, n); | 3977 _assertHasReturn(true, source, n); |
3978 } | 3978 } |
3979 | 3979 |
3980 // Assert that the [n]th statement in the last function declaration of | 3980 // Assert that the [n]th statement in the last function declaration of |
3981 // [source] does not exit. | 3981 // [source] does not exit. |
3982 void _assertNthStatementDoesNotExit(String source, int n) { | 3982 void _assertNthStatementDoesNotExit(Source source, int n) { |
3983 _assertHasReturn(false, source, n); | 3983 _assertHasReturn(false, source, n); |
3984 } | 3984 } |
3985 } | 3985 } |
3986 | 3986 |
3987 @reflectiveTest | 3987 @reflectiveTest |
3988 class FileBasedSourceTest { | 3988 class FileBasedSourceTest { |
3989 void test_equals_false_differentFiles() { | 3989 void test_equals_false_differentFiles() { |
3990 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); | 3990 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); |
3991 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); | 3991 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); |
3992 FileBasedSource source1 = new FileBasedSource(file1); | 3992 FileBasedSource source1 = new FileBasedSource(file1); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4355 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); | 4355 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); |
4356 expect(UriKind.fromEncoding(0x58), same(null)); | 4356 expect(UriKind.fromEncoding(0x58), same(null)); |
4357 } | 4357 } |
4358 | 4358 |
4359 void test_getEncoding() { | 4359 void test_getEncoding() { |
4360 expect(UriKind.DART_URI.encoding, 0x64); | 4360 expect(UriKind.DART_URI.encoding, 0x64); |
4361 expect(UriKind.FILE_URI.encoding, 0x66); | 4361 expect(UriKind.FILE_URI.encoding, 0x66); |
4362 expect(UriKind.PACKAGE_URI.encoding, 0x70); | 4362 expect(UriKind.PACKAGE_URI.encoding, 0x70); |
4363 } | 4363 } |
4364 } | 4364 } |
OLD | NEW |