Project

General

Profile

Revision 5c0d6e4e src/tools/stateflow/json-parser/test_json_parser_variables.ml

View differences:

src/tools/stateflow/json-parser/test_json_parser_variables.ml
66 66
  | _ -> raise (OUnitTest.OUnit_failure
67 67
                  "Program obtained from simple-var-bool-true.json is not correct")
68 68

  
69
let test_simple_var_int_zero tests_ctxt =
70
  let prog = Parse.parse_prog
71
      (Yojson.Basic.from_file "../data-test/simple-var-int-zero.json") in
72
  match prog with
73
  | Program ("simple_var_int_zero", [ ], [ x ]) ->
74
    test_var_skeleton x "my_int_var_zero"
75
      Tydec_int (Expr_const (Const_int 0))
76
  | _ -> raise (OUnitTest.OUnit_failure
77
                  "Program obtained from simple-var-int-zero.json is not correct")
78

  
79
let test_simple_var_int_pos tests_ctxt =
80
  let prog = Parse.parse_prog
81
      (Yojson.Basic.from_file "../data-test/simple-var-int-pos.json") in
82
  match prog with
83
  | Program ("simple_var_int_pos", [ ], [ x ]) ->
84
    test_var_skeleton x "my_int_var_pos"
85
      Tydec_int (Expr_const (Const_int 2))
86
  | _ -> raise (OUnitTest.OUnit_failure
87
                  "Program obtained from simple-var-int-pos.json is not correct")
88

  
89
let test_simple_var_int_neg tests_ctxt =
90
  let prog = Parse.parse_prog
91
      (Yojson.Basic.from_file "../data-test/simple-var-int-neg.json") in
92
  match prog with
93
  | Program ("simple_var_int_neg", [ ], [ x ]) ->
94
    test_var_skeleton x "my_int_var_neg"
95
      Tydec_int (Expr_const (Const_int (-5)))
96
  | _ -> raise (OUnitTest.OUnit_failure
97
                  "Program obtained from simple-var-int-neg.json is not correct")
98

  
99
let test_simple_var_real_zero tests_ctxt =
100
  let prog = Parse.parse_prog
101
      (Yojson.Basic.from_file "../data-test/simple-var-real-zero.json") in
102
  match prog with
103
  | Program ("simple_var_real_zero", [ ], [ x ]) ->
104
    test_var_skeleton x "my_real_var_zero"
105
      Tydec_real (Expr_const (Const_real (Num.num_of_int 0, 1, "0.0")))
106
  | _ -> raise (OUnitTest.OUnit_failure
107
                  "Program obtained from simple-var-real-zero.json is not correct")
108

  
109
let test_simple_var_real_pos tests_ctxt =
110
  let prog = Parse.parse_prog
111
      (Yojson.Basic.from_file "../data-test/simple-var-real-pos.json") in
112
  match prog with
113
  | Program ("simple_var_real_pos", [ ], [ x ]) ->
114
    test_var_skeleton x "my_real_var_pos"
115
      Tydec_real (Expr_const (Const_real (Num.num_of_int 2115, 2, "21.15")))
116
  | _ -> raise (OUnitTest.OUnit_failure
117
                  "Program obtained from simple-var-real-pos.json is not correct")
118

  
119
let test_simple_var_real_neg tests_ctxt =
120
  let prog = Parse.parse_prog
121
      (Yojson.Basic.from_file "../data-test/simple-var-real-neg.json") in
122
  match prog with
123
  | Program ("simple_var_real_neg", [ ], [ x ]) ->
124
    test_var_skeleton x "my_real_var_neg"
125
      Tydec_real (Expr_const (Const_real (Num.num_of_int (-224), 2, "-2.24")))
126
  | _ -> raise (OUnitTest.OUnit_failure
127
                  "Program obtained from simple-var-real-neg.json is not correct")
128

  
129
let test_simple_var_real_wo_dec tests_ctxt =
130
  let prog = Parse.parse_prog
131
      (Yojson.Basic.from_file "../data-test/simple-var-real-wo-dec.json") in
132
  match prog with
133
  | Program ("simple_var_real_wo_dec", [ ], [ x ]) ->
134
    test_var_skeleton x "my_real_var_wo_dec"
135
      Tydec_real (Expr_const (Const_real (Num.num_of_int 2500, 0, "2500")))
136
  | _ -> raise (OUnitTest.OUnit_failure
137
                  "Program obtained from simple-var-real-wo-dec.json is not correct")
138

  
69 139
let var_suite =
70 140
  "suite for variables" >:::
71 141
  [ "simple test for variable (boolean, false)" >::
72 142
    test_simple_var_bool_false;
73 143
    "simple test for variable (boolean, true)"  >::
74
    test_simple_var_bool_true
144
    test_simple_var_bool_true;
145
    "simple test for variable (int, 0)"  >::
146
    test_simple_var_int_zero;
147
    "simple test for variable (int, 2)"  >::
148
    test_simple_var_int_pos;
149
    "simple test for variable (int, -5)"  >::
150
    test_simple_var_int_neg;
151
    "simple test for variable (real, 0.0)"  >::
152
    test_simple_var_real_zero;
153
    "simple test for variable (real, 21.15)"  >::
154
    test_simple_var_real_pos;
155
    "simple test for variable (real, -2.24)"  >::
156
    test_simple_var_real_neg;
157
    "simple test for variable (real, 2500)"  >::
158
    test_simple_var_real_wo_dec;
75 159
  ]
76 160

  
77 161
let _ =

Also available in: Unified diff