[svn:parrot] r41334 - in trunk: runtime/parrot/library/Test src/pmc t/library
dukeleto at svn.parrot.org
dukeleto at svn.parrot.org
Fri Sep 18 16:56:18 UTC 2009
Author: dukeleto
Date: Fri Sep 18 16:56:17 2009
New Revision: 41334
URL: https://trac.parrot.org/parrot/changeset/41334
Log:
[TT #1019] Make ok and nok use a PMC argument in test_more.pir and add tests for nok, flh++
Modified:
trunk/runtime/parrot/library/Test/More.pir
trunk/src/pmc/env.pmc
trunk/t/library/test_more.t
Modified: trunk/runtime/parrot/library/Test/More.pir
==============================================================================
--- trunk/runtime/parrot/library/Test/More.pir Fri Sep 18 12:57:53 2009 (r41333)
+++ trunk/runtime/parrot/library/Test/More.pir Fri Sep 18 16:56:17 2009 (r41334)
@@ -92,19 +92,20 @@
=item C<ok( passed, description )>
-Records a test as pass or fail depending on the truth of the integer C<passed>,
+Records a test as pass or fail depending on the truth of the PMC C<passed>,
recording it with the optional test description in C<description>.
=cut
.sub ok
- .param int passed
+ .param pmc passed
.param string description :optional
.local pmc test
get_hll_global test, [ 'Test'; 'More' ], '_test'
- test.'ok'( passed, description )
+ $I0 = istrue passed
+ test.'ok'( $I0, description )
.end
=item C<nok( passed, description )>
@@ -115,14 +116,14 @@
=cut
.sub nok
- .param int passed
+ .param pmc passed
.param string description :optional
.local pmc test
get_hll_global test, [ 'Test'; 'More' ], '_test'
.local int reverse_passed
- reverse_passed = not passed
+ reverse_passed = isfalse passed
test.'ok'( reverse_passed, description )
.end
Modified: trunk/src/pmc/env.pmc
==============================================================================
--- trunk/src/pmc/env.pmc Fri Sep 18 12:57:53 2009 (r41333)
+++ trunk/src/pmc/env.pmc Fri Sep 18 16:56:17 2009 (r41334)
@@ -99,6 +99,19 @@
/*
+=item C<INTVAL get_bool()>
+
+Returns whether the environment has any elements.
+
+=cut
+
+*/
+ VTABLE INTVAL get_bool() {
+ return SELF.elements() ? 1 : 0;
+ }
+
+/*
+
=item C<INTVAL get_integer()>
Returns the size of the hash.
Modified: trunk/t/library/test_more.t
==============================================================================
--- trunk/t/library/test_more.t Fri Sep 18 12:57:53 2009 (r41333)
+++ trunk/t/library/test_more.t Fri Sep 18 16:56:17 2009 (r41334)
@@ -15,18 +15,19 @@
.local pmc exports, curr_namespace, test_namespace
curr_namespace = get_namespace
test_namespace = get_namespace [ 'Test'; 'More' ]
- exports = split " ", "ok is diag like skip todo is_deeply isa_ok isnt throws_like"
+ exports = split " ", "ok nok is diag like skip todo is_deeply isa_ok isnt throws_like"
test_namespace.'export_to'(curr_namespace, exports)
test_namespace = get_namespace [ 'Test'; 'Builder'; 'Tester' ]
exports = split " ", "plan test_out test_diag test_fail test_pass test_test"
test_namespace.'export_to'(curr_namespace, exports)
- plan( 81 )
+ plan( 89 )
test_skip()
test_todo()
test_ok()
+ test_nok()
test_is()
test_isnt()
test_like()
@@ -72,6 +73,36 @@
.end
+.namespace ['MyFalseClass']
+
+.sub '' :anon :load :init
+ $P0 = newclass ['MyFalseClass']
+.end
+
+.sub 'get_bool' :vtable
+ .return(0)
+.end
+
+.sub 'get_integer' :vtable
+ .return(1)
+.end
+
+.namespace ['MyTrueClass']
+
+.sub '' :anon :load :init
+ $P0 = newclass ['MyTrueClass']
+.end
+
+.sub 'get_bool' :vtable
+ .return(1)
+.end
+
+.sub 'get_integer' :vtable
+ .return(0)
+.end
+
+.namespace []
+
.sub test_ok
test_pass()
ok( 1 )
@@ -88,6 +119,44 @@
test_fail( 'with description' )
ok( 0, 'with description' )
test_test( 'failing test ok() with description')
+
+ $P0 = new ['MyFalseClass']
+ test_fail()
+ ok( $P0 )
+ test_test( 'failing ok() calls get_bool')
+
+ $P0 = new ['MyTrueClass']
+ test_pass()
+ ok( $P0 )
+ test_test( 'passing ok() calls get_bool')
+.end
+
+.sub test_nok
+ test_fail()
+ nok( 1 )
+ test_test( 'failing test nok()')
+
+ test_pass()
+ nok( 0 )
+ test_test( 'passing test nok()')
+
+ test_fail( 'with description' )
+ nok( 1, 'with description' )
+ test_test( 'failing test nok() with description')
+
+ test_pass( 'with description' )
+ nok( 0, 'with description' )
+ test_test( 'passing test nok() with description')
+
+ $P0 = new ['MyFalseClass']
+ test_pass()
+ nok( $P0 )
+ test_test( 'passing nok() calls get_bool')
+
+ $P0 = new ['MyTrueClass']
+ test_fail()
+ nok( $P0 )
+ test_test( 'failing nok() calls get_bool')
.end
.sub test_is
More information about the parrot-commits
mailing list