File tree Expand file tree Collapse file tree 4 files changed +63
-15
lines changed
Expand file tree Collapse file tree 4 files changed +63
-15
lines changed Original file line number Diff line number Diff line change 1+ let % expect_test _ =
2+ let prog =
3+ {|
4+ let rec f x y =
5+ match x,y with
6+ | 0 , 0 -> true
7+ | _ -> f (y - 1 ) (x - 1 )
8+
9+ | }
10+ in
11+ let program = Util. compile_and_parse ~pretty: false prog in
12+ Util. print_program program;
13+ [% expect
14+ {|
15+ (function(a){
16+ " use strict" ;
17+ var b = a.jsoo_runtime;
18+ b.caml_register_global
19+ (0 ,
20+ [0 ,
21+ function(a, b){
22+ var d = a, c = b;
23+ for (;;){
24+ if (0 === d && 0 === c) return 1 ;
25+ var e = d - 1 | 0 , d = c - 1 | 0 , c = e;
26+ }
27+ }],
28+ " Test" );
29+ return;
30+ }
31+ (globalThis));
32+ // end | }]
Original file line number Diff line number Diff line change 4444 (preprocess
4545 (pps ppx_expect)))
4646
47+ (library
48+ ;; compiler/ tests- compiler/ compact.ml
49+ (name compact_15)
50+ (enabled_if true )
51+ (modules compact)
52+ (libraries js_of_ocaml_compiler unix str jsoo_compiler_expect_tests_helper)
53+ (inline_tests
54+ (enabled_if true )
55+ (deps
56+ (file % {project_root}/ compiler/ bin- js_of_ocaml/ js_of_ocaml.exe)
57+ (file % {project_root}/ compiler/ bin- jsoo_minify/ jsoo_minify.exe)))
58+ (flags (: standard - open Jsoo_compiler_expect_tests_helper))
59+ (preprocess
60+ (pps ppx_expect)))
61+
4762(library
4863 ;; compiler/ tests- compiler/ cond.ml
4964 (name cond_15)
Original file line number Diff line number Diff line change @@ -521,6 +521,7 @@ let compile_and_run_bytecode ?unix s =
521521
522522let compile_and_run
523523 ?debug
524+ ?pretty
524525 ?(skip_modern = false )
525526 ?(flags = [] )
526527 ?effects
@@ -536,6 +537,7 @@ let compile_and_run
536537 in
537538 let output_without_stdlib_modern =
538539 compile_bc_to_javascript
540+ ?pretty
539541 ~flags
540542 ?effects
541543 ?use_js_string
@@ -562,33 +564,29 @@ let compile_and_run
562564 print_string output_with_stdlib_modern;
563565 print_endline " ===========================================" ))
564566
565- let compile_and_parse_whole_program ?(debug = true ) ?flags ?effects ?use_js_string ?unix s
566- =
567+ let compile_and_parse_whole_program
568+ ?(debug = true )
569+ ?pretty
570+ ?flags
571+ ?effects
572+ ?use_js_string
573+ ?unix
574+ s =
567575 with_temp_dir ~f: (fun () ->
568576 s
569577 |> Filetype. ocaml_text_of_string
570578 |> Filetype. write_ocaml ~name: " test.ml"
571579 |> compile_ocaml_to_bc ?unix ~debug
572- |> compile_bc_to_javascript
573- ?flags
574- ?effects
575- ?use_js_string
576- ~pretty: true
577- ~sourcemap: debug
580+ |> compile_bc_to_javascript ?pretty ?flags ?effects ?use_js_string ~sourcemap: debug
578581 |> parse_js)
579582
580- let compile_and_parse ?(debug = true ) ?flags ?effects ?use_js_string s =
583+ let compile_and_parse ?(debug = true ) ?pretty ? flags ?effects ?use_js_string s =
581584 with_temp_dir ~f: (fun () ->
582585 s
583586 |> Filetype. ocaml_text_of_string
584587 |> Filetype. write_ocaml ~name: " test.ml"
585588 |> compile_ocaml_to_cmo ~debug
586- |> compile_cmo_to_javascript
587- ?flags
588- ?effects
589- ?use_js_string
590- ~pretty: true
591- ~sourcemap: debug
589+ |> compile_cmo_to_javascript ?pretty ?flags ?effects ?use_js_string ~sourcemap: debug
592590 |> parse_js)
593591
594592let normalize_path s =
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ val find_function : Javascript.program -> string -> Javascript.function_declarat
7777
7878val compile_and_run :
7979 ?debug : bool
80+ -> ?pretty : bool
8081 -> ?skip_modern : bool
8182 -> ?flags : string list
8283 -> ?effects : bool
@@ -89,6 +90,7 @@ val compile_and_run_bytecode : ?unix:bool -> string -> unit
8990
9091val compile_and_parse :
9192 ?debug : bool
93+ -> ?pretty : bool
9294 -> ?flags : string list
9395 -> ?effects : bool
9496 -> ?use_js_string : bool
@@ -97,6 +99,7 @@ val compile_and_parse :
9799
98100val compile_and_parse_whole_program :
99101 ?debug : bool
102+ -> ?pretty : bool
100103 -> ?flags : string list
101104 -> ?effects : bool
102105 -> ?use_js_string : bool
You can’t perform that action at this time.
0 commit comments