| 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 6831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6842 same(ErrorSeverity.WARNING)); | 6842 same(ErrorSeverity.WARNING)); |
| 6843 } | 6843 } |
| 6844 | 6844 |
| 6845 void test_max_warning_warning() { | 6845 void test_max_warning_warning() { |
| 6846 expect( | 6846 expect( |
| 6847 ErrorSeverity.WARNING.max(ErrorSeverity.WARNING), | 6847 ErrorSeverity.WARNING.max(ErrorSeverity.WARNING), |
| 6848 same(ErrorSeverity.WARNING)); | 6848 same(ErrorSeverity.WARNING)); |
| 6849 } | 6849 } |
| 6850 } | 6850 } |
| 6851 | 6851 |
| 6852 | 6852 /** |
| 6853 * Tests for the [ExitDetector] that do not require that the AST be resolved. |
| 6854 * |
| 6855 * See [ExitDetectorTest2] for tests that require the AST to be resolved. |
| 6856 */ |
| 6853 @reflectiveTest | 6857 @reflectiveTest |
| 6854 class ExitDetectorTest extends ParserTestCase { | 6858 class ExitDetectorTest extends ParserTestCase { |
| 6855 void fail_doStatement_continue_with_label() { | 6859 void fail_doStatement_continue_with_label() { |
| 6856 _assertFalse("{ x: do { continue x; } while(true); }"); | 6860 _assertFalse("{ x: do { continue x; } while(true); }"); |
| 6857 } | 6861 } |
| 6858 | 6862 |
| 6859 void fail_whileStatement_continue_with_label() { | 6863 void fail_whileStatement_continue_with_label() { |
| 6860 _assertFalse("{ x: while (true) { continue x; } }"); | 6864 _assertFalse("{ x: while (true) { continue x; } }"); |
| 6861 } | 6865 } |
| 6862 | 6866 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7340 ExitDetector detector = new ExitDetector(); | 7344 ExitDetector detector = new ExitDetector(); |
| 7341 Statement statement = ParserTestCase.parseStatement(source); | 7345 Statement statement = ParserTestCase.parseStatement(source); |
| 7342 expect(statement.accept(detector), same(expectedResult)); | 7346 expect(statement.accept(detector), same(expectedResult)); |
| 7343 } | 7347 } |
| 7344 | 7348 |
| 7345 void _assertTrue(String source) { | 7349 void _assertTrue(String source) { |
| 7346 _assertHasReturn(true, source); | 7350 _assertHasReturn(true, source); |
| 7347 } | 7351 } |
| 7348 } | 7352 } |
| 7349 | 7353 |
| 7354 /** |
| 7355 * Tests for the [ExitDetector] that require that the AST be resolved. |
| 7356 * |
| 7357 * See [ExitDetectorTest] for tests that do not require the AST to be resolved. |
| 7358 */ |
| 7359 @reflectiveTest |
| 7360 class ExitDetectorTest2 extends ResolverTestCase { |
| 7361 void test_switch_withEnum_false_noDefault() { |
| 7362 Source source = addSource(r''' |
| 7363 enum E { A, B } |
| 7364 String f(E e) { |
| 7365 var x; |
| 7366 switch (e) { |
| 7367 case A: |
| 7368 x = 'A'; |
| 7369 case B: |
| 7370 x = 'B'; |
| 7371 } |
| 7372 return x; |
| 7373 } |
| 7374 '''); |
| 7375 LibraryElement element = resolve(source); |
| 7376 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7377 FunctionDeclaration function = unit.declarations.last; |
| 7378 BlockFunctionBody body = function.functionExpression.body; |
| 7379 Statement statement = body.block.statements[1]; |
| 7380 expect(statement.accept(new ExitDetector()), false); |
| 7381 } |
| 7382 |
| 7383 void test_switch_withEnum_false_withDefault() { |
| 7384 Source source = addSource(r''' |
| 7385 enum E { A, B } |
| 7386 String f(E e) { |
| 7387 var x; |
| 7388 switch (e) { |
| 7389 case A: |
| 7390 x = 'A'; |
| 7391 default: |
| 7392 x = '?'; |
| 7393 } |
| 7394 return x; |
| 7395 } |
| 7396 '''); |
| 7397 LibraryElement element = resolve(source); |
| 7398 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7399 FunctionDeclaration function = unit.declarations.last; |
| 7400 BlockFunctionBody body = function.functionExpression.body; |
| 7401 Statement statement = body.block.statements[1]; |
| 7402 expect(statement.accept(new ExitDetector()), false); |
| 7403 } |
| 7404 |
| 7405 void test_switch_withEnum_true_noDefault() { |
| 7406 Source source = addSource(r''' |
| 7407 enum E { A, B } |
| 7408 String f(E e) { |
| 7409 switch (e) { |
| 7410 case A: |
| 7411 return 'A'; |
| 7412 case B: |
| 7413 return 'B'; |
| 7414 } |
| 7415 } |
| 7416 '''); |
| 7417 LibraryElement element = resolve(source); |
| 7418 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7419 FunctionDeclaration function = unit.declarations.last; |
| 7420 BlockFunctionBody body = function.functionExpression.body; |
| 7421 Statement statement = body.block.statements[0]; |
| 7422 expect(statement.accept(new ExitDetector()), true); |
| 7423 } |
| 7424 |
| 7425 void test_switch_withEnum_true_withDefault() { |
| 7426 Source source = addSource(r''' |
| 7427 enum E { A, B } |
| 7428 String f(E e) { |
| 7429 switch (e) { |
| 7430 case A: |
| 7431 return 'A'; |
| 7432 default: |
| 7433 return '?'; |
| 7434 } |
| 7435 } |
| 7436 '''); |
| 7437 LibraryElement element = resolve(source); |
| 7438 CompilationUnit unit = resolveCompilationUnit(source, element); |
| 7439 FunctionDeclaration function = unit.declarations.last; |
| 7440 BlockFunctionBody body = function.functionExpression.body; |
| 7441 Statement statement = body.block.statements[0]; |
| 7442 expect(statement.accept(new ExitDetector()), true); |
| 7443 } |
| 7444 } |
| 7445 |
| 7350 | 7446 |
| 7351 @reflectiveTest | 7447 @reflectiveTest |
| 7352 class FileBasedSourceTest { | 7448 class FileBasedSourceTest { |
| 7353 void test_equals_false_differentFiles() { | 7449 void test_equals_false_differentFiles() { |
| 7354 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); | 7450 JavaFile file1 = FileUtilities2.createFile("/does/not/exist1.dart"); |
| 7355 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); | 7451 JavaFile file2 = FileUtilities2.createFile("/does/not/exist2.dart"); |
| 7356 FileBasedSource source1 = new FileBasedSource.con1(file1); | 7452 FileBasedSource source1 = new FileBasedSource.con1(file1); |
| 7357 FileBasedSource source2 = new FileBasedSource.con1(file2); | 7453 FileBasedSource source2 = new FileBasedSource.con1(file2); |
| 7358 expect(source1 == source2, isFalse); | 7454 expect(source1 == source2, isFalse); |
| 7359 } | 7455 } |
| 7360 | 7456 |
| 7361 void test_equals_false_null() { | 7457 void test_equals_false_null() { |
| 7362 JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart"); | 7458 JavaFile file = FileUtilities2.createFile("/does/not/exist1.dart"); |
| 7363 FileBasedSource source1 = new FileBasedSource.con1(file); | 7459 FileBasedSource source1 = new FileBasedSource.con1(file); |
| 7364 expect(source1 == null, isFalse); | 7460 expect(source1 == null, isFalse); |
| 7365 } | 7461 } |
| 7366 | 7462 |
| 7367 void test_equals_true() { | 7463 void test_equals_true() { |
| 7368 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart"); | 7464 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart"); |
| 7369 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart"); | 7465 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart"); |
| 7370 FileBasedSource source1 = new FileBasedSource.con1(file1); | 7466 FileBasedSource source1 = new FileBasedSource.con1(file1); |
| 7371 FileBasedSource source2 = new FileBasedSource.con1(file2); | 7467 FileBasedSource source2 = new FileBasedSource.con1(file2); |
| 7372 expect(source1 == source2, isTrue); | 7468 expect(source1 == source2, isTrue); |
| 7373 } | 7469 } |
| 7374 | 7470 |
| 7375 void test_getEncoding() { | |
| 7376 SourceFactory factory = new SourceFactory([new FileUriResolver()]); | |
| 7377 String fullPath = "/does/not/exist.dart"; | |
| 7378 JavaFile file = FileUtilities2.createFile(fullPath); | |
| 7379 FileBasedSource source = new FileBasedSource.con1(file); | |
| 7380 expect(factory.fromEncoding(source.encoding), source); | |
| 7381 } | |
| 7382 | |
| 7383 void test_getFullName() { | |
| 7384 String fullPath = "/does/not/exist.dart"; | |
| 7385 JavaFile file = FileUtilities2.createFile(fullPath); | |
| 7386 FileBasedSource source = new FileBasedSource.con1(file); | |
| 7387 expect(source.fullName, file.getAbsolutePath()); | |
| 7388 } | |
| 7389 | |
| 7390 void test_getShortName() { | |
| 7391 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); | |
| 7392 FileBasedSource source = new FileBasedSource.con1(file); | |
| 7393 expect(source.shortName, "exist.dart"); | |
| 7394 } | |
| 7395 | |
| 7396 void test_fileReadMode() { | 7471 void test_fileReadMode() { |
| 7397 expect(FileBasedSource.fileReadMode('a'), 'a'); | 7472 expect(FileBasedSource.fileReadMode('a'), 'a'); |
| 7398 expect(FileBasedSource.fileReadMode('a\n'), 'a\n'); | 7473 expect(FileBasedSource.fileReadMode('a\n'), 'a\n'); |
| 7399 expect(FileBasedSource.fileReadMode('ab'), 'ab'); | 7474 expect(FileBasedSource.fileReadMode('ab'), 'ab'); |
| 7400 expect(FileBasedSource.fileReadMode('abc'), 'abc'); | 7475 expect(FileBasedSource.fileReadMode('abc'), 'abc'); |
| 7401 expect(FileBasedSource.fileReadMode('a\nb'), 'a\nb'); | 7476 expect(FileBasedSource.fileReadMode('a\nb'), 'a\nb'); |
| 7402 expect(FileBasedSource.fileReadMode('a\rb'), 'a\rb'); | 7477 expect(FileBasedSource.fileReadMode('a\rb'), 'a\rb'); |
| 7403 expect(FileBasedSource.fileReadMode('a\r\nb'), 'a\r\nb'); | 7478 expect(FileBasedSource.fileReadMode('a\r\nb'), 'a\r\nb'); |
| 7404 } | 7479 } |
| 7405 | 7480 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 7428 expect(FileBasedSource.fileReadMode('\r\na'), '\na'); | 7503 expect(FileBasedSource.fileReadMode('\r\na'), '\na'); |
| 7429 | 7504 |
| 7430 // '\r' -> '\n' as first, last and only character | 7505 // '\r' -> '\n' as first, last and only character |
| 7431 expect(FileBasedSource.fileReadMode('\r'), '\n'); | 7506 expect(FileBasedSource.fileReadMode('\r'), '\n'); |
| 7432 expect(FileBasedSource.fileReadMode('a\r'), 'a\n'); | 7507 expect(FileBasedSource.fileReadMode('a\r'), 'a\n'); |
| 7433 expect(FileBasedSource.fileReadMode('\ra'), '\na'); | 7508 expect(FileBasedSource.fileReadMode('\ra'), '\na'); |
| 7434 | 7509 |
| 7435 FileBasedSource.fileReadMode = (String s) => s; | 7510 FileBasedSource.fileReadMode = (String s) => s; |
| 7436 } | 7511 } |
| 7437 | 7512 |
| 7513 void test_getEncoding() { |
| 7514 SourceFactory factory = new SourceFactory([new FileUriResolver()]); |
| 7515 String fullPath = "/does/not/exist.dart"; |
| 7516 JavaFile file = FileUtilities2.createFile(fullPath); |
| 7517 FileBasedSource source = new FileBasedSource.con1(file); |
| 7518 expect(factory.fromEncoding(source.encoding), source); |
| 7519 } |
| 7520 |
| 7521 void test_getFullName() { |
| 7522 String fullPath = "/does/not/exist.dart"; |
| 7523 JavaFile file = FileUtilities2.createFile(fullPath); |
| 7524 FileBasedSource source = new FileBasedSource.con1(file); |
| 7525 expect(source.fullName, file.getAbsolutePath()); |
| 7526 } |
| 7527 |
| 7528 void test_getShortName() { |
| 7529 JavaFile file = FileUtilities2.createFile("/does/not/exist.dart"); |
| 7530 FileBasedSource source = new FileBasedSource.con1(file); |
| 7531 expect(source.shortName, "exist.dart"); |
| 7532 } |
| 7533 |
| 7438 void test_hashCode() { | 7534 void test_hashCode() { |
| 7439 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart"); | 7535 JavaFile file1 = FileUtilities2.createFile("/does/not/exist.dart"); |
| 7440 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart"); | 7536 JavaFile file2 = FileUtilities2.createFile("/does/not/exist.dart"); |
| 7441 FileBasedSource source1 = new FileBasedSource.con1(file1); | 7537 FileBasedSource source1 = new FileBasedSource.con1(file1); |
| 7442 FileBasedSource source2 = new FileBasedSource.con1(file2); | 7538 FileBasedSource source2 = new FileBasedSource.con1(file2); |
| 7443 expect(source2.hashCode, source1.hashCode); | 7539 expect(source2.hashCode, source1.hashCode); |
| 7444 } | 7540 } |
| 7445 | 7541 |
| 7446 void test_isInSystemLibrary_contagious() { | 7542 void test_isInSystemLibrary_contagious() { |
| 7447 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; | 7543 JavaFile sdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8877 } else { | 8973 } else { |
| 8878 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); | 8974 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); |
| 8879 String actualExternalScriptName = scriptSource.shortName; | 8975 String actualExternalScriptName = scriptSource.shortName; |
| 8880 expect( | 8976 expect( |
| 8881 actualExternalScriptName, | 8977 actualExternalScriptName, |
| 8882 _expectedExternalScriptName, | 8978 _expectedExternalScriptName, |
| 8883 reason: "script $scriptIndex"); | 8979 reason: "script $scriptIndex"); |
| 8884 } | 8980 } |
| 8885 } | 8981 } |
| 8886 } | 8982 } |
| OLD | NEW |