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

Unified Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 885283007: Fix for issue 22110 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/all_the_rest_test.dart
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index 7199b94b0bf4f940bf098e5e5e7c4f441358521b..aa5ea74244a37f201518adb84cdd063ad55973c0 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -6849,7 +6849,11 @@ class ErrorSeverityTest extends EngineTestCase {
}
}
-
+/**
+ * Tests for the [ExitDetector] that do not require that the AST be resolved.
+ *
+ * See [ExitDetectorTest2] for tests that require the AST to be resolved.
+ */
@reflectiveTest
class ExitDetectorTest extends ParserTestCase {
void fail_doStatement_continue_with_label() {
@@ -7347,6 +7351,98 @@ class ExitDetectorTest extends ParserTestCase {
}
}
+/**
+ * Tests for the [ExitDetector] that require that the AST be resolved.
+ *
+ * See [ExitDetectorTest] for tests that do not require the AST to be resolved.
+ */
+@reflectiveTest
+class ExitDetectorTest2 extends ResolverTestCase {
+ void test_switch_withEnum_false_noDefault() {
+ Source source = addSource(r'''
+enum E { A, B }
+String f(E e) {
+ var x;
+ switch (e) {
+ case A:
+ x = 'A';
+ case B:
+ x = 'B';
+ }
+ return x;
+}
+''');
+ LibraryElement element = resolve(source);
+ CompilationUnit unit = resolveCompilationUnit(source, element);
+ FunctionDeclaration function = unit.declarations.last;
+ BlockFunctionBody body = function.functionExpression.body;
+ Statement statement = body.block.statements[1];
+ expect(statement.accept(new ExitDetector()), false);
+ }
+
+ void test_switch_withEnum_false_withDefault() {
+ Source source = addSource(r'''
+enum E { A, B }
+String f(E e) {
+ var x;
+ switch (e) {
+ case A:
+ x = 'A';
+ default:
+ x = '?';
+ }
+ return x;
+}
+''');
+ LibraryElement element = resolve(source);
+ CompilationUnit unit = resolveCompilationUnit(source, element);
+ FunctionDeclaration function = unit.declarations.last;
+ BlockFunctionBody body = function.functionExpression.body;
+ Statement statement = body.block.statements[1];
+ expect(statement.accept(new ExitDetector()), false);
+ }
+
+ void test_switch_withEnum_true_noDefault() {
+ Source source = addSource(r'''
+enum E { A, B }
+String f(E e) {
+ switch (e) {
+ case A:
+ return 'A';
+ case B:
+ return 'B';
+ }
+}
+''');
+ LibraryElement element = resolve(source);
+ CompilationUnit unit = resolveCompilationUnit(source, element);
+ FunctionDeclaration function = unit.declarations.last;
+ BlockFunctionBody body = function.functionExpression.body;
+ Statement statement = body.block.statements[0];
+ expect(statement.accept(new ExitDetector()), true);
+ }
+
+ void test_switch_withEnum_true_withDefault() {
+ Source source = addSource(r'''
+enum E { A, B }
+String f(E e) {
+ switch (e) {
+ case A:
+ return 'A';
+ default:
+ return '?';
+ }
+}
+''');
+ LibraryElement element = resolve(source);
+ CompilationUnit unit = resolveCompilationUnit(source, element);
+ FunctionDeclaration function = unit.declarations.last;
+ BlockFunctionBody body = function.functionExpression.body;
+ Statement statement = body.block.statements[0];
+ expect(statement.accept(new ExitDetector()), true);
+ }
+}
+
@reflectiveTest
class FileBasedSourceTest {
@@ -7372,27 +7468,6 @@ class FileBasedSourceTest {
expect(source1 == source2, isTrue);
}
- void test_getEncoding() {
- SourceFactory factory = new SourceFactory([new FileUriResolver()]);
- String fullPath = "/does/not/exist.dart";
- JavaFile file = FileUtilities2.createFile(fullPath);
- FileBasedSource source = new FileBasedSource.con1(file);
- expect(factory.fromEncoding(source.encoding), source);
- }
-
- void test_getFullName() {
- String fullPath = "/does/not/exist.dart";
- JavaFile file = FileUtilities2.createFile(fullPath);
- FileBasedSource source = new FileBasedSource.con1(file);
- expect(source.fullName, file.getAbsolutePath());
- }
-
- void test_getShortName() {
- JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
- FileBasedSource source = new FileBasedSource.con1(file);
- expect(source.shortName, "exist.dart");
- }
-
void test_fileReadMode() {
expect(FileBasedSource.fileReadMode('a'), 'a');
expect(FileBasedSource.fileReadMode('a\n'), 'a\n');
@@ -7435,6 +7510,27 @@ class FileBasedSourceTest {
FileBasedSource.fileReadMode = (String s) => s;
}
+ void test_getEncoding() {
+ SourceFactory factory = new SourceFactory([new FileUriResolver()]);
+ String fullPath = "/does/not/exist.dart";
+ JavaFile file = FileUtilities2.createFile(fullPath);
+ FileBasedSource source = new FileBasedSource.con1(file);
+ expect(factory.fromEncoding(source.encoding), source);
+ }
+
+ void test_getFullName() {
+ String fullPath = "/does/not/exist.dart";
+ JavaFile file = FileUtilities2.createFile(fullPath);
+ FileBasedSource source = new FileBasedSource.con1(file);
+ expect(source.fullName, file.getAbsolutePath());
+ }
+
+ void test_getShortName() {
+ JavaFile file = FileUtilities2.createFile("/does/not/exist.dart");
+ FileBasedSource source = new FileBasedSource.con1(file);
+ expect(source.shortName, "exist.dart");
+ }
+
void test_hashCode() {
JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart");
JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart");
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698