[svn:parrot] r40556 - trunk/t/dynoplibs

dukeleto at svn.parrot.org dukeleto at svn.parrot.org
Sat Aug 15 07:53:02 UTC 2009


Author: dukeleto
Date: Sat Aug 15 07:53:01 2009
New Revision: 40556
URL: https://trac.parrot.org/parrot/changeset/40556

Log:
[TT #871] Add some tests for the rand() dynop with different calling conventions

Modified:
   trunk/t/dynoplibs/math.t

Modified: trunk/t/dynoplibs/math.t
==============================================================================
--- trunk/t/dynoplibs/math.t	Sat Aug 15 07:52:31 2009	(r40555)
+++ trunk/t/dynoplibs/math.t	Sat Aug 15 07:53:01 2009	(r40556)
@@ -20,7 +20,7 @@
 .sub main :main
     .include 'test_more.pir'
     .include 'fp_equality.pasm'
-    plan(14)
+    plan(20)
     ok(1, "load math_ops")
     rand $I0
     test_2_arg_int()
@@ -29,6 +29,9 @@
     test_2_arg_num()
     test_3_arg_num()
     test_srand()
+    test_local_nums()
+    test_local_nums_2_arg()
+    test_local_ints()
 .end
 
 .sub test_2_arg_int
@@ -124,6 +127,57 @@
     .fp_eq_ok($N0, $N1, 'having the same seed generates the same numbers')
 .end
 
+.sub test_local_nums_2_arg
+    .local num foo, bar
+    foo = rand 5.0, 25.0
+    lt foo, 5, fail1
+    ok(1, 'rand returns a number greater than or equal to 5')
+    goto upper
+fail1:
+    ok(0, 'rand returns a number greater than or equal to 5')
+upper:
+    gt foo, 25, fail2
+    ok(1, 'rand returns a number less than or equal to 25')
+    goto finish
+fail2:
+    ok(0, 'rand returns a number less than or equal to 25')
+finish:
+.end
+
+.sub test_local_nums
+    .local num foo, bar
+    foo = rand
+    lt foo, 0, fail1
+    ok(1, 'rand returns a number greater than or equal to 0')
+    goto upper
+fail1:
+    ok(0, 'rand returns a number greater than or equal to 0')
+upper:
+    gt foo, 1, fail2
+    ok(1, 'rand returns a number less than or equal to 1')
+    goto finish
+fail2:
+    ok(0, 'rand returns a number less than or equal to 1')
+finish:
+.end
+
+.sub test_local_ints
+    .local int foo, bar
+    foo = rand 5, 25
+    lt foo, 5, fail1
+    ok(1, 'rand returns a number greater than or equal to 5')
+    goto upper
+fail1:
+    ok(0, 'rand returns a number greater than or equal to 5')
+upper:
+    gt foo, 25, fail2
+    ok(1, 'rand returns a number less than or equal to 25')
+    goto finish
+fail2:
+    ok(0, 'rand returns a number less than or equal to 25')
+finish:
+.end
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4


More information about the parrot-commits mailing list