Skip to content

Commit

Permalink
[TT #1965] Make the Rational PMC act sanely when used in a boolean co…
Browse files Browse the repository at this point in the history
…ntext, doughera++
  • Loading branch information
leto committed Jan 19, 2011
1 parent f2848b0 commit 09258d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/dynpmc/rational.pmc
Expand Up @@ -397,7 +397,7 @@ Returns the version of GNU Multiple Precision library. Returns 0.0.0, if GMP is
*/
VTABLE INTVAL get_bool() {
#ifdef PARROT_HAS_GMP
if (mpq_cmp_si(RT(SELF), 0, 0))
if (mpq_cmp_si(RT(SELF), 0, 1) == 0)
return 0;
else
return 1;
Expand Down
10 changes: 6 additions & 4 deletions t/dynpmc/rational.t
Expand Up @@ -25,7 +25,7 @@ Tests the Rational PMC.
$S0 = config_hash['gmp']

unless $S0 goto no_gmp
plan(78)
plan(79)
loadlib $P1, 'rational'
test_init()
test_destroy()
Expand Down Expand Up @@ -559,7 +559,7 @@ CODE

.sub test_init
new $P1, 'Rational'
ok($P1,'initialization')
is($P1, 0, 'initialization')
.end

.sub test_destroy
Expand Down Expand Up @@ -669,8 +669,10 @@ CODE
new $P0, 'Rational'
$P0 = "0"
$I0 = isfalse $P0

todo($I0, "0 value of rational does not evaluate correctly")
ok($I0, '0 should be false')
$P0 = "3/4"
$I0 = istrue $P0
ok($I0, '3/4 should be true')
.end

# Local Variables:
Expand Down

0 comments on commit 09258d5

Please sign in to comment.