[svn:parrot] r41097 - trunk/t/pmc

dukeleto at svn.parrot.org dukeleto at svn.parrot.org
Mon Sep 7 05:38:23 UTC 2009


Author: dukeleto
Date: Mon Sep  7 05:38:23 2009
New Revision: 41097
URL: https://trac.parrot.org/parrot/changeset/41097

Log:
[TT #969][t] Convert t/pmc/float.t to PIR, flh++

Modified:
   trunk/t/pmc/float.t

Modified: trunk/t/pmc/float.t
==============================================================================
--- trunk/t/pmc/float.t	Mon Sep  7 05:27:31 2009	(r41096)
+++ trunk/t/pmc/float.t	Mon Sep  7 05:38:23 2009	(r41097)
@@ -1,15 +1,7 @@
-#!perl
+#! parrot
 # Copyright (C) 2001-2009, Parrot Foundation.
 # $Id$
 
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-
-use Test::More;
-use Parrot::Test tests => 61;
-use Parrot::Config;
-
 =head1 NAME
 
 t/pmc/float.t - Floating-point Numbers
@@ -24,1600 +16,1004 @@
 
 =cut
 
+.const int TESTS = 159
+.const num PRECISION = 0.000001
+
+.sub 'test' :main
+    .include 'test_more.pir'
+
+    plan(TESTS)
+    basic_assignment()
+    add_number_to_self()
+    sub_number_from_self()
+    multiply_number_by_self()
+    divide_number_by_self()
+    divide_by_zero()
+    truth_positive_float()
+    truth_negative_float()
+    truth_positive_integer()
+    truth_negative_integer()
+    falseness_0()
+    'falseness_0.000'()
+    integer_addition()
+    integer_substraction()
+    integer_multiplication()
+    integer_division()
+    number_addition()
+    number_substraction()
+    number_multiplication()
+    number_division()
+    increment_decrement()
+    'neg'()
+    negative_zero()
+    equality()
+    is_interface_done()
+    'abs'()
+    'lt'()
+    'lt_num'()
+    'le'()
+    'le_num'()
+    'gt'()
+    'gt_num'()
+    'ge'()
+    'ge_num'()
+    cmp_p_n()
+    'isgt'()
+    'isge'()
+    'islt'()
+    'isle'()
+    'iseq'()
+    'isne'()
+    instantiate_str()
+    cmp_subclasses()
+    acos_method()
+    cos_method()
+    asec_method()
+    asin_method()
+    atan_method()
+    atan2_method()
+    cosh_method()
+    exp_method()
+    ln_method()
+    log10_method()
+    log2_method()
+    sec_method()
+    sech_method()
+    sin_method()
+    sinh_method()
+    tan_method()
+    tanh_method()
+    sqrt_method()
+.end
+
+.include 'fp_equality.pasm'
+
+.sub 'basic_assignment'
+    $P0 = new ['Float']
+
+    $P0 = 0.001
+    is($P0, 0.001, 'basic float assignment 1', PRECISION)
+
+    $P0 = 12.5
+    is($P0, 12.5, 'basic assignment 2', PRECISION)
+
+    $P0 = 1000
+    is($P0, 1000.0, 'basic integer assignment', PRECISION)
+
+    $P0 = 'Twelve point five'
+    is($P0, 0.0, 'basic string assignment', PRECISION)
+
+    $P0 = 123.45
+    $I0 = $P0
+    is($I0, 123, 'rounding to integer')
+
+    $P0 = 123.45
+    $N0 = $P0
+    is($N0, 123.45, 'get_float_value', PRECISION)
+
+    $P0 = 123.45
+    $S0 = $P0
+    is($S0, '123.45', 'get string')
+
+    $P0 = "12.49"
+    $P1 = get_class ['Float']
+    is($P0, 12.49, 'setting value from string', PRECISION)
+.end
+
+.sub 'add_number_to_self'
+    $P0 = new ['Float']
+    $P0 = 0.001
+    $P0 = $P0 + $P0
+
+    is($P0, 0.002, 'add number to self', PRECISION)
+.end
+
+.sub 'sub_number_from_self'
+    $P0 = new ['Float']
+    $P0 = -1000.2
+    $P0 = $P0 - $P0
+
+    is($P0, 0.0, 'sub number from self', PRECISION)
+.end
+
+.sub 'multiply_number_by_self'
+    $P0 = new ['Float']
+    $P0 = 123.4
+    $P0 = $P0 * $P0
+
+    is($P0, 15227.56, 'multiply number by self', PRECISION)
+.end
+
+.sub 'divide_number_by_self'
+    $P0 = new ['Float']
+    $P0 = 1829354.988
+    $P0 = $P0 / $P0
 
-pasm_output_is( <<"CODE", <<OUTPUT, "basic assignment" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-
-    set P0, 0.001
-    .fp_eq_pasm( P0, 0.001, EQ1)
-    print "not "
-EQ1:    print "ok 1\\n"
-
-        set P0, 1000
-        .fp_eq_pasm( P0, 1000.0, EQ2)
-    print "not "
-EQ2:    print "ok 2\\n"
-
-        set P0, "12.5"
-        .fp_eq_pasm( P0, 12.5, EQ3)
-    print "not "
-EQ3:    print "ok 3\\n"
-
-        set P0, "Twelve point five"
-        .fp_eq_pasm( P0, 0.0, EQ4)
-    print "not "
-EQ4:    print "ok 4\\n"
-
-        set P0, 123.45
-        set I0, P0
-        eq I0, 123, EQ5
-    print "not "
-EQ5:    print "ok 5\\n"
-
-        set P0, 123.45
-        set N0, P0
-        .fp_eq_pasm(N0, 123.45, EQ6)
-    print "not "
-EQ6:    print "ok 6\\n"
-
-        set P0, 123.45
-        set S0, P0
-        eq S0, "123.45", EQ7
-    print "not "
-EQ7:    print "ok 7\\n"
-
-    end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-ok 5
-ok 6
-ok 7
-OUTPUT
-
-pasm_output_is( <<"CODE", <<OUTPUT, "add number to self" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.001
-    add P0, P0, P0
-    .fp_eq_pasm( P0, 0.002, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-    end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<"CODE", <<OUTPUT, "sub number from self" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, -1000.2
-    sub P0, P0, P0
-    .fp_eq_pasm( P0, 0.0, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-    end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<"CODE", <<OUTPUT, "multiply number by self" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 123.4
-    mul P0, P0, P0
-    .fp_eq_pasm( P0, 15227.56, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-    end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<"CODE", <<OUTPUT, "divide number by self" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 1829354.988
-    div P0, P0, P0
-    .fp_eq_pasm( P0, 1.0, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-    end
-CODE
-ok 1
-OUTPUT
+    is($P0, 1.0, 'divide number by self', PRECISION)
+.end
 
-pir_output_is( <<'CODE', <<OUTPUT, "divide by zero" );
-.sub _main :main
+.sub 'divide_by_zero'
     $P0 = new ['Float']
-    set $P0, "12.0"
+    $P0 = 12.0
+
     $P1 = new ['Float']
+
     $P2 = new ['Float']
-    set $P2, "0.0"
-    push_eh OK
+    $P2 = 0.0
+
+    push_eh divide_by_zero_handler
     $P1 = $P0 / $P2
-    print "fail\n"
     pop_eh
-OK:
-    get_results '0', $P0
-    $S0 = $P0
-    print "ok\n"
-    print $S0
-    print "\n"
-.end
-CODE
-ok
-float division by zero
-OUTPUT
+    nok(1, 'divide by zero')
+    .return ()
 
-pir_output_is( << 'CODE', << 'OUTPUT', "Truth of a positive float" );
+  divide_by_zero_handler:
+    .get_results ($P1)
+    $S1 = $P1
+    say $S1
+    like($S1, ':s division by zero', 'divide by zero')
+.end
 
-.sub _main
+.sub 'truth_positive_float'
     .local pmc float_1
     float_1 = new ['Float']
     float_1 = 123.123
-    print float_1
-    if float_1 goto IS_TRUE
-      print " is false\n"
-    end
-    IS_TRUE:
-      print " is true\n"
-    end
-.end
-CODE
-123.123 is true
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "Truth of a negative float" );
+    ok(float_1, 'Truth of a positive float')
+.end
 
-.sub _main
+.sub 'truth_negative_float'
     .local pmc float_1
     float_1 = new ['Float']
     float_1 = -123.123
-    print float_1
-    if float_1 goto IS_TRUE
-      print " is false\n"
-    end
-    IS_TRUE:
-      print " is true\n"
-    end
-.end
-CODE
--123.123 is true
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "Truth of a positive integer" );
+    ok(float_1, 'Truth of a negative float')
+.end
 
-.sub _main
+.sub 'truth_positive_integer'
     .local pmc float_1
     float_1 = new ['Float']
     float_1 = 1
-    print float_1
-    if float_1 goto IS_TRUE
-      print " is false\n"
-    end
-    IS_TRUE:
-      print " is true\n"
-    end
-.end
-CODE
-1 is true
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "Truth of a negative integer" );
+    ok(float_1, 'Truth of a positive integer')
+.end
 
-.sub _main
+.sub 'truth_negative_integer'
     .local pmc float_1
     float_1 = new ['Float']
     float_1 = -1
-    print float_1
-    if float_1 goto IS_TRUE
-      print " is false\n"
-    end
-    IS_TRUE:
-      print " is true\n"
-    end
-.end
-CODE
--1 is true
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "Falseness of 0" );
+    ok(float_1, 'Truth of a negative integer')
+.end
 
-.sub _main
+.sub 'falseness_0'
     .local pmc float_1
     float_1 = new ['Float']
     float_1 = 0
-    print float_1
-    if float_1 goto IS_TRUE
-      print " is false\n"
-    end
-    IS_TRUE:
-      print " is true\n"
-    end
-.end
-CODE
-0 is false
-OUTPUT
-
-pir_output_is( << 'CODE', << 'OUTPUT', "Falseness of 0.000" );
+    nok(float_1, 'Falseness of 0')
+.end
 
-.sub _main
+.sub 'falseness_0.000'
     .local pmc float_1
     float_1 = new ['Float']
     float_1 = 0.000
-    print float_1
-    if float_1 goto IS_TRUE
-      print " is false\n"
-    end
-    IS_TRUE:
-      print " is true\n"
-    end
-.end
-CODE
-0 is false
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic integer arithmetic: addition" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.001
-    add P0, 1
-    .fp_eq_pasm(P0, 1.001, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    add P0, -2
-    .fp_eq_pasm(P0, -0.999, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic integer arithmetic: subtraction" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 103.45
-    sub P0, 77
-    .fp_eq_pasm(P0, 26.45, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    sub P0, -24
-    .fp_eq_pasm(P0, 50.45, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic integer arithmetic: multiplication" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.001
-    mul P0, 10000
-    .fp_eq_pasm(P0, 10.0, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    mul P0, -1
-    .fp_eq_pasm(P0, -10.0, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-
-    mul P0, 0
-    .fp_eq_pasm(P0, 0.0, EQ3)
-    print P0
-    print "not "
-EQ3:    print "ok 3\\n"
-    end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic integer arithmetic: division" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 1e8
-    div P0, 10000
-    .fp_eq_pasm(P0, 10000.0, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    div P0, 1000000
-    .fp_eq_pasm(P0, 0.01, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic numeric arithmetic: addition" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.001
-    add P0, 1.2
-    .fp_eq_pasm(P0, 1.201, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    add P0, -2.4
-    .fp_eq_pasm(P0, -1.199, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic numeric arithmetic: subtraction" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 103.45
-    sub P0, 3.46
-    .fp_eq_pasm(P0, 99.99, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    sub P0, -0.01
-    .fp_eq_pasm(P0, 100.00, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic numeric arithmetic: multiplication" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.001
-    mul P0, 123.5
-    .fp_eq_pasm(P0, 0.1235, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    mul P0, -2.6
-    .fp_eq_pasm(P0, -0.3211, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-
-    mul P0, 0
-    .fp_eq_pasm(P0, 0.0, EQ3)
-    print P0
-    print "not "
-EQ3:    print "ok 3\\n"
-    end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Basic numeric arithmetic: division" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 1e8
-    div P0, 0.5
-    .fp_eq_pasm(P0, 2e8, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    div P0, 4000.0
-    .fp_eq_pasm(P0, 50000.0, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Increment & decrement" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.5
-    inc P0
-    .fp_eq_pasm(P0, 1.5, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-    dec P0
-    .fp_eq_pasm(P0, 0.5, EQ2)
-    print P0
-    print "not "
-EQ2:    print "ok 2\\n"
-
-    dec P0
-    .fp_eq_pasm(P0, -0.5, EQ3)
-    print P0
-    print "not "
-EQ3:    print "ok 3\\n"
-
-    inc P0
-    .fp_eq_pasm(P0, 0.5, EQ4)
-    print P0
-    print "not "
-EQ4:    print "ok 4\\n"
-    end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Neg" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 0.5
-    neg P0
-    .fp_eq_pasm(P0, -0.5, EQ1)
-    print P0
-    print "not "
-EQ1:    print "ok 1\\n"
-
-        new P1, ['Float']
-    neg P1, P0
-    .fp_eq_pasm(P1, 0.5, EQ2)
-    print P1
-    print "not "
-EQ2:    print "ok 2\\n"
-    end
-CODE
-ok 1
-ok 2
-OUTPUT
-
-TODO: {
-    my @todo;
-    @todo = ( todo => '-0.0 not implemented, TT #313' )
-        unless $PConfig{has_negative_zero};
-
-pasm_output_like( <<'CODE', <<'OUTPUT', 'neg 0', @todo );
-    new P0, ['Float']
-    set P0, 0.0
-    neg P0
-    print P0
-    end
-CODE
-/^-0/
-OUTPUT
-}
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "Equality" );
-    new P0, ['Float']
-    set P0, 1e8
-        new P1, ['Float']
-        set P1, 1e8
-        new P2, ['Float']
-        set P2, 2.4
-
-        eq P0, P1, OK1
-        print "not "
-OK1:    print "ok 1\n"
-
-        eq P0, P2, BAD2
-        branch OK2
-BAD2:   print "not "
-OK2:    print "ok 2\n"
-
-        ne P0, P2, OK3
-        print "not "
-OK3:    print "ok 3\n"
-
-        ne P0, P1, BAD4
-        branch OK4
-BAD4:   print "not "
-OK4:    print "ok 4\n"
-
-        eq_num P0, P1, OK5
-        print "not "
-OK5:    print "ok 5\n"
-
-        eq_num P0, P2, BAD6
-        branch OK6
-BAD6:   print "not "
-OK6:    print "ok 6\n"
-
-        ne_num P0, P2, OK7
-        print "not "
-OK7:    print "ok 7\n"
-
-        ne_num P0, P1, BAD8
-        branch OK8
-BAD8:   print "not "
-OK8:    print "ok 8\n"
-    end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-ok 5
-ok 6
-ok 7
-ok 8
-OUTPUT
+    nok(float_1, 'Falseness of 0.000')
+.end
 
-pir_output_is( << 'CODE', << 'OUTPUT', "check whether interface is done" );
+.sub 'integer_addition'
+    $P0 = new ['Float']
 
-.sub _main
-    .local pmc pmc1
-    pmc1 = new ['Float']
-    .local int bool1
-    does bool1, pmc1, "scalar"
-    print bool1
-    print "\n"
-    does bool1, pmc1, "float"
-    print bool1
-    print "\n"
-    does bool1, pmc1, "no_interface"
-    print bool1
-    print "\n"
-    end
-.end
-CODE
-1
-1
-0
-OUTPUT
-
-pasm_output_is( << "CODE", << 'OUTPUT', "Abs" );
-    .include 'fp_equality.pasm'
-    new P0, ['Float']
-    set P0, 1.0
-    abs P0
-        eq P0, P0, OK1
-    print P0
-    print "not "
-OK1:    print "ok 1\\n"
-
-        set P0, -1.0
-        abs P0
-    .fp_eq_pasm(P0, 1.0, OK2)
-    print P0
-    print "not "
-OK2:    print "ok 2\\n"
-
-        new P1, ['Float']
-        set P0, -5.0
-        abs P1, P0
-        .fp_eq_pasm(P1, 5.0, OK3)
-    print P1
-    print "not "
-OK3:    print "ok 3\\n"
-    end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: lt" );
-        new P1, ['Float']
-        set P1, 111.1
-        set N1, P1
-
-        lt P1, 111.2, OK1
-        print "not "
-OK1:    print "ok 1\n"
-
-        lt P1, N1, BAD2
-        branch OK2
-BAD2:   print "not "
-OK2:    print "ok 2\n"
-
-        lt P1, 111.0, BAD3
-        branch OK3
-BAD3:   print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: lt_num" );
-        new P1, ['Float']
-        set P1, 1.1
-        new P2, ['Float']
-        set P2, 1.2
-        new P3, ['Float']
-        set P3, 1.0
-        new P4, ['Float']
-        set P4, P1
-
-        lt_num P1, P2, OK1
-        print "not "
-OK1:    print "ok 1\n"
-
-        lt_num P1, P4, BAD2
-        branch OK2
-BAD2:   print "not "
-OK2:    print "ok 2\n"
-
-        lt_num P1, P3, BAD3
-        branch OK3
-BAD3:   print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: le" );
-        new P1, ['Float']
-        set P1, 111.1
-        set N1, P1
-
-        le P1, 111.2, OK1
-        print "not "
-OK1:    print "ok 1\n"
-
-        le P1, N1, OK2
-        print "not "
-OK2:    print "ok 2\n"
-
-        le P1, 111.0, BAD3
-        branch OK3
-BAD3:   print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: le_num" );
-        new P1, ['Float']
-        set P1, 1.1
-        new P2, ['Float']
-        set P2, 1.2
-        new P3, ['Float']
-        set P3, 1.0
-        new P4, ['Float']
-        set P4, P1
-
-        le_num P1, P2, OK1
-        print "not "
-OK1:    print "ok 1\n"
-
-        le_num P1, P4, OK2
-        print "not "
-OK2:    print "ok 2\n"
-
-        le_num P1, P3, BAD3
-        branch OK3
-BAD3:   print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: gt" );
-        new P1, ['Float']
-        set P1, 111.1
-        set N1, P1
-
-        gt P1, 111.2, BAD1
-        branch OK1
-BAD1:   print "not "
-OK1:    print "ok 1\n"
-
-        gt P1, N1, OK2
-        branch OK2
-BAD2:   print "not "
-OK2:    print "ok 2\n"
-
-        gt P1, 111.0, OK3
-        print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: gt_num" );
-        new P1, ['Float']
-        set P1, 1.1
-        new P2, ['Float']
-        set P2, 1.2
-        new P3, ['Float']
-        set P3, 1.0
-        new P4, ['Float']
-        set P4, P1
-
-        gt_num P1, P2, BAD1
-        branch OK1
-BAD1:   print "not "
-OK1:    print "ok 1\n"
-
-        gt_num P1, P4, OK2
-        branch OK2
-BAD2:   print "not "
-OK2:    print "ok 2\n"
-
-        gt_num P1, P3, OK3
-        print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: ge" );
-        new P1, ['Float']
-        set P1, 111.1
-        set N1, P1
-
-        ge P1, 111.2, BAD1
-        branch OK1
-BAD1:   print "not "
-OK1:    print "ok 1\n"
-
-        ge P1, N1, OK2
-        print "not "
-OK2:    print "ok 2\n"
-
-        ge P1, 111.0, OK3
-        print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: ge_num" );
-        new P1, ['Float']
-        set P1, 1.1
-        new P2, ['Float']
-        set P2, 1.2
-        new P3, ['Float']
-        set P3, 1.0
-        new P4, ['Float']
-        set P4, P1
-
-        ge_num P1, P2, BAD1
-        branch OK1
-BAD1:   print "not "
-OK1:    print "ok 1\n"
-
-        ge_num P1, P4, OK2
-        print "not "
-OK2:    print "ok 2\n"
-
-        ge_num P1, P3, OK3
-        print "not "
-OK3:    print "ok 3\n"
-        end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: cmp_p_n" );
-        new P1, ['Float']
-        set P1, 123.45
-        set N1, 123.45
-        set N2, -1.0
-        set N3, 123.54
-
-        cmp I0, P1, N1
-        print I0
-        print "\n"
-        cmp I0, P1, N2
-        print I0
-        print "\n"
-        cmp I0, P1, N3
-        print I0
-        print "\n"
-        end
-CODE
-0
-1
--1
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: isgt" );
-        new P1, ['Float']
-        new P2, ['Float']
-        new P3, ['Float']
-        new P4, ['Integer']
-        new P5, ['Integer']
-        new P6, ['Float']
-
-        set P1, 10.0
-        set P2, 20.0
-        set P3, 5.0
-        set P4, 3
-        set P5, 12
-        set P6, 10.0
-
-        isgt I0, P1, P2
-        print I0
-        print "\n"
-        isgt I0, P1, P1
-        print I0
-        print "\n"
-        isgt I0, P1, P3
-        print I0
-        print "\n"
-        isgt I0, P1, P4
-        print I0
-        print "\n"
-        isgt I0, P1, P5
-        print I0
-        print "\n"
-        isgt I0, P1, P6
-        print I0
-        print "\n"
-        end
-CODE
-0
-0
-1
-1
-0
-0
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: isge" );
-        new P1, ['Float']
-        new P2, ['Float']
-        new P3, ['Float']
-        new P4, ['Integer']
-        new P5, ['Integer']
-        new P6, ['Float']
-
-        set P1, 10.0
-        set P2, 20.0
-        set P3, 5.0
-        set P4, 3
-        set P5, 12
-        set P6, 10.0
-
-        isge I0, P1, P2
-        print I0
-        print "\n"
-        isge I0, P1, P1
-        print I0
-        print "\n"
-        isge I0, P1, P3
-        print I0
-        print "\n"
-        isge I0, P1, P4
-        print I0
-        print "\n"
-        isge I0, P1, P5
-        print I0
-        print "\n"
-        isge I0, P1, P6
-        print I0
-        print "\n"
-        end
-CODE
-0
-1
-1
-1
-0
-1
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: islt" );
-        new P1, ['Float']
-        new P2, ['Float']
-        new P3, ['Float']
-        new P4, ['Integer']
-        new P5, ['Integer']
-        new P6, ['Float']
-
-        set P1, 10.0
-        set P2, 20.0
-        set P3, 5.0
-        set P4, 3
-        set P5, 12
-        set P6, 10.0
-
-        islt I0, P1, P2
-        print I0
-        print "\n"
-        islt I0, P1, P1
-        print I0
-        print "\n"
-        islt I0, P1, P3
-        print I0
-        print "\n"
-        islt I0, P1, P4
-        print I0
-        print "\n"
-        islt I0, P1, P5
-        print I0
-        print "\n"
-        islt I0, P1, P6
-        print I0
-        print "\n"
-        end
-CODE
-1
-0
-0
-0
-1
-0
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: isle" );
-        new P1, ['Float']
-        new P2, ['Float']
-        new P3, ['Float']
-        new P4, ['Integer']
-        new P5, ['Integer']
-        new P6, ['Float']
-
-        set P1, 10.0
-        set P2, 20.0
-        set P3, 5.0
-        set P4, 3
-        set P5, 12
-        set P6, 10.0
-
-        isle I0, P1, P2
-        print I0
-        print "\n"
-        isle I0, P1, P1
-        print I0
-        print "\n"
-        isle I0, P1, P3
-        print I0
-        print "\n"
-        isle I0, P1, P4
-        print I0
-        print "\n"
-        isle I0, P1, P5
-        print I0
-        print "\n"
-        isle I0, P1, P6
-        print I0
-        print "\n"
-        end
-CODE
-1
-1
-0
-0
-1
-1
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: iseq" );
-        new P1, ['Float']
-        new P2, ['Float']
-        new P3, ['Float']
-        new P4, ['Integer']
-
-        set P1, 2.5
-        set P2, 2.6
-        set P3, 2.5
-        set P4, 2
-
-        iseq I0, P1, P1
-        print I0
-        print "\n"
-        iseq I0, P1, P2
-        print I0
-        print "\n"
-        iseq I0, P1, P3
-        print I0
-        print "\n"
-        iseq I0, P1, P4
-        print I0
-        print "\n"
-        end
-CODE
-1
-0
-1
-0
-OUTPUT
-
-pasm_output_is( << 'CODE', << 'OUTPUT', "comparison ops: isne" );
-        new P1, ['Float']
-        new P2, ['Float']
-        new P3, ['Float']
-        new P4, ['Integer']
-
-        set P1, 2.5
-        set P2, 2.6
-        set P3, 2.5
-        set P4, 2
-
-        isne I0, P1, P1
-        print I0
-        print "\n"
-        isne I0, P1, P2
-        print I0
-        print "\n"
-        isne I0, P1, P3
-        print I0
-        print "\n"
-        isne I0, P1, P4
-        print I0
-        print "\n"
-        end
-CODE
-0
-1
-0
-1
-OUTPUT
+    $P0 = 0.001
+    $P0 += 1
+    is($P0, 1.001, 'Basic integer arithmetic: addition (1)', PRECISION)
 
-pir_output_is( <<'CODE', <<OUTPUT, "instantiate_str" );
-.sub main :main
-    .const 'Float' pi = "3.1"
-    print pi
-    print "\n"
+    $P0 += -2
+    is($P0, -0.999, 'Basic integer arithmetic: addition (2)', PRECISION)
 .end
-CODE
-3.1
-OUTPUT
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'cmp functions for subclasses' );
-.sub main :main
-    $P0 = subclass 'Float', 'Flt'
+.sub 'integer_substraction'
+    $P0 = new ['Float']
 
-    $P1 = new ['Flt']
-    $P1 = 1.5
-    $P2 = new ['Flt']
-    $P2 = 2.73
+    $P0 = 103.45
+    $P0 -= 77
+    is($P0, 26.45, 'Basic integer arithmetic: subtraction (1)', PRECISION)
 
-    $I0 = cmp $P1, $P2
-    say $I0
-    $I0 = cmp $P1, $P1
-    say $I0
-    $I0 = cmp $P2, $P1
-    say $I0
+    $P0 -= -24
+    is($P0, 50.45, 'Basic integer arithmetic: subtraction (2)', PRECISION)
 .end
-CODE
--1
-0
-1
-OUTPUT
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'acos as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+.sub 'integer_multiplication'
     $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'acos'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "acos(%.1f) is %.9f", array
-    say $S0
 
-    $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'acos'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "acos(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-acos(0.0) is 1.570796327
-acos(0.5) is 1.047197551
-OUTPUT
+    $P0 = 0.001
+    $P0 *= 10000
+    is($P0, 10.0, 'Basic integer arithmetic: multiplication (1)', PRECISION)
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'cos as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+    $P0 *= -1
+    is($P0, -10.0, 'Basic integer arithmetic: multiplication (2)', PRECISION)
+
+    $P0 *= 0
+    is($P0, 0.0, 'Basic integer arithmetic: multiplication (3)', PRECISION)
+.end
+
+.sub 'integer_division'
     $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'cos'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "cos(%.1f) is %.9f", array
-    say $S0
 
-    $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'cos'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "cos(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-cos(0.0) is 1.000000000
-cos(0.5) is 0.877582562
-OUTPUT
+    $P0 = 1e8
+    $P0 /= 10000
+    is($P0, 10000.0, 'Basic integer arithmetic: division (1)', PRECISION)
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'asec as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+    $P0 /= 1000000
+    is($P0, 0.01, 'Basic integer arithmetic: division (2)', PRECISION)
+.end
+
+.sub 'number_addition'
     $P0 = new ['Float']
-    $P0 = 1.0
-    $P1 = $P0.'asec'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "asec(%.1f) is %.9f", array
-    say $S0
 
-    $P2 = new ['Float']
-    $P2 = 3.0
-    $P3 = $P2.'asec'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "asec(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-asec(1.0) is 0.000000000
-asec(3.0) is 1.230959417
-OUTPUT
+    $P0 = 0.001
+    $P0 += 1.2
+    is($P0, 1.201, 'Basic numeric arithmetic: addition (1)', PRECISION)
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'asin as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+    $P0 += -2.4
+    is($P0, -1.199, 'Basic numeric arithmetic: addition (2)', PRECISION)
+.end
+
+.sub 'number_substraction'
     $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'asin'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "asin(%.1f) is %.9f", array
-    say $S0
 
-    $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'asin'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "asin(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-asin(0.0) is 0.000000000
-asin(0.5) is 0.523598776
-OUTPUT
+    $P0 = 103.45
+    $P0 -= 3.46
+    is($P0, 99.99, 'Basic numeric arithmetic: subtraction (1)', PRECISION)
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'atan as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+    $P0 -= -0.01
+    is($P0, 100.0, 'Basic numeric arithmetic: subtraction (2)', PRECISION)
+.end
+
+.sub 'number_multiplication'
     $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'atan'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "atan(%.1f) is %.9f", array
-    say $S0
 
-    $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'atan'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "atan(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-atan(0.0) is 0.000000000
-atan(0.5) is 0.463647609
-OUTPUT
+    $P0 = 0.001
+    $P0 *= 123.5
+    is($P0, 0.1235, 'Basic numeric arithmetic: multiplication (1)', PRECISION)
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'atan2 as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 3
+    $P0 *= -2.6
+    is($P0, -0.3211, 'Basic numeric arithmetic: multiplication (2)', PRECISION)
+
+    $P0 *= 0.0
+    is($P0, 0.0, 'Basic numeric arithmetic: multiplication (3)', PRECISION)
+.end
+
+.sub 'number_division'
+    $P0 = new ['Float']
+
+    $P0 = 1e8
+    $P0 /= 0.5
+    is($P0, 2e8, 'Basic numeric arithmetic: division (1)', PRECISION)
+
+    $P0 /= 4000.0
+    is($P0, 50000.0, 'Basic numeric arithmetic: division (2)', PRECISION)
+.end
+
+.sub 'increment_decrement'
+    $P0 = new ['Float']
+
+    $P0 = 0.5
+    inc $P0
+    is($P0, 1.5, 'increment (1)', PRECISION)
+    dec $P0
+    is($P0, 0.5, 'decrement (1)', PRECISION)
+    dec $P0
+    is($P0, -.5, 'decrement (2)', PRECISION)
+    inc $P0
+    is($P0, 0.5, 'increment (2)', PRECISION)
+.end
+
+.sub 'neg'
     $P0 = new ['Float']
+    $P0 = 0.5
+    neg $P0
+    is($P0, -0.5, 'Neg', PRECISION)
+
     $P1 = new ['Float']
-    $P0 = 0.7
-    $P1 = 0.5
-    $P2 = $P0.'atan2'($P1)
-    array[0] = $P0
-    array[1] = $P1
-    array[2] = $P2
-    $S0 = sprintf "atan2(%.1f, %.1f) is %.9f", array
-    say $S0
-.end
-CODE
-atan2(0.7, 0.5) is 0.950546841
-OUTPUT
+    $P1 = - $P0
+    is($P1, 0.5, 'Neg is involutive', PRECISION)
+.end
+
+.sub 'negative_zero'
+    load_bytecode 'config.pbc'
+    $P1 = _config()
+    $P2 = $P1['has_negative_zero']
+    unless $P2 goto negative_zero_todoed
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'cosh as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
     $P0 = new ['Float']
     $P0 = 0.0
-    $P1 = $P0.'cosh'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "cosh(%.1f) is %.9f", array
-    say $S0
+    neg $P0
 
-    $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'cosh'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "cosh(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-cosh(0.0) is 1.000000000
-cosh(0.5) is 1.127625965
-OUTPUT
+    $S0 = $P0
+    like($S0, '^\-0', 'negative zero')
+    .return ()
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'exp as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+  negative_zero_todoed:
+    todo(1, '-0.0 not implemented, TT#313')
+.end
+
+.sub 'equality'
     $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'exp'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "exp(%.1f) is %.9f", array
-    say $S0
+    $P0 = 1e8
+
+    $P1 = new ['Float']
+    $P1 = 1e8
 
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'exp'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "exp(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-exp(0.0) is 1.000000000
-exp(0.5) is 1.648721271
-OUTPUT
+    $P2 = 2.4
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'ln as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+    $I0 = 1
+    if $P0 == $P1 goto equality_1
+    $I0 = 0
+  equality_1:
+    ok($I0, 'equal floats')
+
+    $I0 = 0
+    if $P0 == $P2 goto equality_2
+    $I0 = 1
+  equality_2:
+    ok($I0, 'different floats are not equal')
+
+    $I0 = 1
+    if $P0 != $P2 goto equality_3
+    $I0 = 0
+  equality_3:
+    ok($I0, "different floats are different")
+
+    $I0 = 0
+    if $P0 != $P1 goto equality_4
+    $I0 = 1
+  equality_4:
+    ok($I0, "equal floats aren't different")
+
+    $I0 = 1
+    eq_num $P0, $P1, equality_5
+    $I0 = 0
+  equality_5:
+    ok($I0, "equal floats are eq_num")
+
+    $I0 = 0
+    eq_num $P0, $P2, equality_6
+    $I0 = 1
+  equality_6:
+    ok($I0, "different floats aren't eq_num")
+
+    $I0 = 1
+    ne_num $P0, $P2, equality_7
+    $I0 = 0
+  equality_7:
+    ok($I0, "different floats are ne_num")
+
+    $I0 = 0
+    ne_num $P0, $P1, equality_8
+    $I0 = 1
+  equality_8:
+    ok($I0, "equal floats aren't ne_num")
+.end
+
+.sub 'is_interface_done'
+    .local pmc pmc1
+    .local int bool1
+    pmc1 = new ['Float']
+
+    bool1 = does pmc1, "scalar"
+    ok(bool1, 'Float does "scalar"')
+
+    bool1 = does pmc1, "float"
+    ok(bool1, 'Float does "float"')
+
+    bool1 = does pmc1, "no_interface"
+    nok(bool1, 'Float does not "no_interface"')
+.end
+
+.sub 'abs'
     $P0 = new ['Float']
-    $P0 = 45.0
-    $P1 = $P0.'ln'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "ln(%.1f) is %.9f", array
-    say $S0
+    $P0 = 1.0
+    abs $P0
+    is($P0, $P0, 'abs does not change positive floats')
+
+    $P0 = -1.0
+    abs $P0
+    is($P0, 1.0, 'abs of -1.0', PRECISION)
+
+    $P0 = -5.0
+    abs $P0
+    is($P0, 5.0, 'abs of -5.0', PRECISION)
+.end
+
+.sub 'lt'
+    $P1 = new ['Float']
+    $P1 = 111.11
+    $N1 = $P1
+
+    $I0 = 1
+    lt $P1, 111.12, lt_1
+    $I0 = 0
+  lt_1:
+    ok($I0, 'lt ok')
+
+    $I0 = 0
+    lt $P1, $N1, lt_2
+    $I0 = 1
+  lt_2:
+    ok($I0, 'lt irreflexive')
+
+    $I0 = 0
+    lt $P1, 111.0, lt_3
+    $I0 = 1
+  lt_3:
+    ok($I0, 'not lt')
+.end
+
+.sub 'lt_num'
+    $P1 = new ['Float']
+    $P1 = 1.1
 
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'ln'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "ln(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-ln(45.0) is 3.806662490
-ln(0.5) is -0.693147181
-OUTPUT
+    $P2 = 1.2
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'log10 as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 1000.0
-    $P1 = $P0.'log10'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "log10(%.1f) is %.9f", array
-    say $S0
+    $P3 = new ['Float']
+    $P3 = 1.0
+
+    $P4 = new ['Float']
+    $P4 = $P1
+
+    $I0 = 1
+    lt_num $P1, $P2, lt_num_1
+    $I0 = 0
+  lt_num_1:
+    ok($I0, 'lt_num true')
+
+    $I0 = 0
+    lt_num $P1, $P4, lt_num_2
+    $I0 = 1
+  lt_num_2:
+    ok($I0, 'lt_num irreflexive')
+
+    $I0 = 0
+    lt_num $P1, $P3, lt_num_3
+    $I0 = 1
+  lt_num_3:
+    ok($I0, 'lt_num false')
+.end
+
+.sub 'le'
+    $P1 = new ['Float']
+    $P1 = 111.1
+    $N1 = $P1
+
+    $I0 = 1
+    le $P1, 111.2, le_1
+    $I0 = 0
+  le_1:
+    ok($I0, 'le_p_nc')
+
+    $I0 = 1
+    le $P1, $N1, le_2
+    $I0 = 0
+  le_2:
+    ok($I0, 'le_p_n')
+
+    $I0 = 0
+    le $P1, 111.0, le_3
+    $I0 = 1
+  le_3:
+    ok($I0, 'le_p_nc false')
+
+    $I0 = 1
+    le $P1, $P1, le_4
+    $I0 = 0
+  le_4:
+    ok($I0, 'le reflexive')
+.end
+
+.sub 'le_num'
+    $P1 = new ['Float']
+    $P1 = 1.1
 
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'log10'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "log10(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-log10(1000.0) is 3.000000000
-log10(0.5) is -0.301029996
-OUTPUT
+    $P2 = 1.2
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'log2 as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 32.0
-    $P1 = $P0.'log2'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "log2(%.1f) is %.9f", array
-    say $S0
+    $P3 = new ['Float']
+    $P3 = 1.0
+
+    $P4 = new ['Float']
+    $P4 = $P1
+
+    $I0 = 1
+    le_num $P1, $P2, le_num_1
+    $I0 = 0
+  le_num_1:
+    ok($I0, 'le_num true')
+
+    $I0 = 1
+    le_num $P1, $P4, le_num_2
+    $I0 = 0
+  le_num_2:
+    ok($I0, 'le_num reflexive')
+
+    $I0 = 0
+    le_num $P1, $P3, le_num_3
+    $I0 = 1
+  le_num_3:
+    ok($I0, 'le_num false')
+.end
 
+.sub 'gt'
+    $P1 = new ['Float']
+    $P1 = 111.1
+    $N1 = $P1
+
+    $I0 = 0
+    gt $P1, 111.2, gt_1
+    $I0 = 1
+  gt_1:
+    ok($I0, 'comparison ops: gt nok')
+
+    $I0 = 1
+    gt $P1, $N1, gt_2
+    $I0 = 0
+  gt_2:
+    nok($I0, 'comparison ops: gt irreflexive')
+
+    $I0 = 1
+    gt $P1, 111.0, gt_3
+    $I0 = 0
+  gt_3:
+    ok($I0, 'comparison ops: gt ok')
+.end
+
+.sub 'gt_num'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'log2'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "log2(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-log2(32.0) is 5.000000000
-log2(0.5) is -1.000000000
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Float']
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'sec as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'sec'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "sec(%.1f) is %.9f", array
-    say $S0
+    $P1 = 1.1
+    $P2 = 1.2
+    $P3 = 1.0
+    $P4 = $P1
+
+    $I0 = 0
+    gt_num $P1, $P2, gt_num_1
+    $I0 = 1
+  gt_num_1:
+    ok($I0, 'comparison ops: gt_num nok')
+
+    $I0 = 0
+    gt_num $P1, $P4, gt_num_2
+    $I0 = 1
+  gt_num_2:
+    ok($I0, 'comparison ops: gt_num irreflexive')
+
+    $I0 = 1
+    gt_num $P1, $P3, gt_num_3
+    $I0 = 0
+  gt_num_3:
+    ok($I0, 'comparison ops: gt_num ok')
+.end
 
+.sub 'ge'
+    $P1 = new ['Float']
+    $P1 = 111.1
+    $N1 = $P1
+
+    $I0 = 0
+    ge $P1, 111.2, ge_1
+    $I0 = 1
+  ge_1:
+    ok($I0, 'comparison ops: ge nok')
+
+    $I0 = 1
+    ge $P1, $N1, ge_2
+    $I0 = 0
+  ge_2:
+    ok($I0, 'comparison ops: ge reflexive')
+
+    $I0 = 1
+    ge $P1, 111.0, ge_3
+    $I0 = 0
+  ge_3:
+    ok($I0, 'comparison ops: ge ok')
+.end
+
+.sub 'ge_num'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'sec'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "sec(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-sec(0.0) is 1.000000000
-sec(0.5) is 1.139493927
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Float']
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'sech as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'sech'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "sech(%.1f) is %.9f", array
-    say $S0
+    $P1 = 1.1
+    $P2 = 1.2
+    $P3 = 1.0
+    $P4 = $P1
+
+    $I0 = 0
+    ge_num $P1, $P2, ge_num_1
+    $I0 = 1
+  ge_num_1:
+    ok($I0, 'comparison ops: ge_num nok')
+
+    $I0 = 1
+    ge_num $P1, $P4, ge_num_2
+    $I0 = 0
+  ge_num_2:
+    ok($I0, 'comparison ops: ge_num reflexive')
+
+    $I0 = 1
+    ge_num $P1, $P3, ge_num_3
+    $I0 = 0
+  ge_num_3:
+    ok($I0, 'comparison ops: ge_num ok')
+.end
 
+.sub 'cmp_p_n'
+    $P1 = new ['Float']
+    $P1 = 123.45
+    $N1 = 123.45
+    $N2 = -1.0
+    $N3 = 123.54
+
+    $I0 = cmp $P1, $N1
+    is($I0, 0, 'comparison ops: cmp_p_n: equality')
+
+    $I0 = cmp $P1, $N2
+    is($I0, 1, 'comparison ops: cmp_p_n: gt')
+
+    $I0 = cmp $P1, $N3
+    is($I0, -1, 'comparison ops: cmp_p_n: lt')
+.end
+
+.sub 'isgt'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'sech'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "sech(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-sech(0.0) is 1.000000000
-sech(0.5) is 0.886818884
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Integer']
+    $P5 = new ['Integer']
+    $P6 = new ['Float']
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'sin as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'sin'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "sin(%.1f) is %.9f", array
-    say $S0
+    $P1 = 10.0
+    $P2 = 20.0
+    $P3 = 5.0
+    $P4 = 3
+    $P5 = 12
+    $P6 = 10.0
+
+    $I0 = isgt $P1, $P2
+    nok($I0, 'comparison ops: isgt nok')
+
+    $I0 = isgt $P1, $P1
+    nok($I0, 'comparison ops: isgt irreflexive')
+
+    $I0 = isgt $P1, $P3
+    ok($I0, 'comparison ops: isgt ok')
+
+    $I0 = isgt $P1, $P4
+    ok($I0, 'comparison ops: isgt ok with Float and Integer')
 
+    $I0 = isgt $P1, $P5
+    nok($I0, 'comparison ops: isgt nok with Float and Integer')
+
+    $I0 = isgt $P1, $P6
+    nok($I0, 'comparison ops: isgt irreflexive (different PMCs)')
+.end
+
+.sub 'isge'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'sin'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "sin(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-sin(0.0) is 0.000000000
-sin(0.5) is 0.479425539
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Integer']
+    $P5 = new ['Integer']
+    $P6 = new ['Float']
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'sinh as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'sinh'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "sinh(%.1f) is %.9f", array
-    say $S0
+    $P1 = 10.0
+    $P2 = 20.0
+    $P3 = 5.0
+    $P4 = 3
+    $P5 = 12
+    $P6 = 10.0
+
+    $I0 = isge $P1, $P2
+    nok($I0, 'comparison ops: isge nok')
+
+    $I0 = isge $P1, $P1
+    ok($I0, 'comparison ops: isge reflexive')
+
+    $I0 = isge $P1, $P3
+    ok($I0, 'comparison ops: isge ok')
+
+    $I0 = isge $P1, $P4
+    ok($I0, 'comparison ops: isge ok with Float and Integer')
+
+    $I0 = isge $P1, $P5
+    nok($I0, 'comparison ops: isge nok with Float and Integer')
+
+    $I0 = isge $P1, $P6
+    ok($I0, 'comparison ops: isge reflexive (different PMCs)')
+.end
 
+.sub 'islt'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'sinh'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "sinh(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-sinh(0.0) is 0.000000000
-sinh(0.5) is 0.521095305
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Integer']
+    $P5 = new ['Integer']
+    $P6 = new ['Float']
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'tan as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'tan'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "tan(%.1f) is %.9f", array
-    say $S0
+    $P1 = 10.0
+    $P2 = 20.0
+    $P3 = 5.0
+    $P4 = 3
+    $P5 = 12
+    $P6 = 10.0
+
+    $I0 = islt $P1, $P2
+    ok($I0, 'comparison ops: islt ok')
+
+    $I0 = islt $P1, $P1
+    nok($I0, 'comparison ops: islt irreflexive')
+
+    $I0 = islt $P1, $P3
+    nok($I0, 'comparison ops: islt nok')
+
+    $I0 = islt $P1, $P4
+    nok($I0, 'comparison ops: islt nok with Float and Integer')
 
+    $I0 = islt $P1, $P5
+    ok($I0, 'comparison ops: islt ok with Float and Integer')
+
+    $I0 = islt $P1, $P6
+    nok($I0, 'comparison ops: islt irreflexive (different PMCs)')
+.end
+
+.sub 'isle'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'tan'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "tan(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-tan(0.0) is 0.000000000
-tan(0.5) is 0.546302490
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Integer']
+    $P5 = new ['Integer']
+    $P6 = new ['Float']
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'tanh as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
-    .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
-    $P0 = new ['Float']
-    $P0 = 0.0
-    $P1 = $P0.'tanh'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "tanh(%.1f) is %.9f", array
-    say $S0
+    $P1 = 10.0
+    $P2 = 20.0
+    $P3 = 5.0
+    $P4 = 3
+    $P5 = 12
+    $P6 = 10.0
+
+    $I0 = isle $P1, $P2
+    ok($I0, 'comparison ops: isle ok')
+
+    $I0 = isle $P1, $P1
+    ok($I0, 'comparison ops: isle reflexive')
 
+    $I0 = isle $P1, $P3
+    nok($I0, 'comparison ops: isle nok')
+
+    $I0 = isle $P1, $P4
+    nok($I0, 'comparison ops: isle nok with Float and Integer')
+
+    $I0 = isle $P1, $P5
+    ok($I0, 'comparison ops: isle ok with Float and Integer')
+
+    $I0 = isle $P1, $P6
+    ok($I0, 'comparison ops: isle reflexive (different PMCs)')
+.end
+
+.sub 'iseq'
+    $P1 = new ['Float']
     $P2 = new ['Float']
-    $P2 = 0.5
-    $P3 = $P2.'tanh'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "tanh(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-tanh(0.0) is 0.000000000
-tanh(0.5) is 0.462117157
-OUTPUT
+    $P3 = new ['Float']
+    $P4 = new ['Integer']
+
+    $P1 = 2.5
+    $P2 = 2.6
+    $P3 = 2.5
+    $P4 = 2
+
+    $I0 = iseq $P1, $P1
+    ok($I0, 'iseq reflexive, same PMC')
+
+    $I0 = iseq $P1, $P3
+    ok($I0, 'iseq reflexive, different PMCs')
+
+    $I0 = iseq $P1, $P2
+    nok($I0, 'iseq nok with two Floats')
+
+    $I0 = iseq $P1, $P4
+    nok($I0, 'iseq nok between an Integer and a Float')
+.end
+
+.sub 'isne'
+    $P1 = new ['Float']
+    $P2 = new ['Float']
+    $P3 = new ['Float']
+    $P4 = new ['Integer']
+
+    $P1 = 2.5
+    $P2 = 2.6
+    $P3 = 2.5
+    $P4 = 2
+
+    $I0 = isne $P1, $P1
+    nok($I0, 'isne irreflexive, same PMC')
+
+    $I0 = isne $P1, $P3
+    nok($I0, 'isne irreflexive, different PMCs')
+
+    $I0 = isne $P1, $P2
+    ok($I0, 'isne ok with two Floats')
+
+    $I0 = isne $P1, $P4
+    ok($I0, 'isne ok between an Integer and a Float')
+.end
+
+.sub 'instantiate_str'
+    .const 'Float' pi = "3.1"
+    $P1 = get_class ['Float']
+    isa_ok(pi, $P1)
+    is(pi, 3.1, 'instantiate_str', PRECISION)
+.end
+
+.sub 'cmp_subclasses'
+    $P0 = subclass 'Float', 'Flt'
+
+    $P1 = new ['Flt']
+    $P1 = 1.5
+
+    $P2 = new ['Flt']
+    $P2 = 2.73
+
+    $I0 = cmp $P1, $P2
+    is(-1, $I0, 'cmp functions for subclasses (lt)')
+
+    $I0 = cmp $P1, $P1
+    is(0, $I0, 'cmp functions for subclasses (eq)')
+
+    $I0 = cmp $P2, $P1
+    is(1, $I0, 'cmp functions for subclasses (gt)')
+.end
+
+.sub 'test_method'
+    .param string method
+    .param num number
+    .param num expected
 
-pir_output_is( <<'CODE', <<'OUTPUT', 'sqrt as a method' );
-.include 'fp_equality.pasm'
-.sub main :main
     .local pmc array
-    array = new 'FixedFloatArray'
-    array = 2
+    array = new 'FixedPMCArray'
+    array = 3
+    array[0] = method
+    array[1] = number
+    array[2] = expected
+
     $P0 = new ['Float']
-    $P0 = 16.0
-    $P1 = $P0.'sqrt'()
-    array[0] = $P0
-    array[1] = $P1
-    $S0 = sprintf "sqrt(%.1f) is %.9f", array
-    say $S0
+    $P0 = number
+    $P1 = $P0.method()
 
-    $P2 = new ['Float']
-    $P2 = 2.0
-    $P3 = $P2.'sqrt'()
-    array[0] = $P2
-    array[1] = $P3
-    $S0 = sprintf "sqrt(%.1f) is %.9f", array
-    say $S0
-.end
-CODE
-sqrt(16.0) is 4.000000000
-sqrt(2.0) is 1.414213562
-OUTPUT
+    $S0 = sprintf '%s(%.1f) is %.9f', array
+    is($P1, expected, $S0, PRECISION)
+.end
+
+.sub 'acos_method'
+    test_method('acos', 0.0, 1.570796327)
+    test_method('acos', 0.5, 1.047197551)
+.end
+
+.sub 'cos_method'
+    test_method('cos', 0.0, 1.0)
+    test_method('cos', 0.5, 0.877582562)
+.end
+
+.sub 'asec_method'
+    test_method('asec', 1.0, 0.0)
+    test_method('asec', 3.0, 1.230959417)
+.end
+
+.sub 'asin_method'
+    test_method('asin', 0.0, 0.0)
+    test_method('asin', 0.5, 0.523598776)
+.end
+
+.sub 'atan_method'
+    test_method('atan', 0.0, 0.0)
+    test_method('atan', 0.5, 0.463647609)
+.end
+
+.sub 'atan2_method'
+    $P0 = new ['Float']
+    $P1 = new ['Float']
+
+    $P0 = 0.7
+    $P1 = 0.5
+
+    $P2 = $P0.'atan2'($P1)
+    is($P2, 0.950546841, 'atan2 as a method', PRECISION)
+.end
+
+.sub 'cosh_method'
+    test_method('cosh', 0.0, 1.0)
+    test_method('cosh', 0.5, 1.127625965)
+.end
+
+.sub 'exp_method'
+    test_method('exp', 0.0, 1.0)
+    test_method('exp', 0.5, 1.648721271)
+.end
 
+.sub 'ln_method'
+    test_method('ln', 1.0, 0.0)
+    test_method('ln', 45.0, 3.806662490)
+    test_method('ln', 0.5, -0.693147181)
+.end
+
+.sub 'log10_method'
+    test_method('log10', 1000.0, 3.0)
+    test_method('log10', 0.5, -0.301029996)
+.end
+
+.sub 'log2_method'
+    test_method('log2', 32.0, 5.0)
+    test_method('log2', 0.5, -1.0)
+.end
+
+.sub 'sec_method'
+    test_method('sec', 0.0, 1.0)
+    test_method('sec', 0.5, 1.139493927)
+.end
+
+.sub 'sech_method'
+    test_method('sech', 0.0, 1.0)
+    test_method('sech', 0.5, 0.886818884)
+.end
+
+.sub 'sin_method'
+    test_method('sin', 0.0, 0.0)
+    test_method('sin', 0.5, 0.479425539)
+.end
+
+.sub 'sinh_method'
+    test_method('sinh', 0.0, 0.0)
+    test_method('sinh', 0.5, 0.521095305)
+.end
+
+.sub 'tan_method'
+    test_method('tan', 0.0, 0.0)
+    test_method('tan', 0.5, 0.546302490)
+.end
+
+.sub 'tanh_method'
+    test_method('tanh', 0.0, 0.0)
+    test_method('tanh', 0.5, 0.462117157)
+.end
+
+.sub 'sqrt_method'
+    test_method('sqrt', 16.0, 4.0)
+    test_method('sqrt', 2.0, 1.414213562)
+.end
 
 # Local Variables:
-#   mode: cperl
-#   cperl-indent-level: 4
+#   mode: pir
 #   fill-column: 100
 # End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 ft=pir:


More information about the parrot-commits mailing list