Ticket #1019: ok_calls_get_bool.patch
File ok_calls_get_bool.patch, 4.1 KB (added by flh, 12 years ago) |
---|
-
src/pmc/env.pmc
99 99 100 100 /* 101 101 102 =item C<INTVAL get_bool()> 103 104 Returns whether the environment has any elements. 105 106 =cut 107 108 */ 109 VTABLE INTVAL get_bool() { 110 return SELF.elements() ? 1 : 0; 111 } 112 113 /* 114 102 115 =item C<INTVAL get_integer()> 103 116 104 117 Returns the size of the hash. -
runtime/parrot/library/Test/More.pir
92 92 93 93 =item C<ok( passed, description )> 94 94 95 Records a test as pass or fail depending on the truth of the integerC<passed>,95 Records a test as pass or fail depending on the truth of the PMC C<passed>, 96 96 recording it with the optional test description in C<description>. 97 97 98 98 =cut 99 99 100 100 .sub ok 101 .param intpassed101 .param pmc passed 102 102 .param string description :optional 103 103 104 104 .local pmc test 105 105 get_hll_global test, [ 'Test'; 'More' ], '_test' 106 106 107 test.'ok'( passed, description ) 107 $I0 = istrue passed 108 test.'ok'( $I0, description ) 108 109 .end 109 110 110 111 =item C<nok( passed, description )> … … 115 116 =cut 116 117 117 118 .sub nok 118 .param intpassed119 .param pmc passed 119 120 .param string description :optional 120 121 121 122 .local pmc test 122 123 get_hll_global test, [ 'Test'; 'More' ], '_test' 123 124 124 125 .local int reverse_passed 125 reverse_passed = notpassed126 reverse_passed = isfalse passed 126 127 127 128 test.'ok'( reverse_passed, description ) 128 129 .end -
t/library/test_more.t
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 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" 19 19 test_namespace.'export_to'(curr_namespace, exports) 20 20 21 21 test_namespace = get_namespace [ 'Test'; 'Builder'; 'Tester' ] 22 22 exports = split " ", "plan test_out test_diag test_fail test_pass test_test" 23 23 test_namespace.'export_to'(curr_namespace, exports) 24 24 25 plan( 8 1)25 plan( 89 ) 26 26 27 27 test_skip() 28 28 test_todo() 29 29 test_ok() 30 test_nok() 30 31 test_is() 31 32 test_isnt() 32 33 test_like() … … 72 73 73 74 .end 74 75 76 .namespace ['MyFalseClass'] 77 78 .sub '' :anon :load :init 79 $P0 = newclass ['MyFalseClass'] 80 .end 81 82 .sub 'get_bool' :vtable 83 .return(0) 84 .end 85 86 .sub 'get_integer' :vtable 87 .return(1) 88 .end 89 90 .namespace ['MyTrueClass'] 91 92 .sub '' :anon :load :init 93 $P0 = newclass ['MyTrueClass'] 94 .end 95 96 .sub 'get_bool' :vtable 97 .return(1) 98 .end 99 100 .sub 'get_integer' :vtable 101 .return(0) 102 .end 103 104 .namespace [] 105 75 106 .sub test_ok 76 107 test_pass() 77 108 ok( 1 ) … … 88 119 test_fail( 'with description' ) 89 120 ok( 0, 'with description' ) 90 121 test_test( 'failing test ok() with description') 122 123 $P0 = new ['MyFalseClass'] 124 test_fail() 125 ok( $P0 ) 126 test_test( 'failing ok() calls get_bool') 127 128 $P0 = new ['MyTrueClass'] 129 test_pass() 130 ok( $P0 ) 131 test_test( 'passing ok() calls get_bool') 91 132 .end 92 133 134 .sub test_nok 135 test_fail() 136 nok( 1 ) 137 test_test( 'failing test nok()') 138 139 test_pass() 140 nok( 0 ) 141 test_test( 'passing test nok()') 142 143 test_fail( 'with description' ) 144 nok( 1, 'with description' ) 145 test_test( 'failing test nok() with description') 146 147 test_pass( 'with description' ) 148 nok( 0, 'with description' ) 149 test_test( 'passing test nok() with description') 150 151 $P0 = new ['MyFalseClass'] 152 test_pass() 153 nok( $P0 ) 154 test_test( 'passing nok() calls get_bool') 155 156 $P0 = new ['MyTrueClass'] 157 test_fail() 158 nok( $P0 ) 159 test_test( 'failing nok() calls get_bool') 160 .end 161 93 162 .sub test_is 94 163 test_pass() 95 164 is( 100, 100 )