Skip to content

Commit

Permalink
clear code
Browse files Browse the repository at this point in the history
  • Loading branch information
y2k committed Dec 31, 2024
1 parent a93a0cc commit fd48b19
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 81 deletions.
4 changes: 3 additions & 1 deletion lib/backend_interpreter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,6 @@ let main (log : bool) (filename : string) prelude_macros code =
|> try_log "Stage_linter ->" log
|> interpret ctx
in
invoke filename code |> snd |> show_sexp |> unpack_string |> String.trim
invoke filename code |> snd |> show_sexp
|> ( function x when String.starts_with ~prefix:"\"" x -> unpack_string x |> Scanf.unescaped | x -> x )
|> String.trim
1 change: 1 addition & 0 deletions test/samples/input/samples.js.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__POS__
"he\nwo"
(- 1 (- 10 20))
(- 1 2 3 4)
(-> :person (assoc :city "NY"))
Expand Down
1 change: 1 addition & 0 deletions test/samples/input/samples.repl.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__FILENAME__
__LINE__
__POSITION__
"he\nwo"
(- 3 2)
(:b {:a 1 :b 2 :c 3})
(* 3 2)
Expand Down
2 changes: 2 additions & 0 deletions test/samples/output/samples.js.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
=============================
"app/main.clj:1:1"
=============================
"he\nwo"
=============================
(1 - (10 - 20))
=============================
(1 - 2 - 3 - 4)
Expand Down
3 changes: 3 additions & 0 deletions test/samples/output/samples.repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ app/main.clj
=============================
0
=============================
he
wo
=============================
1
=============================
2
Expand Down
79 changes: 0 additions & 79 deletions test/samples/temp.clj

This file was deleted.

5 changes: 4 additions & 1 deletion test/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ let _assert_repl = Utils.assert_ (Lib.main_interpreter true) "interpreter/prelud
let () =
Alcotest.run "Tests"
[
("Local", []);
("Local", [
_assert_repl __POS__ {|"he\nwo"|} "he\nwo";
_assert_js __POS__ {|"he\nwo"|} {|"he\nwo"|};
]);
("Repl", U.make_samples_test (Lib.main_interpreter true) "interpreter/prelude.clj" "samples.repl");
("Bytecode", U.make_samples_test (Lib.main_bytecode true) "bytecode/prelude.clj" "samples.bytecode");
("JS", U.make_samples_test (Lib.main_js true) "js/src/prelude.clj" "samples.js");
Expand Down

0 comments on commit fd48b19

Please sign in to comment.