File: expr_info_polymorphic_use_test.ml

package info (click to toggle)
ocaml-visitors 20180513-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,640 kB
  • sloc: ml: 4,063; makefile: 120; sh: 13
file content (27 lines) | stat: -rw-r--r-- 490 bytes parent folder | download | duplicates (5)
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
open Expr_info_polymorphic
open Expr_info_polymorphic_use

let strip : 'a . 'a expr -> unit expr = strip
let number : 'a . 'a expr -> int expr = number

let mk node = { info = (); node }

let const i =
  mk (EConst i)

let add e1 e2 =
  mk (EAdd (e1, e2))

let e =
  add (const 1) (add (const 0) (const 3))

let e = number (strip e)

let () =
  assert (e.info = 0);
  match e.node with
  | EAdd (e1, e2) ->
      assert (e1.info = 1);
      assert (e2.info = 2)
  | _ ->
      assert false