diff --git runtime/parrot/include/test_more.pir runtime/parrot/include/test_more.pir
index 318828b..3afbf74 100644
|
|
|
|
| 20 | 20 | .local pmc exports, curr_namespace, test_namespace |
| 21 | 21 | curr_namespace = get_namespace |
| 22 | 22 | test_namespace = get_root_namespace [ 'parrot'; 'Test'; 'More' ] |
| 23 | | exports = split ' ', 'plan diag ok nok is is_deeply like substring isa_ok skip isnt todo throws_like throws_substring' |
| | 23 | exports = split ' ', 'plan diag ok nok is is_deeply like substring isa_ok skip isnt todo throws_like lives_ok throws_substring' |
| 24 | 24 | |
| 25 | 25 | test_namespace.'export_to'(curr_namespace, exports) |
| 26 | 26 | |
diff --git runtime/parrot/library/Test/More.pir runtime/parrot/library/Test/More.pir
index de4b7f9..7bde336 100644
|
|
|
|
| 13 | 13 | .local pmc exports, curr_namespace, test_namespace |
| 14 | 14 | curr_namespace = get_namespace |
| 15 | 15 | test_namespace = get_namespace [ 'Test'; 'More' ] |
| 16 | | exports = split ' ', 'plan diag ok nok is is_deeply like isa_ok skip isnt todo throws_like' |
| | 16 | exports = split ' ', 'plan diag ok nok is is_deeply like isa_ok skip isnt todo throws_like lives_ok' |
| 17 | 17 | |
| 18 | 18 | test_namespace.'export_to'(curr_namespace, exports) |
| 19 | 19 | |
| … |
… |
|
| 838 | 838 | .return( equal ) |
| 839 | 839 | .end |
| 840 | 840 | |
| | 841 | =item C<lives_ok( codestring, description )> |
| | 842 | |
| | 843 | Takes PIR code in C<codestring> and an optional message in C<description>. |
| | 844 | Passes a test if the PIR does not throw any exception. |
| | 845 | |
| | 846 | =cut |
| | 847 | |
| | 848 | .sub lives_ok |
| | 849 | .param string target |
| | 850 | .param string description :optional |
| | 851 | |
| | 852 | .local pmc test |
| | 853 | get_hll_global test, [ 'Test'; 'More' ], '_test' |
| | 854 | |
| | 855 | .local pmc comp |
| | 856 | .local pmc compfun |
| | 857 | .local pmc compiler |
| | 858 | compiler = compreg 'PIR' |
| | 859 | |
| | 860 | .local pmc eh |
| | 861 | eh = new 'ExceptionHandler' |
| | 862 | set_addr eh, handler # set handler label for exceptions |
| | 863 | push_eh eh |
| | 864 | |
| | 865 | compfun = compiler(target) |
| | 866 | compfun() # eval the target code |
| | 867 | |
| | 868 | pop_eh |
| | 869 | |
| | 870 | # if it doesn't throw an exception pass |
| | 871 | test.'ok'( 1, description ) |
| | 872 | |
| | 873 | goto done |
| | 874 | |
| | 875 | handler: |
| | 876 | .local pmc ex |
| | 877 | .local string error_msg |
| | 878 | .local string diagnostic |
| | 879 | |
| | 880 | .get_results (ex) |
| | 881 | pop_eh |
| | 882 | error_msg = ex |
| | 883 | test.'ok'( 0, description ) |
| | 884 | test.'diag'(error_msg) |
| | 885 | |
| | 886 | done: |
| | 887 | |
| | 888 | .end |
| | 889 | |
| 841 | 890 | =item C<throws_like( codestring, pattern, description )> |
| 842 | 891 | |
| 843 | 892 | Takes PIR code in C<codestring> and a PGE pattern to match in C<pattern>, as |
diff --git t/library/test_more.t t/library/test_more.t
index d511233..a5ea0a8 100644
|
|
|
|
| 15 | 15 | .local pmc exports, curr_namespace, test_namespace |
| 16 | 16 | curr_namespace = get_namespace |
| 17 | 17 | test_namespace = get_namespace [ 'Test'; 'More' ] |
| 18 | | exports = split " ", "ok nok is diag like skip todo is_deeply isa_ok isnt throws_like" |
| | 18 | exports = split " ", "ok nok is diag like skip todo is_deeply isa_ok isnt throws_like lives_ok" |
| 19 | 19 | test_namespace.'export_to'(curr_namespace, exports) |
| 20 | 20 | |
| 21 | 21 | test_namespace = get_namespace [ 'Test'; 'Builder'; 'Tester' ] |
| … |
… |
|
| 33 | 33 | test_like() |
| 34 | 34 | test_is_deeply() |
| 35 | 35 | test_diagnostics() |
| | 36 | test_lives_ok() |
| 36 | 37 | test_throws_like() |
| 37 | 38 | test_isa_ok() |
| 38 | 39 | |
| 39 | 40 | test.'finish'() |
| 40 | 41 | .end |
| 41 | 42 | |
| | 43 | .sub test_lives_ok |
| | 44 | |
| | 45 | test_pass( 'lives_ok passes when there is no error' ) |
| | 46 | lives_ok( <<'CODE', 'lives_ok passes when there is no error' ) |
| | 47 | .sub main |
| | 48 | $I0 = 42 |
| | 49 | .end |
| | 50 | CODE |
| | 51 | test_test( 'lives_ok passes when there is no error' ) |
| | 52 | |
| | 53 | test_fail( 'lives_ok fails when there is an error') |
| | 54 | lives_ok( <<'CODE', 'lives_ok fails when there is an error') |
| | 55 | .sub main |
| | 56 | die 'I did it for the lulz' |
| | 57 | .end |
| | 58 | CODE |
| | 59 | test_diag( 'I did it for the lulz' ) |
| | 60 | test_test( 'lives_ok fails when there is an error' ) |
| | 61 | |
| | 62 | test_pass( 'lives_ok passes when there is no error (with diagnostic message)' ) |
| | 63 | lives_ok( <<'CODE', 'lives_ok passes when there is no error (with diagnostic message)' ) |
| | 64 | .sub main |
| | 65 | $I0 = 42 |
| | 66 | .end |
| | 67 | CODE |
| | 68 | test_diag( '' ) |
| | 69 | test_test( 'lives_ok passes when there is no error (with diagnostic message)' ) |
| | 70 | |
| | 71 | test_fail( 'lives_ok fails when there is an error (with diagnostic message)' ) |
| | 72 | lives_ok( <<'CODE', 'lives_ok fails when there is an error (with diagnostic message)' ) |
| | 73 | .sub main |
| | 74 | die 'I did it for the lulz' |
| | 75 | .end |
| | 76 | CODE |
| | 77 | test_diag( 'I did it for the lulz' ) |
| | 78 | test_test( 'lives_ok fails when there is an error' ) |
| | 79 | .end |
| | 80 | |
| 42 | 81 | .sub test_throws_like |
| 43 | 82 | |
| 44 | 83 | test_fail('throws_like fails when there is no error') |