tests.ml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. open Printf
  2. ;;
  3. let print title vl =
  4. let i = Objsize.objsize vl in
  5. printf "%S : data_words=%i headers=%i depth=%i\n \
  6. bytes_without_headers=%i bytes_with_headers=%i\n%!"
  7. title i.Objsize.data i.Objsize.headers i.Objsize.depth
  8. (Objsize.size_without_headers i)
  9. (Objsize.size_with_headers i)
  10. in
  11. print "string of 13 chars" ("0123456" ^ "789012")
  12. ;
  13. print "some object"
  14. ( object method x = 123; method y = print_int; end
  15. )
  16. ;
  17. print "some float" (Random.float 1.)
  18. ;
  19. (*
  20. let rec cyc = [1 :: [2 :: [3 :: cyc]]] in
  21. print "cyclic list" cyc
  22. ;
  23. *)
  24. let genlist n =
  25. let rec inner acc n =
  26. if n <= 0
  27. then acc
  28. else inner (n :: acc) (n-1)
  29. in
  30. inner [] n
  31. in
  32. print "big list" (genlist 300000)
  33. ;
  34. print "big array" (Array.make 30000 true)
  35. ;
  36. print "statically created value" [1; 2; 3]
  37. ;
  38. print "objsize 0.14 bug"
  39. (let rec val_a = (val_z, val_z)
  40. and val_z = (123, val_y)
  41. and val_y = (234, 345)
  42. in
  43. val_a
  44. )
  45. ;
  46. print "objsize 0.15 bug"
  47. (let val_z = ((), ()) in
  48. let val_y = (val_z, val_z, fun x -> x) in
  49. val_y
  50. )
  51. ;