Project

General

Profile

Revision cbfee4a3 src/tools/stateflow/json-parser/test_json_parser_variables.ml

View differences:

src/tools/stateflow/json-parser/test_json_parser_variables.ml
16 16

  
17 17
let location = Location.dummy_loc
18 18

  
19
let string_of_var_type var_type =
20
  match var_type with
21
  | Tydec_bool -> "bool"
22
  | Tydec_int  -> "int"
23
  | Tydec_real -> "real"
24
  | _          -> "other"
25

  
26
let string_of_var_value value =
27
  match value with
28
  | Expr_const (Const_tag label)      -> label
29
  | Expr_const (Const_int v)          -> string_of_int v
30
  | Expr_const (Const_real (n, l, s)) -> (Num.string_of_num n) ^
31
                                         " x 10^-" ^
32
                                         (string_of_int l) ^
33
                                         " (" ^ s ^ ")"
34
  | _                   -> "other value (not possible)"
35

  
19 36
let test_var_skeleton var id var_type value =
20 37
  begin
21 38
    assert_bool
......
30 47
      var.var_dec_clock.ck_dec_desc;
31 48
    assert_equal
32 49
      ~msg:("problem with variable " ^ var.var_id ^ " ident")
50
      ~printer:(fun x -> x)
33 51
      id
34 52
      var.var_id;
35 53
    assert_equal
36 54
      ~msg:("problem with variable " ^ var.var_id ^ " type")
55
      ~printer:string_of_var_type
37 56
      var_type
38 57
      var.var_dec_type.ty_dec_desc;
39 58
    match var.var_dec_value with
40 59
    | Some { expr_desc = d } ->
41 60
      assert_equal
42 61
        ~msg:("problem with variable " ^ var.var_id ^ " value")
62
        ~printer:string_of_var_value
43 63
        value
44 64
        d
45 65
    | _       -> raise (OUnitTest.OUnit_failure

Also available in: Unified diff