File: test_obj_local.ml

package info (click to toggle)
janest-base 0.17.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,632 kB
  • sloc: ml: 48,653; ansic: 281; javascript: 126; makefile: 14
file content (36 lines) | stat: -rw-r--r-- 668 bytes parent folder | download | duplicates (2)
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
open! Import
open! Exported_for_specific_uses.Obj_local

(* immediate *)
let%test_unit _ =
  [%test_result: stack_or_heap]
    (let x = 42 in
     stack_or_heap (repr x))
    ~expect:Immediate
;;

(* global*)
let%test_unit _ =
  [%test_result: stack_or_heap]
    (let s = "hello" in
     let _r = ref s in
     stack_or_heap (repr s))
    ~expect:Heap
;;

let stack_enabled =
  match Sys.backend_type with
  | Sys.Native -> true
  | _ -> false
;;

(* local *)
let%test_unit _ =
  [%test_result: stack_or_heap]
    (let foo x =
       let s = ref x in
       stack_or_heap (repr s) [@nontail]
     in
     foo 42)
    ~expect:(if stack_enabled then Stack else Heap)
;;