[svn:parrot] r41934 - trunk/t/op
jkeenan at svn.parrot.org
jkeenan at svn.parrot.org
Sun Oct 18 19:08:50 UTC 2009
Author: jkeenan
Date: Sun Oct 18 19:08:43 2009
New Revision: 41934
URL: https://trac.parrot.org/parrot/changeset/41934
Log:
Add 4 tests for 'gcd' for integers. But how should we handle case where one argument is 0?
Modified:
trunk/t/op/arithmetics.t
Modified: trunk/t/op/arithmetics.t
==============================================================================
--- trunk/t/op/arithmetics.t Sun Oct 18 17:28:18 2009 (r41933)
+++ trunk/t/op/arithmetics.t Sun Oct 18 19:08:43 2009 (r41934)
@@ -20,7 +20,7 @@
.sub main :main
.include 'test_more.pir'
- plan(125)
+ plan(129)
take_the_negative_of_a_native_integer()
take_the_absolute_of_a_native_integer()
@@ -42,6 +42,7 @@
multiply_native_number_with_native_number()
divide_native_number_by_native_number()
lcm_test()
+ gcd_test()
integer_overflow_with_pow()
# END_OF_TESTS
@@ -477,6 +478,27 @@
is( $I2, 0, 'lcm_test' )
.end
+.sub gcd_test
+ set $I0, 70
+ set $I1, 42
+ gcd $I2, $I1, $I0
+ is( $I2, 14, 'gcd_test' )
+
+ set $I0, 66
+ gcd $I2, $I1, $I0
+ is( $I2, 6, 'gcd_test' )
+
+ set $I0, 70
+ set $I1, 1
+ gcd $I2, $I1, $I0
+ is( $I2, 1, 'gcd_test' )
+
+ set $I0, 70
+ set $I1, 3
+ gcd $I2, $I1, $I0
+ is( $I2, 1, 'gcd_test' )
+.end
+
.sub integer_overflow_with_pow
.include "iglobals.pasm"
More information about the parrot-commits
mailing list