diff --git a/compiler2/Real.cc b/compiler2/Real.cc index 87632b85ff2327659d2a9e38c755ab561a2be545..c9f5a8179783037f979b0a426e4085f1a5b19b4c 100644 --- a/compiler2/Real.cc +++ b/compiler2/Real.cc @@ -32,11 +32,6 @@ namespace Common { { return ((r!=r) || (r==REAL_INFINITY) || (r==-REAL_INFINITY)); } - - bool isNaN(const Real& r) - { - return r!=r; - } string Real2string(const Real& r) { diff --git a/compiler2/Real.hh b/compiler2/Real.hh index 2259d1eca31f3e742011fb8ba0a5cca24b415132..1d6ebcf35df7634ade3edc84ff2281d6bdce42e0 100644 --- a/compiler2/Real.hh +++ b/compiler2/Real.hh @@ -55,7 +55,6 @@ namespace Common { /** +/- infinity and not_a_number are non-numeric float values in ttcn-3, these special values cannot be used in some places */ bool isSpecialFloatValue(const Real& r); - bool isNaN(const Real& r); /** * Converts the Common::Real value to string. diff --git a/compiler2/Value.cc b/compiler2/Value.cc index 6d3efe51df92f0305263221c1d573c3fff516c12..babf951260e0eea8d6933bb7c140a6e543ed0362 100644 --- a/compiler2/Value.cc +++ b/compiler2/Value.cc @@ -6396,47 +6396,6 @@ error: set_valuetype(V_ERROR); } } - - void Value::chk_expr_operand_valid_float(Value* v1, Value* v2, const char *opnum1, const char *opnum2, const char *opname) - { - ttcn3float r1, r2; - boolean r1_is_set = FALSE, r2_is_set = FALSE; - if(valuetype!=V_ERROR) { - if(u.expr.state!=EXPR_CHECKING_ERR) { - if(!v1->is_unfoldable()) { - if(v1->get_expr_returntype()==Type::T_REAL) { - r1 = v1->get_val_Real(); - r1_is_set = TRUE; - } - } - if(!v2->is_unfoldable()) { - if(v2->get_expr_returntype()==Type::T_REAL) { - r2 = v2->get_val_Real(); - r2_is_set = TRUE; - } - } - if (r1_is_set && r2_is_set) { - if ((isSpecialFloatValue(r1) && isSpecialFloatValue(r2)) || isNaN(r1) || isNaN(r2)) { - error("Invalid operands of float %s: %s operand is %s, %s operand is %s", - opname, opnum1, Real2string(r1).c_str(), opnum2, Real2string(r2).c_str()); - set_valuetype(V_ERROR); - } - } else if (r1_is_set) { - if (isNaN(r1)) { - v1->error("%s operand of operation `%s' cannot be %s, it must be a numeric value", - opnum1, opname, Real2string(r1).c_str()); - set_valuetype(V_ERROR); - } - } else if (r2_is_set) { - if (isNaN(r2)) { - v2->error("%s operand of operation `%s' cannot be %s, it must be a numeric value", - opnum2, opname, Real2string(r2).c_str()); - set_valuetype(V_ERROR); - } - } - } - } - } void Value::chk_expr_operands(ReferenceChain *refch, Type::expected_value_t exp_val) @@ -6943,7 +6902,7 @@ error: chk_expr_operandtype_int_float(tt2, second, opname, v2); chk_expr_eval_value(v1, t_chk, refch, exp_val); chk_expr_eval_value(v2, t_chk, refch, exp_val); - chk_expr_operand_valid_float(v1, v2, first, second, opname); + // No float checks needed, everything is allowed on -+infinity and not_a_number if(u.expr.v_optype==OPTYPE_DIVIDE) chk_expr_val_int_float_not0(v2, second, opname); chk_expr_operandtypes_same(tt1, tt2, opname); diff --git a/compiler2/Value.hh b/compiler2/Value.hh index b53051033579e477b4cffb95d896494e3ff3cf2c..ba32dd28e34a2779829313b276e62afe4a99e6f9 100644 --- a/compiler2/Value.hh +++ b/compiler2/Value.hh @@ -668,7 +668,6 @@ namespace Common { void chk_expr_operands(ReferenceChain *refch, Type::expected_value_t exp_val); void chk_expr_operand_valid_float(Value* v, const char *opnum, const char *opname); - void chk_expr_operand_valid_float(Value* v1, Value* v2, const char *opnum1, const char *opnum2, const char *opname); /** Evaluate... * Called by Value::get_value_refd_last() for V_EXPR */ void evaluate_value(ReferenceChain *refch, Type::expected_value_t exp_val); diff --git a/compiler2/XSD_Types.hh b/compiler2/XSD_Types.hh index 00f2142ad041bd760870521845c9964e2856b497..5a93bf8c888bcc7cb182ce8f7443d7af6793e509 100644 --- a/compiler2/XSD_Types.hh +++ b/compiler2/XSD_Types.hh @@ -77,4 +77,4 @@ const char * XSD_type_to_xml_type(const XSD_types xsd_type); #ifdef __cplusplus } /* extern "C" */ #endif -#endif /*XSD_TYPES_HH*/ \ No newline at end of file +#endif /*XSD_TYPES_HH*/ diff --git a/core/Float.cc b/core/Float.cc index c0e5211353554c2bd9f983316390426ca94e44be..c0f7a9ff3e489de0b838acf13b4aec51accddc71 100644 --- a/core/Float.cc +++ b/core/Float.cc @@ -130,11 +130,6 @@ boolean FLOAT::is_special(double flt_val) return ( (flt_val!=flt_val) || (flt_val==INFINITY) || (flt_val==-INFINITY) ); } -boolean FLOAT::is_nan(double flt_val) -{ - return flt_val!=flt_val; -} - void FLOAT::check_numeric(double flt_val, const char *err_msg_begin) { if (is_special(flt_val)) { @@ -146,10 +141,6 @@ void FLOAT::check_numeric(double flt_val, const char *err_msg_begin) double FLOAT::operator+(double other_value) const { must_bound("Unbound left operand of float addition."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value)) || is_nan(float_value) || is_nan(other_value)) { - TTCN_error("Invalid operands of float addition: Left operand is %g, right operand is %g", (double)float_value, other_value); - } return float_value + other_value; } @@ -157,20 +148,12 @@ double FLOAT::operator+(const FLOAT& other_value) const { must_bound("Unbound left operand of float addition."); other_value.must_bound("Unbound right operand of float addition."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value.float_value)) || is_nan(float_value) || is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float addition: Left operand is %g, right operand is %g", (double)float_value, (double)other_value.float_value); - } return float_value + other_value.float_value; } double FLOAT::operator-(double other_value) const { must_bound("Unbound left operand of float subtraction."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value)) || is_nan(float_value) || is_nan(other_value)) { - TTCN_error("Invalid operands of float subtraction: Left operand is %g, right operand is %g", (double)float_value, other_value); - } return float_value - other_value; } @@ -178,20 +161,12 @@ double FLOAT::operator-(const FLOAT& other_value) const { must_bound("Unbound left operand of float subtraction."); other_value.must_bound("Unbound right operand of float subtraction."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value.float_value)) || is_nan(float_value) || is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float subtraction: Left operand is %g, right operand is %g", (double)float_value, (double)other_value.float_value); - } return float_value - other_value.float_value; } double FLOAT::operator*(double other_value) const { must_bound("Unbound left operand of float multiplication."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value)) || is_nan(float_value) || is_nan(other_value)) { - TTCN_error("Invalid operands of float multiplication: Left operand is %g, right operand is %g", (double)float_value, other_value); - } return float_value * other_value; } @@ -199,20 +174,12 @@ double FLOAT::operator*(const FLOAT& other_value) const { must_bound("Unbound left operand of float multiplication."); other_value.must_bound("Unbound right operand of float multiplication."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value.float_value)) || is_nan(float_value) || is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float multiplication: Left operand is %g, right operand is %g", (double)float_value, (double)other_value.float_value); - } return float_value * other_value.float_value; } double FLOAT::operator/(double other_value) const { must_bound("Unbound left operand of float division."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value)) || is_nan(float_value) || is_nan(other_value)) { - TTCN_error("Invalid operands of float division: Left operand is %g, right operand is %g", (double)float_value, other_value); - } if (other_value == 0.0) TTCN_error("Float division by zero."); return float_value / other_value; } @@ -221,10 +188,6 @@ double FLOAT::operator/(const FLOAT& other_value) const { must_bound("Unbound left operand of float division."); other_value.must_bound("Unbound right operand of float division."); - // Both of them are +-infinity or one of them is nan - if ((is_special(float_value) && is_special(other_value.float_value)) || is_nan(float_value) || is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float division: Left operand is %g, right operand is %g", (double)float_value, (double)other_value.float_value); - } if (other_value.float_value == 0.0) TTCN_error("Float division by zero."); return float_value / other_value.float_value; } @@ -1195,40 +1158,24 @@ int FLOAT::JSON_decode(const TTCN_Typedescriptor_t& p_td, JSON_Tokenizer& p_tok, double operator+(double double_value, const FLOAT& other_value) { other_value.must_bound("Unbound right operand of float addition."); - // Both of them are +-infinity or one of them is nan - if ((FLOAT::is_special(double_value) && FLOAT::is_special(other_value.float_value)) || FLOAT::is_nan(double_value) || FLOAT::is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float addition: Left operand is %g, right operand is %g", double_value, (double)other_value.float_value); - } return double_value + other_value.float_value; } double operator-(double double_value, const FLOAT& other_value) { other_value.must_bound("Unbound right operand of float subtraction."); - // Both of them are +-infinity or one of them is nan - if ((FLOAT::is_special(double_value) && FLOAT::is_special(other_value.float_value)) || FLOAT::is_nan(double_value) || FLOAT::is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float subtraction: Left operand is %g, right operand is %g", double_value, (double)other_value.float_value); - } return double_value - other_value.float_value; } double operator*(double double_value, const FLOAT& other_value) { other_value.must_bound("Unbound right operand of float multiplication."); - // Both of them are +-infinity or one of them is nan - if ((FLOAT::is_special(double_value) && FLOAT::is_special(other_value.float_value)) || FLOAT::is_nan(double_value) || FLOAT::is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float multiplication: Left operand is %g, right operand is %g", double_value, (double)other_value.float_value); - } return double_value * other_value.float_value; } double operator/(double double_value, const FLOAT& other_value) { other_value.must_bound("Unbound right operand of float division."); - // Both of them are +-infinity or one of them is nan - if ((FLOAT::is_special(double_value) && FLOAT::is_special(other_value.float_value)) || FLOAT::is_nan(double_value) || FLOAT::is_nan(other_value.float_value)) { - TTCN_error("Invalid operands of float division: Left operand is %g, right operand is %g", double_value, (double)other_value.float_value); - } if (other_value.float_value == 0.0) TTCN_error("Float division by zero."); return double_value / other_value.float_value; } diff --git a/core/Float.hh b/core/Float.hh index c4d9e1a77a10593a783b5f397e782383f59dfb60..9755e7f5ad92930885497ca397ac16b38bcdfe59 100644 --- a/core/Float.hh +++ b/core/Float.hh @@ -106,7 +106,6 @@ public: /** special TTCN-3 float values are not_a_number and +/- infinity */ static boolean is_special(double flt_val); - static boolean is_nan(double flt_val); static void check_numeric(double flt_val, const char *err_msg_begin); void log() const; diff --git a/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script b/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script index ca5b19b780ab8c73b9a40252ccfa6ff01b771ade..14a469696452d3c84a7fcd4cb08547df278e9b53 100644 --- a/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script +++ b/function_test/Semantic_Analyser/TTCN3_SA_ttcn3adhoc_TD.script @@ -6536,9 +6536,6 @@ control { } <END_MODULE> <RESULT IF_PASS COUNT 1> -(?im)error: Second operand of operation `/' cannot be NaN, it must be a numeric value -<END_RESULT> -<RESULT IF_PASS COUNT 1> (?im)error: The operand of operation `rnd \(seed\)' cannot be INF, it must be a numeric value <END_RESULT> <RESULT IF_PASS COUNT 1> @@ -6550,7 +6547,7 @@ control { <RESULT IF_PASS COUNT 1> (?im)error: A non-negative float value was expected as timer duration instead of `NaN' <END_RESULT> -<RESULT IF_PASS COUNT 5> +<RESULT IF_PASS COUNT 4> (?is)\berror: <END_RESULT> <END_TC> diff --git a/function_test/Semantic_Analyser/float/special_OK.ttcn b/function_test/Semantic_Analyser/float/special_OK.ttcn new file mode 100644 index 0000000000000000000000000000000000000000..c1da6ad5a169f8d42f10db13ad9bf8ae8a534622 --- /dev/null +++ b/function_test/Semantic_Analyser/float/special_OK.ttcn @@ -0,0 +1,55 @@ +/****************************************************************************** + * Copyright (c) 2000-2016 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bence Janos Szabo + * + ******************************************************************************/ +module special_SE { + +const float err1 := infinity + infinity; +const float err2 := infinity + -infinity; +const float err3 := -infinity + -infinity; + + +const float err4 := infinity - infinity; +const float err5 := infinity - -infinity; +const float err6 := -infinity - -infinity; + +const float err7 := infinity * infinity; +const float err8 := infinity * -infinity; +const float err9 := -infinity * -infinity; + + +const float err10 := infinity / infinity; +const float err11 := infinity / -infinity; +const float err12 := -infinity / -infinity; + +const float err13 := not_a_number + 2.0; +const float err14 := not_a_number - 2.0; +const float err15 := not_a_number * 2.0; +const float err16 := not_a_number / 2.0; +const float err17 := not_a_number + infinity; +const float err18 := not_a_number + -infinity; + +function fun() { + var float f := 2.0; + var float f2 := f + not_a_number; + f2 := not_a_number + f; + + f2 := not_a_number - f; + f2 := f - not_a_number; + + f2 := not_a_number * f; + f2 := f * not_a_number; + + f2 := not_a_number / f; + f2 := f / not_a_number; +} + + +} diff --git a/function_test/Semantic_Analyser/float/special_SE.ttcn b/function_test/Semantic_Analyser/float/special_SE.ttcn deleted file mode 100644 index 1a04be104c9f52f9ee2ad50c9a1b97893d057dda..0000000000000000000000000000000000000000 --- a/function_test/Semantic_Analyser/float/special_SE.ttcn +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2000-2016 Ericsson Telecom AB - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Bence Janos Szabo - * - ******************************************************************************/ -module special_SE { //^In TTCN-3 module// - -const float err1 := infinity + infinity; //^In constant definition// //^In the operands of operation \`\+\'// //^error: Invalid operands of float \+\: First operand is INF\, Second operand is INF// -const float err2 := infinity + -infinity; //^In constant definition// //^In the operands of operation \`\+\'// //^error: Invalid operands of float \+\: First operand is INF\, Second operand is -INF// -const float err3 := -infinity + -infinity; //^In constant definition// //^In the operands of operation \`\+\'// //^error: Invalid operands of float \+\: First operand is -INF\, Second operand is -INF// - - -const float err4 := infinity - infinity; //^In constant definition// //^In the operands of operation \`\-\'// //^error: Invalid operands of float \-\: First operand is INF\, Second operand is INF// -const float err5 := infinity - -infinity; //^In constant definition// //^In the operands of operation \`\-\'// //^error: Invalid operands of float \-\: First operand is INF\, Second operand is -INF// -const float err6 := -infinity - -infinity; //^In constant definition// //^In the operands of operation \`\-\'// //^error: Invalid operands of float \-\: First operand is -INF\, Second operand is -INF// - -const float err7 := infinity * infinity; //^In constant definition// //^In the operands of operation \`\*\'// //^error: Invalid operands of float \*\: First operand is INF\, Second operand is INF// -const float err8 := infinity * -infinity; //^In constant definition// //^In the operands of operation \`\*\'// //^error: Invalid operands of float \*\: First operand is INF\, Second operand is -INF// -const float err9 := -infinity * -infinity; //^In constant definition// //^In the operands of operation \`\*\'// //^error: Invalid operands of float \*\: First operand is -INF\, Second operand is -INF// - - -const float err10 := infinity / infinity; //^In constant definition// //^In the operands of operation \`\/\'// //^error: Invalid operands of float \/\: First operand is INF\, Second operand is INF// -const float err11 := infinity / -infinity; //^In constant definition// //^In the operands of operation \`\/\'// //^error: Invalid operands of float \/\: First operand is INF\, Second operand is -INF// -const float err12 := -infinity / -infinity; //^In constant definition// //^In the operands of operation \`\/\'// //^error: Invalid operands of float \/\: First operand is -INF\, Second operand is -INF// - -const float err13 := not_a_number + 2.0; //^In constant definition// //^In the operands of operation \`\+\'// //^error: Invalid operands of float \+\: First operand is NaN\, Second operand is 2\.0e0// -const float err14 := not_a_number - 2.0; //^In constant definition// //^In the operands of operation \`\-\'// //^error: Invalid operands of float \-\: First operand is NaN\, Second operand is 2\.0e0// -const float err15 := not_a_number * 2.0; //^In constant definition// //^In the operands of operation \`\*\'// //^error: Invalid operands of float \*\: First operand is NaN\, Second operand is 2\.0e0// -const float err16 := not_a_number / 2.0; //^In constant definition// //^In the operands of operation \`\/\'// //^error: Invalid operands of float \/\: First operand is NaN\, Second operand is 2\.0e0// -const float err17 := not_a_number + infinity; //^In constant definition// //^In the operands of operation \`\+\'// //^error: Invalid operands of float \+\: First operand is NaN\, Second operand is INF// -const float err18 := not_a_number + -infinity; //^In constant definition// //^In the operands of operation \`\+\'// //^error: Invalid operands of float \+\: First operand is NaN\, Second operand is -INF// - -function fun() { //^In function definition// - var float f := 2.0; - var float f2 := f + not_a_number; //^In variable definition// //^In the operands of operation \`\+\'// //^error: Second operand of operation \`\+\' cannot be NaN\, it must be a numeric value// - f2 := not_a_number + f; //^In variable assignment// //^In the operands of operation \`\+\'// //^error: First operand of operation \`\+\' cannot be NaN\, it must be a numeric value// - - f2 := not_a_number - f; //^In variable assignment// //^In the operands of operation \`\-\'// //^error: First operand of operation \`\-\' cannot be NaN\, it must be a numeric value// - f2 := f - not_a_number; //^In variable assignment// //^In the operands of operation \`\-\'// //^error: Second operand of operation \`\-\' cannot be NaN\, it must be a numeric value// - - f2 := not_a_number * f; //^In variable assignment// //^In the operands of operation \`\*\'// //^error: First operand of operation \`\*\' cannot be NaN\, it must be a numeric value// - f2 := f * not_a_number; //^In variable assignment// //^In the operands of operation \`\*\'// //^error: Second operand of operation \`\*\' cannot be NaN\, it must be a numeric value// - - f2 := not_a_number / f; //^In variable assignment// //^In the operands of operation \`\/\'// //^error: First operand of operation \`\/\' cannot be NaN\, it must be a numeric value// - f2 := f / not_a_number; //^In variable assignment// //^In the operands of operation \`\/\'// //^error: Second operand of operation \`\/\' cannot be NaN\, it must be a numeric value// - -} - - -} diff --git a/regression_test/floatOper/TfloatOperSpecial.ttcn b/regression_test/floatOper/TfloatOperSpecial.ttcn index fc96ebef677ce9acbf7b97a089b979645f0a47f6..1e908f890d2c99634eaf709fc52ce6bd690c17c8 100644 --- a/regression_test/floatOper/TfloatOperSpecial.ttcn +++ b/regression_test/floatOper/TfloatOperSpecial.ttcn @@ -37,7 +37,11 @@ testcase tc_addition() runs on EmptyCT { setverdict(fail); } - // Checked at compile time + f := f2 + f; + if (f != -infinity) { + setverdict(fail); + } + f := infinity + 1.0; if (f != infinity) { setverdict(fail); @@ -48,109 +52,38 @@ testcase tc_addition() runs on EmptyCT { setverdict(fail); } - - var charstring dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is inf, right operand is inf"; - @try { - f := infinity; - f2 := infinity; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } - } - - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is inf, right operand is -inf"; - @try { - f := infinity; - f2 := -infinity; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } - } - - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is -inf, right operand is inf"; - @try { - f := -infinity; - f2 := infinity; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := not_a_number + f2; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is -inf, right operand is -inf"; - @try { - f := -infinity; - f2 := -infinity; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := f2 + not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is nan, right operand is inf"; - @try { - f := not_a_number; - f2 := infinity; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity + not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is inf, right operand is nan"; - @try { - f := infinity; - f2 := not_a_number; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity + not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is nan, right operand is nan"; - @try { - f := not_a_number; - f2 := not_a_number; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity + infinity; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float addition: Left operand is nan, right operand is 1"; - @try { - f := not_a_number; - f2 := 1.0; - f := f + f2; - setverdict(fail, "Expected dynamic test case error"); + f := infinity + infinity; + if (f != infinity) { + setverdict(fail); } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity + -infinity; + if (f != -infinity) { + setverdict(fail); } setverdict(pass); @@ -169,6 +102,10 @@ testcase tc_subtraction() runs on EmptyCT { setverdict(fail); } + f := f2 - f; + if (f != -infinity) { + setverdict(fail); + } f := -infinity; f := f - 1.0; @@ -180,7 +117,6 @@ testcase tc_subtraction() runs on EmptyCT { setverdict(fail); } - // Checked at compile time f := infinity - 1.0; if (f != infinity) { setverdict(fail); @@ -192,108 +128,39 @@ testcase tc_subtraction() runs on EmptyCT { } - var charstring dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is inf, right operand is inf"; - @try { - f := infinity; - f2 := infinity; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } - } - - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is inf, right operand is -inf"; - @try { - f := infinity; - f2 := -infinity; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := not_a_number - f2; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is -inf, right operand is inf"; - @try { - f := -infinity; - f2 := infinity; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := f2 - not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is -inf, right operand is -inf"; - @try { - f := -infinity; - f2 := -infinity; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity - not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is nan, right operand is inf"; - @try { - f := not_a_number; - f2 := infinity; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity - not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is inf, right operand is nan"; - @try { - f := infinity; - f2 := not_a_number; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity - infinity; + if (f != -infinity) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is nan, right operand is nan"; - @try { - f := not_a_number; - f2 := not_a_number; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity - infinity; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float subtraction: Left operand is nan, right operand is 1"; - @try { - f := not_a_number; - f2 := 1.0; - f := f - f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity - -infinity; + if (f != not_a_number) { + setverdict(fail); } setverdict(pass); @@ -317,6 +184,12 @@ testcase tc_multiplication() runs on EmptyCT { setverdict(fail); } + f := infinity; + f := f2 * f; + if (f != infinity) { + setverdict(fail); + } + f := -infinity; f := f * 2.0; if (f != -infinity) { @@ -331,7 +204,6 @@ testcase tc_multiplication() runs on EmptyCT { setverdict(fail); } - // Checked at compile time f := infinity * 1.0; if (f != infinity) { setverdict(fail); @@ -342,109 +214,39 @@ testcase tc_multiplication() runs on EmptyCT { setverdict(fail); } - - var charstring dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is inf, right operand is inf"; - @try { - f := infinity; - f2 := infinity; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } - } - - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is inf, right operand is -inf"; - @try { - f := infinity; - f2 := -infinity; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := not_a_number * f2; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is -inf, right operand is inf"; - @try { - f := -infinity; - f2 := infinity; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := f2 * not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is -inf, right operand is -inf"; - @try { - f := -infinity; - f2 := -infinity; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity * not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is nan, right operand is inf"; - @try { - f := not_a_number; - f2 := infinity; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity * not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is inf, right operand is nan"; - @try { - f := infinity; - f2 := not_a_number; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity * infinity; + if (f != -infinity) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is nan, right operand is nan"; - @try { - f := not_a_number; - f2 := not_a_number; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity * infinity; + if (f != infinity) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float multiplication: Left operand is nan, right operand is 2"; - @try { - f := not_a_number; - f2 := 2.0; - f := f * f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity * -infinity; + if (f != infinity) { + setverdict(fail); } setverdict(pass); @@ -468,6 +270,12 @@ testcase tc_division() runs on EmptyCT { setverdict(fail); } + f := infinity; + f := f2 / f; + if (f != 0.000000) { + setverdict(fail); + } + f := -infinity; f := f / 2.0; if (f != -infinity) { @@ -505,8 +313,6 @@ testcase tc_division() runs on EmptyCT { setverdict(fail); } - - // Checked at compile time f := infinity / 2.0; if (f != infinity) { setverdict(fail); @@ -518,108 +324,39 @@ testcase tc_division() runs on EmptyCT { } - var charstring dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is inf, right operand is inf"; - @try { - f := infinity; - f2 := infinity; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } - } - - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is inf, right operand is -inf"; - @try { - f := infinity; - f2 := -infinity; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := not_a_number / f2; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is -inf, right operand is inf"; - @try { - f := -infinity; - f2 := infinity; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := f2 / not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is -inf, right operand is -inf"; - @try { - f := -infinity; - f2 := -infinity; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity / not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is nan, right operand is inf"; - @try { - f := not_a_number; - f2 := infinity; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity / not_a_number; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is inf, right operand is nan"; - @try { - f := infinity; - f2 := not_a_number; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity / infinity; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is nan, right operand is nan"; - @try { - f := not_a_number; - f2 := not_a_number; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := infinity / infinity; + if (f != not_a_number) { + setverdict(fail); } - dte_message := "Dynamic test case error: Invalid operands of float division: Left operand is nan, right operand is 2"; - @try { - f := not_a_number; - f2 := 2.0; - f := f / f2; - setverdict(fail, "Expected dynamic test case error"); - } - @catch (msg) { - if (not match(msg, dte_message)) { - setverdict(fail, "Expected error: ", dte_message, ", got: ", msg); - } + f := -infinity / -infinity; + if (f != not_a_number) { + setverdict(fail); } setverdict(pass); @@ -643,6 +380,9 @@ const float c_f5 := inf * two; const float c_f6 := inf / two; const float c_f7 := neginf * negtwo; const float c_f8 := neginf / negtwo; +const float c_f21 := inf + inf; +const float c_f22 := inf * inf; +const float c_f23 := -inf * -inf; // All of theese are -infinity const float c_f9 := neginf + two; @@ -653,6 +393,10 @@ const float c_f13 := neginf * two; const float c_f14 := neginf / two; const float c_f15 := inf * negtwo; const float c_f16 := inf / negtwo; +const float c_f24 := -inf - inf; +const float c_f25 := -inf * inf; +const float c_f26 := inf * -inf; +const float c_f27 := -inf + -inf; // All of theese are 0.000000 @@ -662,9 +406,20 @@ const float c_f17 := two / inf; const float c_f18 := two / neginf; // All of theese are not_a_number - const float c_f19 := inf * 0.0; const float c_f20 := neginf * 0.0; +const float c_f28 := not_a_number + 1.0; +const float c_f29 := not_a_number - 1.0; +const float c_f30 := 1.0 + not_a_number; +const float c_f31 := 1.0 - not_a_number; +const float c_f32 := not_a_number * 1.0; +const float c_f33 := not_a_number / 1.0; +const float c_f34 := 1.0 * not_a_number; +const float c_f35 := 1.0 / not_a_number; +const float c_f36 := inf / inf; +const float c_f37 := -inf / inf; +const float c_f38 := -inf / -inf; +const float c_f39 := inf / -inf; testcase tc_compile_time() runs on EmptyCT { @@ -693,6 +448,15 @@ testcase tc_compile_time() runs on EmptyCT { if (c_f8 != infinity) { setverdict(fail); } + if (c_f21 != infinity) { + setverdict(fail); + } + if (c_f22 != infinity) { + setverdict(fail); + } + if (c_f23 != infinity) { + setverdict(fail); + } // Negative infinities @@ -720,6 +484,18 @@ testcase tc_compile_time() runs on EmptyCT { if (c_f16 != -infinity) { setverdict(fail); } + if (c_f24 != -infinity) { + setverdict(fail); + } + if (c_f25 != -infinity) { + setverdict(fail); + } + if (c_f26 != -infinity) { + setverdict(fail); + } + if (c_f27 != -infinity) { + setverdict(fail); + } // 0.000000 @@ -740,6 +516,42 @@ testcase tc_compile_time() runs on EmptyCT { if (c_f20 != not_a_number) { setverdict(fail); } + if (c_f28 != not_a_number) { + setverdict(fail); + } + if (c_f29 != not_a_number) { + setverdict(fail); + } + if (c_f30 != not_a_number) { + setverdict(fail); + } + if (c_f31 != not_a_number) { + setverdict(fail); + } + if (c_f32 != not_a_number) { + setverdict(fail); + } + if (c_f33 != not_a_number) { + setverdict(fail); + } + if (c_f34 != not_a_number) { + setverdict(fail); + } + if (c_f35 != not_a_number) { + setverdict(fail); + } + if (c_f36 != not_a_number) { + setverdict(fail); + } + if (c_f37 != not_a_number) { + setverdict(fail); + } + if (c_f38 != not_a_number) { + setverdict(fail); + } + if (c_f39 != not_a_number) { + setverdict(fail); + } setverdict(pass); }