Skip to content

Commit

Permalink
Make browser_only test to be reason syntax as well
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Aug 14, 2023
1 parent 0e2e95d commit 30a2b36
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/ppx/test_snapshot/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@
(libraries pipe_first_ppx double_hash_ppx regex_ppx browser_ppx ppxlib))

(rule
(targets transformation.result)
(deps input.ml)
(targets ocaml.preprocessed)
(deps ocaml.ml)
(action
(run ./main.exe --impl %{deps} -o %{targets})))

(rule
(targets reason.preprocessed)
(deps
(:input reason.re))
(action
(progn
(with-stdout-to
%{targets}
(run refmt --parse re --print ml %{input}))
(run ./main.exe --impl %{targets} -o %{targets})
(run refmt --parse ml --print re --in-place %{targets}))))

(rule
(alias runtest)
(action
(diff output.expected transformation.result)))
(progn
(diff reason.expected reason.preprocessed)
(diff ocaml.expected ocaml.preprocessed))))
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions packages/ppx/test_snapshot/reason.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[@warning "-27"]
let loadInitialText = () =>
raise(
ReactDOM.Impossible_in_ssr(
"fun () ->\n setHtmlFetchState Loading;\n (((((WcApi.fetchHTML WcConstants.initialText) |. Promise.flatMap)\n (fun html ->\n (onChange (html |. WcStringHelpers.htmlToText)) |. Promise.resolved))\n |. Promise.Js.catch)\n (fun _ -> (setHtmlFetchState Error) |. Promise.resolved))\n |. ignore",
),
);
7 changes: 7 additions & 0 deletions packages/ppx/test_snapshot/reason.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let%browser_only loadInitialText = () => {
setHtmlFetchState(Loading);
WcApi.fetchHTML(WcConstants.initialText)
->Promise.flatMap(html => onChange(html->WcStringHelpers.htmlToText)->Promise.resolved)
->Promise.Js.catch(_ => setHtmlFetchState(Error)->Promise.resolved)
->ignore;
};

0 comments on commit 30a2b36

Please sign in to comment.