| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.all_the_rest_test; | 8 library engine.all_the_rest_test; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 7324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7335 | 7335 |
| 7336 void test_whileStatement_true_throw() { | 7336 void test_whileStatement_true_throw() { |
| 7337 _assertTrue("{ while (true) { throw ''; } }"); | 7337 _assertTrue("{ while (true) { throw ''; } }"); |
| 7338 } | 7338 } |
| 7339 | 7339 |
| 7340 void _assertFalse(String source) { | 7340 void _assertFalse(String source) { |
| 7341 _assertHasReturn(false, source); | 7341 _assertHasReturn(false, source); |
| 7342 } | 7342 } |
| 7343 | 7343 |
| 7344 void _assertHasReturn(bool expectedResult, String source) { | 7344 void _assertHasReturn(bool expectedResult, String source) { |
| 7345 ExitDetector detector = new ExitDetector(); | |
| 7346 Statement statement = ParserTestCase.parseStatement(source); | 7345 Statement statement = ParserTestCase.parseStatement(source); |
| 7347 expect(statement.accept(detector), same(expectedResult)); | 7346 expect(ExitDetector.exits(statement), expectedResult); |
| 7348 } | 7347 } |
| 7349 | 7348 |
| 7350 void _assertTrue(String source) { | 7349 void _assertTrue(String source) { |
| 7351 _assertHasReturn(true, source); | 7350 _assertHasReturn(true, source); |
| 7352 } | 7351 } |
| 7353 } | 7352 } |
| 7354 | 7353 |
| 7355 /** | 7354 /** |
| 7356 * Tests for the [ExitDetector] that require that the AST be resolved. | 7355 * Tests for the [ExitDetector] that require that the AST be resolved. |
| 7357 * | 7356 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 7371 x = 'B'; | 7370 x = 'B'; |
| 7372 } | 7371 } |
| 7373 return x; | 7372 return x; |
| 7374 } | 7373 } |
| 7375 '''); | 7374 '''); |
| 7376 LibraryElement element = resolve(source); | 7375 LibraryElement element = resolve(source); |
| 7377 CompilationUnit unit = resolveCompilationUnit(source, element); | 7376 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7378 FunctionDeclaration function = unit.declarations.last; | 7377 FunctionDeclaration function = unit.declarations.last; |
| 7379 BlockFunctionBody body = function.functionExpression.body; | 7378 BlockFunctionBody body = function.functionExpression.body; |
| 7380 Statement statement = body.block.statements[1]; | 7379 Statement statement = body.block.statements[1]; |
| 7381 expect(statement.accept(new ExitDetector()), false); | 7380 expect(ExitDetector.exits(statement), false); |
| 7382 } | 7381 } |
| 7383 | 7382 |
| 7384 void test_switch_withEnum_false_withDefault() { | 7383 void test_switch_withEnum_false_withDefault() { |
| 7385 Source source = addSource(r''' | 7384 Source source = addSource(r''' |
| 7386 enum E { A, B } | 7385 enum E { A, B } |
| 7387 String f(E e) { | 7386 String f(E e) { |
| 7388 var x; | 7387 var x; |
| 7389 switch (e) { | 7388 switch (e) { |
| 7390 case A: | 7389 case A: |
| 7391 x = 'A'; | 7390 x = 'A'; |
| 7392 default: | 7391 default: |
| 7393 x = '?'; | 7392 x = '?'; |
| 7394 } | 7393 } |
| 7395 return x; | 7394 return x; |
| 7396 } | 7395 } |
| 7397 '''); | 7396 '''); |
| 7398 LibraryElement element = resolve(source); | 7397 LibraryElement element = resolve(source); |
| 7399 CompilationUnit unit = resolveCompilationUnit(source, element); | 7398 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7400 FunctionDeclaration function = unit.declarations.last; | 7399 FunctionDeclaration function = unit.declarations.last; |
| 7401 BlockFunctionBody body = function.functionExpression.body; | 7400 BlockFunctionBody body = function.functionExpression.body; |
| 7402 Statement statement = body.block.statements[1]; | 7401 Statement statement = body.block.statements[1]; |
| 7403 expect(statement.accept(new ExitDetector()), false); | 7402 expect(ExitDetector.exits(statement), false); |
| 7404 } | 7403 } |
| 7405 | 7404 |
| 7406 void test_switch_withEnum_true_noDefault() { | 7405 void test_switch_withEnum_true_noDefault() { |
| 7407 Source source = addSource(r''' | 7406 Source source = addSource(r''' |
| 7408 enum E { A, B } | 7407 enum E { A, B } |
| 7409 String f(E e) { | 7408 String f(E e) { |
| 7410 switch (e) { | 7409 switch (e) { |
| 7411 case A: | 7410 case A: |
| 7412 return 'A'; | 7411 return 'A'; |
| 7413 case B: | 7412 case B: |
| 7414 return 'B'; | 7413 return 'B'; |
| 7415 } | 7414 } |
| 7416 } | 7415 } |
| 7417 '''); | 7416 '''); |
| 7418 LibraryElement element = resolve(source); | 7417 LibraryElement element = resolve(source); |
| 7419 CompilationUnit unit = resolveCompilationUnit(source, element); | 7418 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7420 FunctionDeclaration function = unit.declarations.last; | 7419 FunctionDeclaration function = unit.declarations.last; |
| 7421 BlockFunctionBody body = function.functionExpression.body; | 7420 BlockFunctionBody body = function.functionExpression.body; |
| 7422 Statement statement = body.block.statements[0]; | 7421 Statement statement = body.block.statements[0]; |
| 7423 expect(statement.accept(new ExitDetector()), true); | 7422 expect(ExitDetector.exits(statement), true); |
| 7424 } | 7423 } |
| 7425 | 7424 |
| 7426 void test_switch_withEnum_true_withDefault() { | 7425 void test_switch_withEnum_true_withDefault() { |
| 7427 Source source = addSource(r''' | 7426 Source source = addSource(r''' |
| 7428 enum E { A, B } | 7427 enum E { A, B } |
| 7429 String f(E e) { | 7428 String f(E e) { |
| 7430 switch (e) { | 7429 switch (e) { |
| 7431 case A: | 7430 case A: |
| 7432 return 'A'; | 7431 return 'A'; |
| 7433 default: | 7432 default: |
| 7434 return '?'; | 7433 return '?'; |
| 7435 } | 7434 } |
| 7436 } | 7435 } |
| 7437 '''); | 7436 '''); |
| 7438 LibraryElement element = resolve(source); | 7437 LibraryElement element = resolve(source); |
| 7439 CompilationUnit unit = resolveCompilationUnit(source, element); | 7438 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7440 FunctionDeclaration function = unit.declarations.last; | 7439 FunctionDeclaration function = unit.declarations.last; |
| 7441 BlockFunctionBody body = function.functionExpression.body; | 7440 BlockFunctionBody body = function.functionExpression.body; |
| 7442 Statement statement = body.block.statements[0]; | 7441 Statement statement = body.block.statements[0]; |
| 7443 expect(statement.accept(new ExitDetector()), true); | 7442 expect(ExitDetector.exits(statement), true); |
| 7444 } | 7443 } |
| 7445 } | 7444 } |
| 7446 | 7445 |
| 7447 | 7446 |
| 7448 @reflectiveTest | 7447 @reflectiveTest |
| 7449 class FileBasedSourceTest { | 7448 class FileBasedSourceTest { |
| 7450 void test_equals_false_differentFiles() { | 7449 void test_equals_false_differentFiles() { |
| 7451 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); | 7450 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); |
| 7452 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); | 7451 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); |
| 7453 FileBasedSource source1 = new FileBasedSource.con1(file1); | 7452 FileBasedSource source1 = new FileBasedSource.con1(file1); |
| (...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8974 } else { | 8973 } else { |
| 8975 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); | 8974 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); |
| 8976 String actualExternalScriptName = scriptSource.shortName; | 8975 String actualExternalScriptName = scriptSource.shortName; |
| 8977 expect( | 8976 expect( |
| 8978 actualExternalScriptName, | 8977 actualExternalScriptName, |
| 8979 _expectedExternalScriptName, | 8978 _expectedExternalScriptName, |
| 8980 reason: "script $scriptIndex"); | 8979 reason: "script $scriptIndex"); |
| 8981 } | 8980 } |
| 8982 } | 8981 } |
| 8983 } | 8982 } |
| OLD | NEW |