| 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 (function() { | 5 (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 let dart_sdk = dart_library.import('dart_sdk'); | 8 let dart_sdk = dart_library.import('dart_sdk'); |
| 9 dart_sdk._isolate_helper.startRootIsolate(function() {}, []); | 9 dart_sdk._isolate_helper.startRootIsolate(function() {}, []); |
| 10 let async_helper = dart_library.import('async_helper').async_helper; | 10 let async_helper = dart_library.import('async_helper').async_helper; |
| 11 | 11 |
| 12 // Test attributes are a list of strings, or a string for a single | 12 // Test attributes are a list of strings, or a string for a single |
| 13 // attribute. Valid attribues are: | 13 // attribute. Valid attribues are: |
| 14 // | 14 // |
| 15 // 'skip' - don't run the test | 15 // 'skip' - don't run the test |
| 16 // 'fail' - test fails | 16 // 'fail' - test fails |
| 17 // 'timeout' - test times out | 17 // 'timeout' - test times out |
| 18 // 'slow' - use 5s timeout instead of default 2s. |
| 18 // 'helper' - not a test, used by other tests. | 19 // 'helper' - not a test, used by other tests. |
| 19 // 'unittest' - run separately as a unittest test. | 20 // 'unittest' - run separately as a unittest test. |
| 20 // | 21 // |
| 21 // Common combinations: | 22 // Common combinations: |
| 22 const fail = 'fail'; | 23 const fail = 'fail'; |
| 23 const skip_fail = ['skip', 'fail']; | 24 const skip_fail = ['skip', 'fail']; |
| 24 const skip_timeout = ['skip', 'timeout']; | 25 const skip_timeout = ['skip', 'timeout']; |
| 25 | 26 |
| 26 // TODO(jmesserly): separate StrongModeError from other errors. | 27 // TODO(jmesserly): separate StrongModeError from other errors. |
| 27 let all_status = { | 28 let all_status = { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 'from_environment_const_type_undefined_test_none_multi': skip_fail, // co
nstructor throws | 408 'from_environment_const_type_undefined_test_none_multi': skip_fail, // co
nstructor throws |
| 408 'hash_map2_test': skip_timeout, | 409 'hash_map2_test': skip_timeout, |
| 409 'hash_set_test_01_multi': fail, | 410 'hash_set_test_01_multi': fail, |
| 410 'hidden_library2_test_01_multi': fail, | 411 'hidden_library2_test_01_multi': fail, |
| 411 'indexed_list_access_test': fail, | 412 'indexed_list_access_test': fail, |
| 412 'int_from_environment2_test': fail, | 413 'int_from_environment2_test': fail, |
| 413 'int_from_environment_test': fail, | 414 'int_from_environment_test': fail, |
| 414 'int_modulo_arith_test_bignum_multi': fail, | 415 'int_modulo_arith_test_bignum_multi': fail, |
| 415 'int_modulo_arith_test_modPow_multi': fail, | 416 'int_modulo_arith_test_modPow_multi': fail, |
| 416 'int_modulo_arith_test_none_multi': fail, | 417 'int_modulo_arith_test_none_multi': fail, |
| 418 'int_parse_radix_test_01_multi': fail, // JS implementations disagree on U
+0085 being whitespace. |
| 419 'int_parse_radix_test_02_multi': ['fail', 'timeout', 'skip'], // No bigint
s. |
| 420 'int_parse_radix_test_none_multi': ['slow'], |
| 417 'integer_to_radix_string_test': fail, | 421 'integer_to_radix_string_test': fail, |
| 418 'integer_to_string_test_01_multi': fail, | 422 'integer_to_string_test_01_multi': fail, |
| 419 'iterable_generate_test': fail, | 423 'iterable_generate_test': fail, |
| 420 'iterable_return_type_test_01_multi': fail, | 424 'iterable_return_type_test_01_multi': fail, |
| 421 'iterable_return_type_test_02_multi': fail, | 425 'iterable_return_type_test_02_multi': fail, |
| 422 'iterable_return_type_test_none_multi': fail, | 426 'iterable_return_type_test_none_multi': fail, |
| 423 'json_map_test': fail, | 427 'json_map_test': fail, |
| 424 'list_fill_range_test': fail, | 428 'list_fill_range_test': fail, |
| 425 'list_replace_range_test': fail, | 429 'list_replace_range_test': fail, |
| 426 'list_set_all_test': fail, | 430 'list_set_all_test': fail, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 // A few tests are special because they use package:unittest. | 514 // A few tests are special because they use package:unittest. |
| 511 // We run them below. | 515 // We run them below. |
| 512 if (has('unittest')) { | 516 if (has('unittest')) { |
| 513 unittest_tests.push(() => { | 517 unittest_tests.push(() => { |
| 514 console.log('Running unittest test ' + testFile); | 518 console.log('Running unittest test ' + testFile); |
| 515 dart_library.import(module)[name].main(); | 519 dart_library.import(module)[name].main(); |
| 516 }); | 520 }); |
| 517 continue; | 521 continue; |
| 518 } | 522 } |
| 519 | 523 |
| 520 test(name, (done) => { | 524 function protect(f) { // Returns the exception, or `null`. |
| 525 try { |
| 526 f(); |
| 527 return null; |
| 528 } catch (e) { |
| 529 return e; |
| 530 }; |
| 531 } |
| 532 |
| 533 test(name, function(done) { // 'function' to allow `this.timeout`. |
| 521 async_helper.asyncTestInitialize(done); | 534 async_helper.asyncTestInitialize(done); |
| 522 console.debug('Running test: ' + name); | 535 console.debug('Running test: ' + name); |
| 523 | 536 |
| 524 let mainLibrary = dart_library.import(module)[name]; | 537 let mainLibrary = dart_library.import(module)[name]; |
| 525 let negative = /negative_test/.test(name); | 538 let negative = /negative_test/.test(name); |
| 526 if (has('fail')) negative = !negative; | 539 if (has('slow')) this.timeout(5000); |
| 527 if (negative) { | 540 if (has('fail')) { |
| 528 assert.throws(mainLibrary.main); | 541 let e = protect(mainLibrary.main); |
| 542 if (negative) { |
| 543 if (e != null) { |
| 544 throw new Error( |
| 545 "negative test marked as 'fail' " + |
| 546 "but passed by throwing:\n" + e); |
| 547 } |
| 548 } else { |
| 549 if (e == null) { |
| 550 throw new Error("test marked as 'fail' but passed"); |
| 551 } |
| 552 } |
| 529 } else { | 553 } else { |
| 530 mainLibrary.main(); | 554 if (negative) { |
| 555 assert.throws(mainLibrary.main); |
| 556 } else { |
| 557 mainLibrary.main(); |
| 558 } |
| 531 } | 559 } |
| 532 | 560 |
| 533 if (!async_helper.asyncTestStarted) done(); | 561 if (!async_helper.asyncTestStarted) done(); |
| 534 }); | 562 }); |
| 535 } | 563 } |
| 536 } | 564 } |
| 537 | 565 |
| 538 for (let action of unittest_tests) { | 566 for (let action of unittest_tests) { |
| 539 action(); | 567 action(); |
| 540 } | 568 } |
| 541 })(); | 569 })(); |
| OLD | NEW |