GT-3106: Implement AVR 8 pcodetests

Updated AVR 8 to implement pcode tests and correct any issues found as a
result.
This commit is contained in:
ghidorahrex 2019-09-04 09:37:23 -04:00
parent 20ac7ece0a
commit 947b7635ce
28 changed files with 3992 additions and 3398 deletions

View file

@ -1,197 +1,199 @@
#include "pcode_test.h"
/* Comparison operators */
#ifdef HAS_DOUBLE
TEST biopEqf8f8_Main()
TEST f8_greaterThan_Main()
{
extern f8 biopEqf8f8(f8 lhs, f8 rhs);
extern f8 f8_greaterThan(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopEqf8f8(lhs, rhs);
retVal = f8_greaterThan(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(f8_greaterThan(PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(f8_greaterThan(PI_SHORT, 2*PI_SHORT), 0.0);
ASSERTF8(f8_greaterThan(2*PI_SHORT, PI_SHORT), 1.0);
}
#endif
#ifdef HAS_DOUBLE
TEST f8_greaterThanEquals_Main()
{
extern f8 f8_greaterThanEquals(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = f8_greaterThanEquals(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(f8_greaterThanEquals(PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(f8_greaterThanEquals(PI_SHORT, 2*PI_SHORT), 0.0);
ASSERTF8(f8_greaterThanEquals(2*PI_SHORT, PI_SHORT), 1.0);
}
#endif
#ifdef HAS_DOUBLE
TEST f8_lessThan_Main()
{
extern f8 f8_lessThan(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = f8_lessThan(lhs, rhs);
ASSERTF8(retVal, 0);
ASSERTF8(biopEqf8f8(PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(biopEqf8f8(PI_SHORT, 2*PI_SHORT), 0.0);
ASSERTF8(biopEqf8f8(2*PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(f8_lessThan(PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(f8_lessThan(PI_SHORT, 2*PI_SHORT), 1.0);
ASSERTF8(f8_lessThan(2*PI_SHORT, PI_SHORT), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST biopNef8f8_Main()
TEST f8_lessThanEquals_Main()
{
extern f8 biopNef8f8(f8 lhs, f8 rhs);
extern f8 f8_lessThanEquals(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopNef8f8(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(biopNef8f8(PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(biopNef8f8(PI_SHORT, 2*PI_SHORT), 1.0);
ASSERTF8(biopNef8f8(2*PI_SHORT, PI_SHORT), 1.0);
}
#endif
#ifdef HAS_DOUBLE
TEST biopLogicOrf8f8_Main()
{
extern f8 biopLogicOrf8f8(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopLogicOrf8f8(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(biopLogicOrf8f8(PI_SHORT, PI_SHORT), 1);
ASSERTF8(biopLogicOrf8f8(PI_SHORT, 0), 1);
}
#endif
#ifdef HAS_DOUBLE
TEST biopLogicAndf8f8_Main()
{
extern f8 biopLogicAndf8f8(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopLogicAndf8f8(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(biopLogicAndf8f8(PI_SHORT, PI_SHORT), 1);
ASSERTF8(biopLogicAndf8f8(PI_SHORT, 0), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST unopNotf8_Main()
{
extern f8 unopNotf8(f8 lhs);
f8 lhs = 2;
f8 retVal;
retVal = unopNotf8(lhs);
retVal = f8_lessThanEquals(lhs, rhs);
ASSERTF8(retVal, 0);
ASSERTF8(unopNotf8(PI_SHORT), 0);
ASSERTF8(f8_lessThanEquals(PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(f8_lessThanEquals(PI_SHORT, 2*PI_SHORT), 1.0);
ASSERTF8(f8_lessThanEquals(2*PI_SHORT, PI_SHORT), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST unopNegativef8_Main()
TEST f8_equals_Main()
{
extern f8 unopNegativef8(f8 lhs);
extern f8 f8_equals(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = f8_equals(lhs, rhs);
ASSERTF8(retVal, 0);
ASSERTF8(f8_equals(PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(f8_equals(PI_SHORT, 2*PI_SHORT), 0.0);
ASSERTF8(f8_equals(2*PI_SHORT, PI_SHORT), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST f8_notEquals_Main()
{
extern f8 f8_notEquals(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = f8_notEquals(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(f8_notEquals(PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(f8_notEquals(PI_SHORT, 2*PI_SHORT), 1.0);
ASSERTF8(f8_notEquals(2*PI_SHORT, PI_SHORT), 1.0);
}
#endif
/* Logical operators */
#ifdef HAS_DOUBLE
TEST f8_logicalAnd_Main()
{
extern f8 f8_logicalAnd(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = f8_logicalAnd(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(f8_logicalAnd(PI_SHORT, PI_SHORT), 1);
ASSERTF8(f8_logicalAnd(PI_SHORT, 0), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST f8_logicalOr_Main()
{
extern f8 f8_logicalOr(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = f8_logicalOr(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(f8_logicalOr(PI_SHORT, PI_SHORT), 1);
ASSERTF8(f8_logicalOr(PI_SHORT, 0), 1);
}
#endif
#ifdef HAS_DOUBLE
TEST f8_logicalNot_Main()
{
extern f8 f8_logicalNot(f8 lhs);
f8 lhs = 2;
f8 retVal;
retVal = unopNegativef8(lhs);
retVal = f8_logicalNot(lhs);
ASSERTF8(retVal, 0);
ASSERTF8(f8_logicalNot(PI_SHORT), 0);
}
#endif
/* Arithmetic operators */
#ifdef HAS_DOUBLE
TEST f8_unaryMinus_Main()
{
extern f8 f8_unaryMinus(f8 lhs);
f8 lhs = 2;
f8 retVal;
retVal = f8_unaryMinus(lhs);
ASSERTF8(retVal, -2);
ASSERTF8(unopNegativef8(PI_SHORT), -3.14);
ASSERTF8(f8_unaryMinus(PI_SHORT), -3.14);
}
#endif
#ifdef HAS_DOUBLE
TEST unopPlusf8_Main()
TEST f8_unaryPlus_Main()
{
extern f8 unopPlusf8(f8 lhs);
extern f8 f8_unaryPlus(f8 lhs);
f8 lhs = 2;
f8 retVal;
retVal = unopPlusf8(lhs);
retVal = f8_unaryPlus(lhs);
ASSERTF8(retVal, 2);
ASSERTF8(unopPlusf8(PI_SHORT), PI_SHORT);
ASSERTF8(f8_unaryPlus(PI_SHORT), PI_SHORT);
}
#endif
#ifdef HAS_DOUBLE
TEST biopMultf8f8_Main()
TEST f8_addition_Main()
{
extern f8 biopMultf8f8(f8 lhs, f8 rhs);
extern f8 f8_addition(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopMultf8f8(lhs, rhs);
ASSERTF8(retVal, 2);
ASSERTF8(biopMultf8f8(PI_SHORT, PI_SHORT), 9.8596);
}
#endif
#ifdef HAS_DOUBLE
TEST biopSubf8f8_Main()
{
extern f8 biopSubf8f8(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopSubf8f8(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(biopSubf8f8(PI_SHORT, PI_SHORT), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST biopAddf8f8_Main()
{
extern f8 biopAddf8f8(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopAddf8f8(lhs, rhs);
retVal = f8_addition(lhs, rhs);
ASSERTF8(retVal, 3);
ASSERTF8(biopAddf8f8(PI_SHORT, PI_SHORT), 6.28);
ASSERTF8(f8_addition(PI_SHORT, PI_SHORT), 6.28);
}
#endif
#ifdef HAS_DOUBLE
TEST biopGtf8f8_Main()
TEST f8_subtract_Main()
{
extern f8 biopGtf8f8(f8 lhs, f8 rhs);
extern f8 f8_subtract(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopGtf8f8(lhs, rhs);
retVal = f8_subtract(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(biopGtf8f8(PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(biopGtf8f8(PI_SHORT, 2*PI_SHORT), 0.0);
ASSERTF8(biopGtf8f8(2*PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(f8_subtract(PI_SHORT, PI_SHORT), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST biopGef8f8_Main()
TEST f8_multiply_Main()
{
extern f8 biopGef8f8(f8 lhs, f8 rhs);
extern f8 f8_multiply(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopGef8f8(lhs, rhs);
ASSERTF8(retVal, 1);
ASSERTF8(biopGef8f8(PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(biopGef8f8(PI_SHORT, 2*PI_SHORT), 0.0);
ASSERTF8(biopGef8f8(2*PI_SHORT, PI_SHORT), 1.0);
}
#endif
#ifdef HAS_DOUBLE
TEST biopLtf8f8_Main()
{
extern f8 biopLtf8f8(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopLtf8f8(lhs, rhs);
ASSERTF8(retVal, 0);
ASSERTF8(biopLtf8f8(PI_SHORT, PI_SHORT), 0.0);
ASSERTF8(biopLtf8f8(PI_SHORT, 2*PI_SHORT), 1.0);
ASSERTF8(biopLtf8f8(2*PI_SHORT, PI_SHORT), 0.0);
}
#endif
#ifdef HAS_DOUBLE
TEST biopLef8f8_Main()
{
extern f8 biopLef8f8(f8 lhs, f8 rhs);
f8 lhs = 2;
f8 rhs = 1;
f8 retVal;
retVal = biopLef8f8(lhs, rhs);
ASSERTF8(retVal, 0);
ASSERTF8(biopLef8f8(PI_SHORT, PI_SHORT), 1.0);
ASSERTF8(biopLef8f8(PI_SHORT, 2*PI_SHORT), 1.0);
ASSERTF8(biopLef8f8(2*PI_SHORT, PI_SHORT), 0.0);
retVal = f8_multiply(lhs, rhs);
ASSERTF8(retVal, 2);
ASSERTF8(f8_multiply(PI_SHORT, PI_SHORT), 9.8596);
}
#endif
MAIN BIOPS_DOUBLE_main() { }