mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] Fix tests
This commit is contained in:
@@ -141,7 +141,11 @@ void assert_parsed_expression_evaluates_to(const char * expression, const char *
|
||||
int numberOfDigits = sizeof(T) == sizeof(double) ? PrintFloat::k_numberOfStoredSignificantDigits : PrintFloat::k_numberOfPrintedSignificantDigits;
|
||||
numberOfDigits = numberOfSignificantDigits > 0 ? numberOfSignificantDigits : numberOfDigits;
|
||||
assert_parsed_expression_process_to(expression, approximation, angleUnit, complexFormat, [](Expression e, Context & context, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat) {
|
||||
return e.simplify(context, angleUnit).approximate<T>(context, angleUnit, complexFormat);
|
||||
Expression result = e.clone().simplify(context, angleUnit);
|
||||
if (result.isUninitialized()) {
|
||||
result = e;
|
||||
}
|
||||
return result.approximate<T>(context, angleUnit, complexFormat);
|
||||
}, numberOfDigits);
|
||||
}
|
||||
|
||||
@@ -149,7 +153,12 @@ void assert_parsed_expression_simplify_to(const char * expression, const char *
|
||||
#if POINCARE_TESTS_PRINT_EXPRESSIONS
|
||||
cout << "--------- Simplification ---------" << endl;
|
||||
#endif
|
||||
assert_parsed_expression_process_to(expression, simplifiedExpression, angleUnit, Preferences::ComplexFormat::Cartesian, [](Expression e, Context & context, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat) { return e.simplify(context, angleUnit); });
|
||||
assert_parsed_expression_process_to(expression, simplifiedExpression, angleUnit, Preferences::ComplexFormat::Cartesian, [](Expression e, Context & context, Preferences::AngleUnit angleUnit, Preferences::ComplexFormat complexFormat) {
|
||||
Expression result = e.clone().simplify(context, angleUnit);
|
||||
if (result.isUninitialized()) {
|
||||
return e;
|
||||
}
|
||||
return result;});
|
||||
}
|
||||
|
||||
void assert_parsed_expression_serialize_to(Expression expression, const char * serializedExpression, Preferences::PrintFloatMode mode, int numberOfSignifiantDigits) {
|
||||
|
||||
@@ -72,14 +72,24 @@ QUIZ_CASE(poincare_store_that_should_fail) {
|
||||
}
|
||||
|
||||
QUIZ_CASE(poincare_store_overwrite) {
|
||||
assert_parsed_expression_simplify_to("2>g", "2");
|
||||
assert_parsed_expression_simplify_to("-1>g(x)", "-1");
|
||||
assert_parsed_expression_evaluates_to<double>("g(4)", "-1");
|
||||
|
||||
// Clean the storage for other tests
|
||||
Ion::Storage::sharedStorage()->recordNamed("g.func").destroy();
|
||||
}
|
||||
|
||||
QUIZ_CASE(poincare_store_do_not_overwrite) {
|
||||
assert_parsed_expression_simplify_to("-1>g(x)", "-1");
|
||||
assert_parsed_expression_simplify_to("1+g(x)>f(x)", "1+g(?)");
|
||||
assert_parsed_expression_simplify_to("2>g", "2");
|
||||
assert_parsed_expression_evaluates_to<double>("g(4)", "undef");
|
||||
assert_parsed_expression_evaluates_to<double>("f(4)", "undef");
|
||||
assert_parsed_expression_simplify_to("2>g", "undef");
|
||||
assert_parsed_expression_evaluates_to<double>("g(4)", "-1");
|
||||
assert_parsed_expression_evaluates_to<double>("f(4)", "0");
|
||||
|
||||
// Clean the storage for other tests
|
||||
Ion::Storage::sharedStorage()->recordNamed("f.func").destroy();
|
||||
Ion::Storage::sharedStorage()->recordNamed("g.exp").destroy();
|
||||
Ion::Storage::sharedStorage()->recordNamed("g.func").destroy();
|
||||
}
|
||||
|
||||
QUIZ_CASE(poincare_store_2_circular_variables) {
|
||||
|
||||
Reference in New Issue
Block a user