/******************************************************************************
 * Copyright (c) 2000-2021 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Gecse, Roland
 *   Kovacs, Ferenc
 *   Raduly, Csaba
 *   Szabados, Kristof
 *   Szabo, Janos Zoltan – initial implementation
 *
 ******************************************************************************/
module TfloatOper
{
const float TfloatOper_const1:=2.0;
type component floatOper_comptype { };
modulepar float tsp_f_unchanged := 1.2+3.6/2.0;
modulepar float tsp_f_changed1 := 1.2+3.6/2.0;
modulepar float tsp_f_changed2;
modulepar float tsp_f_uninit_notchanged;

testcase floatAssign() runs on floatOper_comptype
{ var float x1:=12E3;
  var float x4:=x1;
  var float x2,x3;
  x2:=-124.2;
  x3:=x2;
  if (x1==12E3) {setverdict(pass);}	//at declaration, value
     else {setverdict(fail);}
  if (x4==12000.0) {setverdict(pass);}	//at declaration, variable
     else {setverdict(fail);}
  if (x2==-124.2) {setverdict(pass);}	//later, value
     else {setverdict(fail);}
  if (x3==-124.2) {setverdict(pass);}	//later, variable
     else {setverdict(fail);}
}

testcase floatConst() runs on floatOper_comptype {
const float TfloatOper_const3:=-5E2;
if (TfloatOper_const1==2.0) {setverdict(pass);}	//definition part
     else {setverdict(fail);}
//if (TfloatOper_const2==2) {setverdict(pass);}	//control part
//     else {setverdict(fail);}
if (TfloatOper_const3==-500.0) {setverdict(pass);}	//testcase
     else {setverdict(fail);}
}

testcase floatCompEq() runs on floatOper_comptype
{ var float x1,x2,x3;
  x1:=100.0;
  x2:=1E2;
  x3:=200.0;
  if (x1==x2) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x3==x2)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1==1E2) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x1==1010.0)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (1E2==x1) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(1001.0==x1)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (100.0==1E2) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(1100.0==100.0)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatCompNotEq() runs on floatOper_comptype
{ var float x1,x2,x3;
  x1:=1E2;
  x2:=200.0;
  x3:=100.0;
  if (x1!=x2) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x1!=x3)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1!=150.0) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x1!=1E2)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (120.0!=x2) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(2E2!=x2)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (111.0!=1E2) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(111.0!=111.0)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatCompLess() runs on floatOper_comptype
{ var float x1,x2,x3;
  x1:=1E2;
  x2:=100.0;
  x3:=200.0;
  if (x1<x3) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x1<x2)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x3<x1)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1<110.0) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x1<1E2)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x2<9E1)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (100.0<x3) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(1E2<x2)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(110.0<x1)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (1E2<120.0) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(100.0<1E2)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(110.0<1E1)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatCompLessEq() runs on floatOper_comptype
{ var float x1,x2,x3;
  x1:=100.0;
  x2:=1E2;
  x3:=200.0;
  if (x1<=x3) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1<=x2) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x3<=x1)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1<=11E1) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (x1<=1E2) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x2<=90.0)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (1E2<=x3) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (100.0<=x2) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(110.0<=x1)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (1E2<=120.0) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (100.0<=1E2) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(110.0<=10.0)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatCompGreat() runs on floatOper_comptype
{ var float x1,x2,x3;
  x1:=100.0;
  x2:=1E2;
  x3:=200.0;
  if (x3>x1) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x1>x2)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x1>x3)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1>99.0) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x1>1E2)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x2>11E1)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (210.0>x3) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(1E2>x2)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(90.0>x1)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (130.0>1.2E2) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(1E2>100.0)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(10.0>110.0)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatCompGreatEq() runs on floatOper_comptype
{ var float x1,x2,x3;
  x1:=1E2;
  x2:=100.0;
  x3:=200.0;
  if (x3>=x1) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1>=x2) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (not(x1>=x3)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x1>=99.0) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (x1>=1E2) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (not(x2>=11E2)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (210.0>=x3) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (1E2>=x2) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (not(9E1>=x1)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (130.0>=1.2E2) {setverdict(pass);} //value_value
   else {setverdict(fail);}
  if (100.0>=1E2) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  if (not(1E1>=110.0)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatAdd() runs on floatOper_comptype
{ var float x1,x2,x3,x4,x5,x6;
  x1:=125.5;
  x2:=1000.0;
  x3:=x1+x2;
  x4:=x2+456.2;
  x5:=1E2+x1;
  x6:=1E2+234.3;
  if (x3==1125.5) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (x4==1456.2) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (x5==225.5) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (x6==334.3) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatSubs() runs on floatOper_comptype
{ var float x1,x2,x3,x4,x5,x6;
  x1:=125.2;
  x2:=1125.2;
  x3:=x1-x2;
  x4:=x2-102.0;
  x5:=1E2-x1;
  x6:=100.0-2.34E2;
  if (((x3+1000.0)<1E-12)and((-1000.0-x3)>-1E-12)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (((x4-1023.2)<1E-12)and((1023.2-x4)>-1E-12)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (((x5+25.2)<1E-12)and((-25.2-x5)>-1E-12)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (((x6+134.0)<1E-12)and((-134.0-x6)>-1E-12)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatMultipl() runs on floatOper_comptype
{ var float x1,x2,x3,x4,x5,x6;
  x1:=12.0;
  x2:=10.1;
  x3:=x1*x2;
  x4:=x2*-2.0;
  x5:=1E1*x1;
  x6:=-2.5*3.0;
  if (((x3-121.2)<1E-12)and((121.2-x3)>-1E-12)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (((x4+20.2)<1E-12)and((-20.2-x4)>-1E-12)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (((x5-120.0)<1E-12)and((120.0-x5)>-1E-12)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (((x6+7.5)<1E-12)and((-7.5-x6)>-1E-12)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
}

testcase floatDiv() runs on floatOper_comptype
{ var float x1,x2,x3,x4,x5,x6;
  x1:=-125.0;
  x2:=500.0;
  x3:=x2/x1;
  x4:=x2/50.0;
  x5:=250.0/x1;
  x6:=1E2/-25.0;
  if (((x3+4.0)<1E-12)and((-4.0-x3)>-1E-12)) {setverdict(pass);}	//variable_variable
   else {setverdict(fail);}
  if (((x4-10.0)<1E-12)and((10.0-x4)>-1E-12)) {setverdict(pass);}	//variable_value
   else {setverdict(fail);}
  if (((x5+2.0)<1E-12)and((-2.0-x5)>-1E-12)) {setverdict(pass);}	//value_variable
   else {setverdict(fail);}
  if (((x6+4.0)<1E-12)and((-4.0-x6)>-1E-12)) {setverdict(pass);}	//value_value
   else {setverdict(fail);}
  //Divide by zero:
  x1 := 1.0;
  x2 := 0.0;
  @try {
    if (x1/x2 == infinity) {log(x1/x1) } else {log(x1/x2)}
    setverdict(fail, "This line should not be reached, DTE expected")
  } @catch(e){
    setverdict(pass, "DTE expected: ", e);
  }
}

type component floatOperSubtypes_comptype { }

type float myf1
type float myf2 (1.0, 2.0, 3.0)
type float myf3 (-infinity..0.0)
type float myf4 (-infinity..infinity)
type float myf5 (-infinity..infinity, 0.0, 1.0, 2.0, 3.0)
type myf5 myf6
type float myf7 (2147483648.0, 4294967296.0, 8589934592.0)
type float myf8 (2147483648.0..8589934592.0)
type float myf9 (myf2, myf3)
type myf9 myf10 (myf2)
type myf8 myf11 (2147483648.0..4294967296.0, 4294967296.0..4294967300.0)

const myf1 c_myf1 := 1.0
const myf2 c_myf2 := 1.0
const myf3 c_myf3 := 0.0
const myf4 c_myf4 := c_myf3
const myf5 c_myf5 := c_myf4
const myf6 c_myf6 := c_myf5
const myf7 c_myf7 := 4294967296.0
const myf8 c_myf8 := c_myf7
const myf9 c_myf9 := 0.0
const myf10 c_myf10 := 1.0
template myf1 t_myf1 := 1.0
template myf2 t_myf2 := 1.0
template myf3 t_myf3 := 0.0
template myf4 t_myf4 := t_myf3
template myf5 t_myf5 := t_myf4
template myf6 t_myf6 := t_myf5
template myf7 t_myf7 := 4294967296.0
template myf8 t_myf8 := t_myf7
template myf9 t_myf9 := 0.0
template myf10 t_myf10 := 1.0

testcase floatSubtypes() runs on floatOperSubtypes_comptype
{
  if (c_myf1 == c_myf2 and valueof(t_myf1) == valueof(t_myf2)) { setverdict(pass) }
  else { setverdict(fail) }
  var template myf1 vt_myf1 := 1.0
  var template myf2 vt_myf2 := 1.0
  var myf1 v_myf1 := 1.0
  var myf2 v_myf2 := 1.0
  if (v_myf1 == v_myf2 and valueof(vt_myf1) == valueof(vt_myf2)) { setverdict(pass) }
  else { setverdict(fail) }
  if (c_myf3 == c_myf4 and c_myf4 == c_myf5 and c_myf5 == c_myf6 and
      valueof(t_myf3) == valueof(t_myf4) and valueof(t_myf4) == valueof(t_myf5) and
      valueof(t_myf5) == valueof(t_myf6)) { setverdict(pass) }
  else { setverdict(fail) }
  var template myf3 vt_myf3 := 0.0
  var template myf4 vt_myf4 := vt_myf3
  var template myf5 vt_myf5 := vt_myf4
  var template myf6 vt_myf6 := vt_myf5
  var myf3 v_myf3 := 0.0
  var myf4 v_myf4 := v_myf3
  var myf5 v_myf5 := v_myf4
  var myf6 v_myf6 := v_myf5
  if (v_myf3 == v_myf4 and v_myf4 == v_myf5 and v_myf5 == v_myf6 and
      valueof(vt_myf3) == valueof(vt_myf4) and valueof(vt_myf4) == valueof(vt_myf5) and
      valueof(vt_myf5) == valueof(vt_myf6)) { setverdict(pass) }
  else { setverdict(fail) }
  if (c_myf7 == c_myf8 and valueof(t_myf7) == valueof(t_myf8)) { setverdict(pass) }
  else { setverdict(fail) }
  var template myf7 vt_myf7 := 4294967296.0
  var template myf8 vt_myf8 := vt_myf7
  var myf7 v_myf7 := 4294967296.0
  var myf8 v_myf8 := v_myf7
  if (v_myf7 == v_myf8 and valueof(vt_myf7) == valueof(vt_myf8)) { setverdict(pass) }
  else { setverdict(fail) }
}

testcase floatIsvalue() runs on floatOper_comptype {
  var float f0, f1 := 1.0;
  var template float tf0;
  var template float tf1 := (5.5);
  var template float tf2 := (1.0 .. 2.0);

  if ( isvalue(f0) ) { setverdict(fail); } else { setverdict(pass); };
  if ( isvalue(f1) ) { setverdict(pass); } else { setverdict(fail); };
  if ( isvalue(tf0) ) { setverdict(fail); } else { setverdict(pass); };
  if ( isvalue(tf1) ) { setverdict(pass); } else { setverdict(fail); };
  if ( isvalue(tf2) ) { setverdict(fail); } else { setverdict(pass); };
  if ( isvalue(f1 + 1.0) ) { setverdict(pass); } else { setverdict(fail); };
}

testcase floatIsbound() runs on floatOper_comptype {
  var float f0, f1 := 1.0;
  var template float tf0;
  var template float tf1 := (5.5);
  var template float tf2 := (1.0 .. 2.0);

  if ( isbound(f0) ) { setverdict(fail); } else { setverdict(pass); };
  if ( isbound(f1) ) { setverdict(pass); } else { setverdict(fail); };
  if ( isbound(tf0) ) { setverdict(fail); } else { setverdict(pass); };
  if ( isbound(tf1) ) { setverdict(pass); } else { setverdict(fail); };
  if ( isbound(tf2) ) { setverdict(pass); } else { setverdict(fail); };
  if ( isbound(f1 + 1.0) ) { setverdict(pass); } else { setverdict(fail); };
}

testcase floatComparison() runs on floatOper_comptype {
  // 
  var float minus_zero := -0.0;
  var float plus_zero  :=  0.0;

  //----------------

  if (minus_zero == -0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT == -0.0") } 
  if (minus_zero <=  0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= 0.0") }
  if (minus_zero <   0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < 0.0") }
  if (minus_zero <=  plus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= 0.0") }
  if (minus_zero <   plus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < 0.0") }
  if (plus_zero >=  minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": 0.0 NOT >= -0.0") }
  if (plus_zero >   minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": 0.0 NOT > -0.0") }
  
  if (-infinity <  minus_zero ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity NOT < -0.0") }
  if (-infinity <= minus_zero ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity NOT <= -0.0") }
  if (minus_zero <  infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < infinity") }
  if (minus_zero <= infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= infinity") }
  if (minus_zero <  not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < not_a_number") }
  if (minus_zero <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= not_a_number") }
  if (not_a_number >  minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": not_a_number NOT > -0.0") }
  if (not_a_number >= minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": not_a_number NOT >= -0.0") }

  //----------------

  var float plus_inf := infinity;
  if (plus_inf == infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity==infinity:NotOK") }
  if (-infinity <  plus_inf ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<infinity:NotOK") }
  if (-infinity <= plus_inf ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=infinity:NotOK") }
  if (plus_inf <  not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<not_a_number:NotOK") }
  if (plus_inf <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<=not_a_number:NotOK") }

  //----------------

  var float minus_inf := -infinity;
  if (minus_inf == -infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity==-infinity:NotOK") }
  if (minus_inf < not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") }
  if (minus_inf <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=not_a_number:NotOK") }

  //----------------

  var float NaN := not_a_number;
  if (NaN != not_a_number) { setverdict(fail, __LINE__, ": not_a_number==not_a_number:NotOK") }
  if (NaN < NaN) { setverdict(fail, __LINE__, ": not_a_number<not_a_number:NotOK") }
  if (NaN > NaN) { setverdict(fail, __LINE__, ": not_a_number<not_a_number:NotOK") }
}

testcase tc_floatComparison_const() runs on floatOper_comptype {
  // 
  const float minus_zero := -0.0;
  const float plus_zero  :=  0.0;

  //----------------

  if (minus_zero == -0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT == -0.0") } 
  if (minus_zero <=  0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= 0.0") }
  if (minus_zero <   0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < 0.0") }
  if (minus_zero <=  plus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= 0.0") }
  if (minus_zero <   plus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < 0.0") }
  if (plus_zero >=  minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": 0.0 NOT >= -0.0") }
  if (plus_zero >   minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": 0.0 NOT > -0.0") }
  
  if (-infinity <  minus_zero ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity NOT < -0.0") }
  if (-infinity <= minus_zero ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity NOT <= -0.0") }
  if (minus_zero <  infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < infinity") }
  if (minus_zero <= infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= infinity") }
  if (minus_zero <  not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < not_a_number") }
  if (minus_zero <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= not_a_number") }
  if (not_a_number >  minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": not_a_number NOT > -0.0") }
  if (not_a_number >= minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": not_a_number NOT >= -0.0") }

  //----------------

  const float plus_inf := infinity;
  if (plus_inf == infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity==infinity:NotOK") }
  if (-infinity <  plus_inf ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<infinity:NotOK") }
  if (-infinity <= plus_inf ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=infinity:NotOK") }
  if (plus_inf <  not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<not_a_number:NotOK") }
  if (plus_inf <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<=not_a_number:NotOK") }

  //----------------

  const float minus_inf := -infinity;
  if (minus_inf == -infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity==-infinity:NotOK") }
  if (minus_inf < not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") }
  if (minus_inf <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=not_a_number:NotOK") }

  //----------------

  const float NaN := not_a_number;
  if (NaN != not_a_number) { setverdict(fail, __LINE__, ": not_a_number==not_a_number:NotOK") }
  if (NaN < NaN) { setverdict(fail, __LINE__, ": not_a_number<not_a_number:NotOK") }
  if (NaN > NaN) { setverdict(fail, __LINE__, ": not_a_number<not_a_number:NotOK") }
}


//runtime evaluation
testcase tc_floatComparison_var() runs on floatOper_comptype {
  // 
  var float minus_zero := -0.0;
  var float plus_zero  :=  0.0;

  //----------------

  if (minus_zero == -0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT == -0.0") } 
  if (minus_zero <=  0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= 0.0") }
  if (minus_zero <   0.0) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < 0.0") }
  if (minus_zero <=  plus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= 0.0") }
  if (minus_zero <   plus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < 0.0") }
  if (plus_zero >=  minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": 0.0 NOT >= -0.0") }
  if (plus_zero >   minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": 0.0 NOT > -0.0") }
  
  if (-infinity <  minus_zero ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity NOT < -0.0") }
  if (-infinity <= minus_zero ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity NOT <= -0.0") }
  if (minus_zero <  infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < infinity") }
  if (minus_zero <= infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= infinity") }
  if (minus_zero <  not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT < not_a_number") }
  if (minus_zero <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -0.0 NOT <= not_a_number") }
  if (not_a_number >  minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": not_a_number NOT > -0.0") }
  if (not_a_number >= minus_zero) { setverdict(pass); } else { setverdict(fail, __LINE__, ": notc_floatComparison_const.0") }

  //----------------

  var float plus_inf := infinity;
  if (plus_inf == infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity==infinity:NotOK") }
  if (-infinity <  plus_inf ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<infinity:NotOK") }
  if (-infinity <= plus_inf ) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=infinity:NotOK") }
  if (plus_inf <  not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<not_a_number:NotOK") }
  if (plus_inf <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<=not_a_number:NotOK") }

  //----------------

  var float minus_inf := -infinity;
  if (minus_inf == -infinity) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity==-infinity:NotOK") }
  if (minus_inf < not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") }
  if (minus_inf <= not_a_number) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=not_a_number:NotOK") }

  //----------------

  var float NaN := not_a_number;
  if (NaN == NaN) { setverdict(pass); } else { setverdict(fail, __LINE__, ": not_a_number != not_a_number:NotOK") }
  if (NaN != NaN) { setverdict(fail, __LINE__, ": not_a_number==not_a_number:NotOK") }
  if (NaN != not_a_number) { setverdict(fail, __LINE__, ": not_a_number==not_a_number:NotOK") }
  if (NaN < NaN) { setverdict(fail, __LINE__, ": not_a_number<not_a_number:NotOK") }
  if (NaN > NaN) { setverdict(fail, __LINE__, ": not_a_number<not_a_number:NotOK") }
  if (minus_inf < NaN) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") }
  if (minus_inf <= NaN) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<=not_a_number:NotOK") }
  if (NaN > minus_inf) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") }
  if (NaN >= minus_inf) { setverdict(pass); } else { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") }
  if (NaN < minus_inf) { setverdict(fail, __LINE__, ": -infinity>not_a_number:NotOK") } else { setverdict(pass); }
  if (NaN <= minus_inf) { setverdict(fail, __LINE__, ": -infinity<not_a_number:NotOK") } else { setverdict(pass); }
  if (plus_inf <  NaN) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<not_a_number failed") }
  if (plus_inf <= NaN) { setverdict(pass); } else { setverdict(fail, __LINE__, ": infinity<=not_a_number failed") }
  if (plus_inf > NaN) { setverdict(fail, __LINE__, ": infinity>not_a_number failed") } else { setverdict(pass); }
  if (plus_inf >= NaN) { setverdict(fail, __LINE__, ": infinity>=not_a_number failed") } else { setverdict(pass); }

}

testcase tc_float_modulepars() runs on floatOper_comptype {
  if (tsp_f_unchanged == 3.0 ) {
    setverdict(pass)
  } else {
    setverdict(fail, "Expected: 3.0, got ",tsp_f_unchanged);
  }
  if (tsp_f_changed1 == 3.0 ) {
    setverdict(pass, tsp_f_changed1)
  } else {
    setverdict(fail, "Expected: 3.0, got ",tsp_f_changed1);
  }
  if (tsp_f_changed2 == -1.3 ) {
    setverdict(pass, tsp_f_changed2)
  } else {
    setverdict(fail, "Expected: -1.3, got ",tsp_f_changed2);
  }
}

testcase tc_float_log2str() runs on floatOper_comptype {
  var float f1, f2, f3;
  f1 := 1.0;
  if( log2str(f1) == "1.000000") {setverdict(pass)} else { setverdict(fail,f1)}
  f1 := -1.0;
  if( log2str(f1) == "-1.000000") {setverdict(pass)} else { setverdict(fail,f1)}
  f1 := -1.0e+3;
  if( log2str(f1) == "-1000.000000") {setverdict(pass)} else { setverdict(fail,f1)}
  f1 := -1.0e+30;
  if( log2str(f1) == "-1.000000e+30") {setverdict(pass)} else { setverdict(fail,f1)}
  f1 := infinity;
  if( log2str(f1) == "infinity") {setverdict(pass)} else { setverdict(fail,f1)}
  f1 := -infinity;
  if( log2str(f1) == "-infinity") {setverdict(pass)} else { setverdict(fail,f1)}
  f1 := infinity/infinity;
  if( log2str(f1) == "not_a_number") {setverdict(pass)} else { setverdict(fail,log2str(f1)) }
  if( log2str(f2) == "<unbound>") {setverdict(pass)} else { setverdict(fail,f2)}
  
}

control {
  const float cl_1:=2.0;
  var float vl_1;

  execute(floatAssign());
  execute(floatConst());
  execute(floatCompEq());
  execute(floatCompNotEq());
  execute(floatCompLess());
  execute(floatCompLessEq());
  execute(floatCompGreat());
  execute(floatCompGreatEq());
  execute(floatAdd());
  execute(floatSubs());
  execute(floatMultipl());
  execute(floatDiv());
  execute(floatSubtypes());
  execute(floatIsvalue());
  execute(floatIsbound());
  execute(floatComparison());
  execute(tc_floatComparison_const());
  execute(tc_floatComparison_var());
  execute(tc_float_modulepars());
  execute(tc_float_log2str());
}

}
