[svn:parrot] r40481 - in trunk: . runtime/parrot/include src/dynoplibs t/codingstd t/dynoplibs t/pmc
dukeleto at svn.parrot.org
dukeleto at svn.parrot.org
Tue Aug 11 06:09:37 UTC 2009
Author: dukeleto
Date: Tue Aug 11 06:09:35 2009
New Revision: 40481
URL: https://trac.parrot.org/parrot/changeset/40481
Log:
[TT #819] Add tests to obscure.ops, un-TODO the related codingstd test and refactor fp_eq_ok into fp_equality.pasm
Added:
trunk/t/dynoplibs/obscure.t
Modified:
trunk/MANIFEST
trunk/runtime/parrot/include/fp_equality.pasm
trunk/src/dynoplibs/obscure.ops
trunk/t/codingstd/test_file_coverage.t
trunk/t/pmc/complex.t
trunk/t/pmc/string.t
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Mon Aug 10 23:23:26 2009 (r40480)
+++ trunk/MANIFEST Tue Aug 11 06:09:35 2009 (r40481)
@@ -1672,6 +1672,7 @@
t/distro/file_metadata.t [test]
t/distro/manifest.t [test]
t/distro/meta_yml.t [test]
+t/dynoplibs/obscure.t [test]
t/dynpmc/dynlexpad.t [test]
t/dynpmc/foo.t [test]
t/dynpmc/foo2.t [test]
Modified: trunk/runtime/parrot/include/fp_equality.pasm
==============================================================================
--- trunk/runtime/parrot/include/fp_equality.pasm Mon Aug 10 23:23:26 2009 (r40480)
+++ trunk/runtime/parrot/include/fp_equality.pasm Tue Aug 11 06:09:35 2009 (r40481)
@@ -7,7 +7,7 @@
=head1 DESCRIPTION
-This file provides two PIR macros to determine if a pair of floating point numbers are equivalent.
+This file provides PIR macros to determine if a pair of floating point numbers are equivalent.
The same macros are also provided for PASM.
=cut
@@ -23,6 +23,18 @@
.label $FPEQNOK:
.endm
+.macro fp_eq_ok ( J, K, L )
+ set $N10, .J
+ set $N11, .K
+ sub $N12, $N11, $N10
+ abs $N12, $N12
+
+ set $I0, 0
+ gt $N12, 0.000001, .$FPEQNOK
+ set $I0, 1
+.label $FPEQNOK:
+ ok( $I0, .L )
+.endm
.macro fp_ne ( J, K, L )
set $N10, .J
Modified: trunk/src/dynoplibs/obscure.ops
==============================================================================
--- trunk/src/dynoplibs/obscure.ops Mon Aug 10 23:23:26 2009 (r40480)
+++ trunk/src/dynoplibs/obscure.ops Tue Aug 11 06:09:35 2009 (r40481)
@@ -11,7 +11,7 @@
=head1 NAME
-obscure.ops - Obscure Mathmatical Opcodes
+obscure.ops - Obscure Mathematical Opcodes
=cut
Modified: trunk/t/codingstd/test_file_coverage.t
==============================================================================
--- trunk/t/codingstd/test_file_coverage.t Mon Aug 10 23:23:26 2009 (r40480)
+++ trunk/t/codingstd/test_file_coverage.t Tue Aug 11 06:09:35 2009 (r40481)
@@ -63,7 +63,6 @@
# Tests in src/dynoplibs
{
- local $TODO = "obscure.ops needs tests. (TT #819)";
ok( !@$test_dynoplibs_miss, "there are test files in $test_dynoplibs_dir for all OPS files" )
or diag "files in $dynoplibs_dir but not in test dir:\n\t@$test_dynoplibs_miss";
}
Added: trunk/t/dynoplibs/obscure.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/dynoplibs/obscure.t Tue Aug 11 06:09:35 2009 (r40481)
@@ -0,0 +1,70 @@
+#! perl
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+use strict;
+use warnings;
+use lib qw( . lib ../lib ../../lib );
+use Test::More;
+use Parrot::Test tests => 4;
+use Parrot::Config;
+
+=head1 NAME
+
+t/dynoplibs/obscure.t - Tests for obscure mathematical functions
+
+=head1 SYNOPSIS
+
+ % prove t/dynoblibs/obscure.t
+
+=head1 DESCRIPTION
+
+Tests obscure.ops
+
+=cut
+
+pir_output_like( <<CODE, qr/^42/, "loadlib obscure ops" );
+.loadlib 'obscure_ops'
+.sub main :main
+ print 42
+.end
+CODE
+
+
+pir_output_like( <<CODE, qr/^1/, "covers of 0" );
+.loadlib 'obscure_ops'
+.sub main :main
+ .local num x
+ covers x, 0
+ print x
+.end
+CODE
+
+pir_output_like( <<CODE, qr/^1/, "covers of pi" );
+.loadlib 'obscure_ops'
+.sub main :main
+ .local num x, pi
+ pi = atan 1.0, 1.0
+ pi *= 4
+ covers x, pi
+ print x
+.end
+CODE
+
+pir_output_like( <<CODE, qr/^0/, "covers of pi/2" );
+.loadlib 'obscure_ops'
+.sub main :main
+ .local num x, halfpi
+ halfpi = atan 1.0, 1.0
+ halfpi *= 2
+ covers x, halfpi
+ print x
+.end
+CODE
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Modified: trunk/t/pmc/complex.t
==============================================================================
--- trunk/t/pmc/complex.t Mon Aug 10 23:23:26 2009 (r40480)
+++ trunk/t/pmc/complex.t Tue Aug 11 06:09:35 2009 (r40481)
@@ -91,19 +91,6 @@
is( message, .M, .M )
.endm
-.macro fp_eq_ok( J, K, L )
- set $N10, .J
- set $N11, .K
- sub $N12, $N11, $N10
- abs $N12, $N12
-
- set $I0, 0
- gt $N12, 0.000001, .$FPEQNOK
- set $I0, 1
-.label $FPEQNOK:
- ok( $I0, .L )
-.endm
-
.sub string_parsing
$P0 = new ['Complex']
$P1 = new ['String']
Modified: trunk/t/pmc/string.t
==============================================================================
--- trunk/t/pmc/string.t Mon Aug 10 23:23:26 2009 (r40480)
+++ trunk/t/pmc/string.t Tue Aug 11 06:09:35 2009 (r40481)
@@ -131,21 +131,6 @@
is( $I0, 0, 'string "foo" -> int' )
.end
-# Macro to ease testing of floating point comparisons
-# borrowed from fp_eq in fp_equality.pasm
-.macro fp_eq_ok ( J, K, L )
- set $N10, .J
- set $N11, .K
- sub $N12, $N11, $N10
- abs $N12, $N12
-
- set $I0, 0
- gt $N12, 0.000001, .$FPEQNOK
- set $I0, 1
-.label $FPEQNOK:
- ok( $I0, .L )
-.endm
-
.sub setting_numbers
.include 'fp_equality.pasm'
new $P0, ['String']
More information about the parrot-commits
mailing list