/******************************************************************************
 * Copyright (c) 2000-2025 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
 *   Raduly, Csaba
 *   Szabo, Bence Janos
 *
 ******************************************************************************/
module subtype_SE { //^In TTCN-3 module//

type component floater {}

type float myf123 (1.0, 2.0, 3.0)
type float minf_to_zero (-infinity..0.0)
type float minf_to_mzero (-infinity..-0.0)
type float reals (-infinity..infinity)
type float reals_and_some (-infinity..infinity, 0.0, 1.0, 2.0, 3.0)
//type myf5 myf6

type float pow2     (2147483648.0, 4294967296.0, 8589934592.0)
type float two31_32 (2147483648.0..8589934592.0)
type float myf9     (myf123, minf_to_zero)

type myf9 myf10 (myf123)
type two31_32 myf11 (2147483648.0..4294967296.0, 4294967296.0..4294967300.0)

type myf123 su2 (3.14);        //^In type definition//    //^error\: The subtype restriction is not a subset of the restriction on the parent type\. Subtype \(3\.14e0\) is not subset of subtype \(1\.0e0,2\.0e0,3\.0e0\)$//
type minf_to_zero su3 (!6.0 .. 10.0); //^In type definition//    //^error\: The subtype restriction is not a subset of the restriction on the parent type\. Subtype \(\!6\.0e0\.\.1\.0e1\) is not subset of subtype \(\-INF\.\.0\.0e0\)$//

type float buzz_lightyear (infinity .. not_a_number) //^In type definition//    //^error: upper boundary cannot be not_a_number in float subtype range$//
// to infinity and beyond

type su3 su3bis (6.0 .. 10.0);

type float one_to_ten (1.0 .. 10.0)
type float ten_to_eleven (10.0 .. 11.0)

// The real axis:                               -infinity  -0.0 0.0   +infinity
type float strict_neg_x  (-infinity .. !-0.0) //[.............)
type float strict_neg    (-infinity ..  -0.0) //[.............]
type float        neg0_x (-infinity .. ! 0.0) //[.................)
type float        neg0   (-infinity ..   0.0) //[.................]

type float pos           ( -0.0 .. infinity)  //            [................]
type float pos_x         (!-0.0 .. infinity)  //            (................]
type float strict_pos    (  0.0 .. infinity)  //                 [...........]
type float strict_pos_x  (! 0.0 .. infinity)  //                 (...........]

type float  zero ( -0.0 ..  0.0) // two values
type float xzero (!-0.0 ..  0.0) // one value:  0.0
type float  zerox( -0.0 .. !0.0) // one value: -0.0
type float xzerox(!-0.0 .. !0.0) // no values!

testcase negative() runs on floater //^In testcase definition//
{
  var strict_neg_x snx_minus_0 := -0.0; //^In variable definition//	//^error: -0\.0e0 is not a valid value for type \`float\' which has subtype \(-INF\.\.!-0\.0e0\)$//
  var strict_neg_x snx_plus_0  :=  0.0; //^In variable definition//	 //^error: 0\.0e0 is not a valid value for type \`float\' which has subtype \(-INF\.\.!-0\.0e0\)$//

  var strict_neg   sn_minus_0 := -0.0; // OK
  var strict_neg   sn_plus_0  :=  0.0; //^In variable definition//	//^error: 0\.0e0 is not a valid value for type \`float\' which has subtype \(-INF\.\.-0\.0e0\)$//
  
  var neg0_x n0x_minus_0 := -0.0; // OK
  var neg0_x n0x_plus_0  :=  0.0; //^In variable definition//	//^error: 0\.0e0 is not a valid value for type \`float\' which has subtype \(-INF\.\.!0\.0e0\)$//
  
  var neg0 nz_minus_zero := -0.0; // OK
  var neg0 nz_plus_zero  :=  0.0; // OK
}

testcase positive() runs on floater //^In testcase definition//
{
  var pos p_minus_0 := -0.0 // OK
  var pos p_plus_0  :=  0.0 // OK

  var pos_x px_minus_0 := -0.0 //^In variable definition//	//^error: -0\.0e0 is not a valid value for type \`float\' which has subtype \(!-0\.0e0\.\.INF\)$//
  var pos_x px_plus_0  :=  0.0 // OK
  
  var strict_pos sp_minus_0 := -0.0 //^In variable definition//	//^error: -0\.0e0 is not a valid value for type \`float\' which has subtype \(0\.0e0\.\.INF\)$//
  var strict_pos sp_0 := 0.0 // OK
  
  var strict_pos_x spx_minus_0 := -0.0 //^In variable definition//	//^error: -0\.0e0 is not a valid value for type \`float\' which has subtype \(!0\.0e0\.\.INF\)$//
  var strict_pos_x spx_plus_0  :=  0.0 //^In variable definition//	 //^error: 0\.0e0 is not a valid value for type \`float\' which has subtype \(!0\.0e0\.\.INF\)$//
}

testcase nulla() runs on floater
{
  var zero minus_zero := -0.0; // OK
  var zero plus_zero  :=  0.0; // OK
}

control { //^In control part:$   nothing right now
  var one_to_ten six := 6.6;
  var ten_to_eleven ten := six;
  
  execute(negative());
  execute(positive());
  execute(nulla());
}


}
