Skip to content

Commit

Permalink
Fix TestEqualityPrecedence, enable
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhmm committed Mar 2, 2024
1 parent fb5d580 commit 79245de
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
76 changes: 39 additions & 37 deletions libskrypt/skrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ namespace {
void Skrypt::ProcessQuestionLine(std::string_view& line)
{
Valuable::YesNoMaybe is = Valuable::YesNoMaybe::Maybe;
auto& total = Total();
auto questionless = Questionless(line);
if (questionless.empty()) {
for (auto& [name, var] : vars) {
Expand All @@ -123,42 +122,45 @@ void Skrypt::ProcessQuestionLine(std::string_view& line)
} else {
is = Valuable::YesNoMaybe::No;
}
} else if (total.IsSum()) {
auto rest = total / expression;
std::cout << "Total: " << total << std::endl
<< total << " / " << expression << ": " << rest << std::endl;
auto& totalSum = total.as<Sum>();
if (lineVars.size() == 1) {
std::vector<Valuable> coefficients;
auto& va = *lineVars.begin();
auto totalGrade = totalSum.FillPolyCoeff(coefficients, va);
coefficients.clear();
if (expression.IsSum()) {
auto& lineSum = expression.as<Sum>();
auto lineGrade = lineSum.FillPolyCoeff(coefficients, va);
if (rest.IsSum()) {
auto restGrade = rest.as<Sum>().FillPolyCoeff(coefficients, va);
if (totalGrade == restGrade + lineGrade)
is = Valuable::YesNoMaybe::Yes;
}
}
else if (expression.IsVa()) {
auto solutions = Solve(expression.as<Variable>());
if (solutions.size() == 1) {
if(solutions.cbegin()->operator==(0))
is = Valuable::YesNoMaybe::Yes;
}
}
}
else {
IMPLEMENT
}
} else if (total == constants::zero) {
} else if (total.IsInt()) {
is = Valuable::YesNoMaybe::No;
}
else {
IMPLEMENT
} else try {
auto total = MakeTotalEqu() ? Total() : CalculateTotalExpression();
if (total.IsSum()) {
auto rest = total / expression;
std::cout << "Total: " << total << std::endl
<< total << " / " << expression << ": " << rest << std::endl;
auto& totalSum = total.as<Sum>();
if (lineVars.size() == 1) {
std::vector<Valuable> coefficients;
auto& va = *lineVars.begin();
auto totalGrade = totalSum.FillPolyCoeff(coefficients, va);
coefficients.clear();
if (expression.IsSum()) {
auto& lineSum = expression.as<Sum>();
auto lineGrade = lineSum.FillPolyCoeff(coefficients, va);
if (rest.IsSum()) {
auto restGrade = rest.as<Sum>().FillPolyCoeff(coefficients, va);
if (totalGrade == restGrade + lineGrade)
is = Valuable::YesNoMaybe::Yes;
}
} else if (expression.IsVa()) {
auto solutions = Solve(expression.as<Variable>());
if (solutions.size() == 1) {
if (solutions.cbegin()->operator==(0))
is = Valuable::YesNoMaybe::Yes;
}
}
} else {
IMPLEMENT
}
} else if (total == constants::zero) {
} else if (total.IsInt()) {
is = Valuable::YesNoMaybe::No;
} else {
IMPLEMENT
}
}
catch (...) {
is = Valuable::YesNoMaybe::Maybe;
}

std::cout << '\n' << expression << " ?\n";
Expand Down
4 changes: 1 addition & 3 deletions libskrypt/tests/TestExpPrecedence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ BOOST_AUTO_TEST_CASE(skryptExpOrdertest
BOOST_TEST(solutionsWithExpNoBrackets == solutions);
}

BOOST_AUTO_TEST_CASE(TestEqualityPrecedence
, *boost::unit_test::disabled()
) {
BOOST_AUTO_TEST_CASE(TestEqualityPrecedence) {
Skrypt skryptWithBrackets;
skryptWithBrackets.Load(TEST_SRC_DIR "TestEqualityPrecedence.skrypt");
}

0 comments on commit 79245de

Please sign in to comment.