subtype_SE.ttcn 4.12 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/******************************************************************************
 * Copyright (c) 2000-2014 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
 ******************************************************************************/
module subtype_SE { //^In TTCN-3 module//
import from subtype_OK all;

type component floater {}

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());
}


}