view tests/mini/floatcmp.d @ 1650:40bd4a0d4870

Update to work with LLVM 2.7. Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
author Tomas Lindquist Olsen
date Wed, 19 May 2010 12:42:32 +0200
parents 1bb99290e03a
children
line wrap: on
line source

module floatcmp;
extern(C) int printf(char*, ...);

void eq()
{
    float _3 = 3;
    assert(!(_3 == 4));
    assert(!(_3 == 2));
    assert(_3 == 3);
    assert(!(_3 == float.nan));
}

void neq()
{
    float _3 = 3;
    assert(_3 != 4);
    assert(_3 != 2);
    assert(!(_3 != 3));
    assert(_3 != float.nan);
}

void gt()
{
    float _3 = 3;
    assert(_3 > 2);
    assert(!(_3 > 4));
    assert(!(_3 > 3));
    assert(!(_3 > float.nan));
}

void ge()
{
    float _3 = 3;
    assert(_3 >= 2);
    assert(!(_3 >= 4));
    assert(_3 >= 3);
    assert(!(_3 >= float.nan));
}

void lt()
{
    float _3 = 3;
    assert(_3 < 4);
    assert(!(_3 < 2));
    assert(!(_3 < 3));
    assert(!(_3 < float.nan));
}

void le()
{
    float _3 = 3;
    assert(_3 <= 4);
    assert(!(_3 <= 2));
    assert(_3 <= 3);
    assert(!(_3 <= float.nan));
}

void uno()
{
    float _3 = 3;
    assert(!(_3 !<>= 2));
    assert(!(_3 !<>= 3));
    assert(!(_3 !<>= 4));
    assert(_3 !<>= float.nan);
}

void lg()
{
    float _3 = 3;
    assert(_3 <> 4);
    assert(_3 <> 2);
    assert(!(_3 <> 3));
    assert(!(_3 <> float.nan));
}

void lge()
{
    float _3 = 3;
    assert(_3 <>= 4);
    assert(_3 <>= 2);
    assert(_3 <>= 3);
    assert(!(_3 <>= float.nan));
}

void ugt()
{
    float _3 = 3;
    assert(_3 !<= 2);
    assert(!(_3 !<= 4));
    assert(!(_3 !<= 3));
    assert(_3 !<= float.nan);
}

void uge()
{
    float _3 = 3;
    assert(_3 !< 2);
    assert(!(_3 !< 4));
    assert(_3 !< 3);
    assert(_3 !< float.nan);
}

void ult()
{
    float _3 = 3;
    assert(_3 !>= 4);
    assert(!(_3 !>= 2));
    assert(!(_3 !>= 3));
    assert(_3 !>= float.nan);
}

void ule()
{
    float _3 = 3;
    assert(_3 !> 4);
    assert(!(_3 !> 2));
    assert(_3 !> 3);
    assert(_3 !> float.nan);
}

void ueq()
{
    float _3 = 3;
    assert(!(_3 !<> 2));
    assert(!(_3 !<> 4));
    assert(_3 !<> 3);
    assert(_3 !<> float.nan);
}

void main()
{
    printf("floating point comparison test\n");
    
    eq();
    neq();
    gt();
    ge();
    lt();
    le();
    uno();
    lg();
    lge();
    ugt();
    uge();
    ult();
    ule();
    ueq();
    
    printf("  SUCCESS\n");
}

/+
void gt()
{
    float _3 = 3;
    assert();
    assert();
    assert();
    assert();
}
+/