Skip to content

Inline tests are included in binaries built with js_of_ocaml #74

@copy

Description

@copy

For example:

(executable
  ((name test)
   (js_of_ocaml ((flags (:standard --opt 3 --pretty +weak.js))))
   (libraries (js_of_ocaml core_kernel))))

With test.ml containing:

let _ = Core_kernel.Time.now ()

And building with jbuilder build test.bc.js.

The generated test.bc.js contains quite a few calls similar to the ones below:

                    test_unit
                     (_u4_,
                      _aCq_,
                      0,
                      _aCp_,
                      793,
                      4,
                      63,
                      function(param){return test(1,3609444,_aCo_)});
                    test_unit
                     (_u4_,
                      _auK_,
                      0,
                      _auJ_,
                      333,
                      4,
                      214,
                      function(param)
                       {return round_trip$0
                                (to_parts$1(create$31(0,0,[0,hr],0,0,0,0,0,0)))});
     _avr_=caml_new_string(": <<test true 71 1666750235549516973L>>"),
     _avt_=caml_new_string("src/time_ns.ml"),
     _avu_=caml_new_string(": <<test true 4398 1232807081547132235L>>"),
     _avw_=caml_new_string("src/time_ns.ml"),
     _avx_=caml_new_string(": <<test false 702561 1233263206897519979L>>"),
     _avz_=caml_new_string("src/time_ns.ml"),

Note that this is at the maximum optimisation level that jsoo supports (as far as I know). jsoo is able to remove the entire module if it isn't referenced (for example when test.ml is empty), but it doesn't seem to be able to remove the values exported for the inline tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    forwarded-to-js-devsThis report has been forwarded to Jane Street's internal review system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions