Skip to content

Commit

Permalink
Implement '<' and enable Less_operator_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhmm committed Aug 18, 2024
1 parent de2b91c commit a3af5f6
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions omnn/math/test/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,56 @@ BOOST_AUTO_TEST_CASE(LessOrEqual_operator_test) {
}
}

BOOST_AUTO_TEST_CASE(Less_operator_test
, *disabled() // FIXME:
) {
DECL_VARS(X, Y);
auto LE = X.Less(Y);
std::cout << "X<Y : " << LE << std::endl;
for (auto x = 10; x--> -10;) {
for (auto y = 10; y--> -10;) {
auto isLess = x < y;
auto lessOperatorInstantiation = LE;
Valuable::vars_cont_t evalMap = {{X, x}, {Y, y}};
std::cout << '\n' << x << "<" << y << " = ";
lessOperatorInstantiation.eval(evalMap);
std::cout << " expression that must be equal to zero when true: " << lessOperatorInstantiation
<< std::endl;

lessOperatorInstantiation.optimize();
std::cout << std::endl << "Is " << x << "<" << y << " : " << lessOperatorInstantiation << std::endl;
bool b = {};
auto boolLessOp = lessOperatorInstantiation.ToBool();
BOOST_TEST(boolLessOp == isLess);
boolLessOp.eval(evalMap);
BOOST_TEST(boolLessOp == isLess);
if (boolLessOp == true) {
BOOST_TEST(boolLessOp.IsInt());
BOOST_TEST(lessOperatorInstantiation.IsInt());
b = lessOperatorInstantiation.IsInt() && lessOperatorInstantiation.ca() == 0;
std::cout << std::endl << x << "<" << y << " : " << b << std::endl;
} else if (boolLessOp == false) {
BOOST_TEST(boolLessOrEqualOp.IsInt());
b = lessOperatorInstantiation == 0;
std::cout << std::endl
<< x << "<" << y << " : " << (b ? "true; " : "false; ")
<< lessOperatorInstantiation << " != 0" << std::endl;
} else {
std::cout << std::endl << x << "<" << y << " : " << boolLessOp << std::endl;
BOOST_TEST(!"boolLessOp must have boolean value");
}
BOOST_TEST(boolLessOrEqualOp == b);

auto ok = b == isLess;
if (!ok) {
std::cout << "X=" << x << " Y=" << y << ' ' << ok << " bool: " << b << std::endl;
BOOST_TEST(ok);
}
}
}
}


BOOST_AUTO_TEST_CASE(Delta_function_test
, *disabled() // FIXME:
) { // https://en.wikipedia.org/wiki/Dirac_delta_function
Expand Down Expand Up @@ -152,9 +202,9 @@ BOOST_AUTO_TEST_CASE(ifz_tests) {
}
}

BOOST_AUTO_TEST_CASE(Less_operator_test
, *disabled() // FIXME:
) {
BOOST_AUTO_TEST_CASE(Less_cmp_test
, *disabled() // FIXME:
){
DECL_VARS(X, Y);
auto Less = X.Less(Y);
std::cout << "X<Y : " << Less << std::endl;
Expand Down

0 comments on commit a3af5f6

Please sign in to comment.