Skip to content

Commit

Permalink
Merge pull request #5 from jchavarri/reorg-tests
Browse files Browse the repository at this point in the history
Reorg tests
  • Loading branch information
jchavarri authored Jan 29, 2024
2 parents d28bdfc + 7607f98 commit fd1dfba
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 54 deletions.
3 changes: 2 additions & 1 deletion src/fest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ external strict_equal : 'a -> 'a -> unit = "strictEqual"

let strictEqual = strict_equal

external deep_strict_equal: 'a -> 'a -> unit = "deepStrictEqual" [@@mel.send.pipe: assertion]
external deep_strict_equal : 'a -> 'a -> unit = "deepStrictEqual"
[@@mel.send.pipe: assertion]

let deepStrictEqual = deep_strict_equal
44 changes: 44 additions & 0 deletions test/bindings.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
open Fest

let () = test "strict_equal" (fun () -> expect |> strict_equal 1 1)
let () = test "strictEqual" (fun () -> expect |> strictEqual 1 1)
let () = test "equal" (fun () -> expect |> equal "foo" "foo")

module Deep_strict_equal = struct
type foo = Foo of int
type bar = { foo : foo; bar : string }

let assertion ~f () =
expect
|> f
{ foo = Foo 42; bar = "hello" }
(let bar = { foo = Foo 40; bar = "hell" } in
let bar = { bar with bar = bar.bar ^ "o" } in
let bar =
{ bar with foo = (match bar.foo with Foo x -> Foo (x + 2)) }
in
bar)

let () = test "deep_strict_equal" (assertion ~f:deep_strict_equal)
let () = test "deepStrictEqual" (assertion ~f:deepStrictEqual)
end

module Promise = struct
open Fest.Promise

let inner input output =
test
("Math.defaultRound: " ^ Js.Float.toString input)
(fun () ->
expect
|> equal output (input |> Js.Math.round |> int_of_float |> string_of_int);
Js.Promise.resolve ())

let (_ : unit Js.Promise.t) =
let* () =
test "promise" (fun () ->
let* () = inner 0. "0" in
inner 0.055 "0")
in
Js.Promise.resolve ()
end
27 changes: 0 additions & 27 deletions test/two.re → test/components.re
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,3 @@ let () =
let el = RTL.getByText(~matcher=`Str("Hello Nila"), result);
expect |> strictEqual(textContent(el), "Hello Nila");
});

type foo =
| Foo(int);

type bar = {
foo,
bar: string,
};

test("test variant", () =>
expect
|> deepStrictEqual(
{foo: Foo(42), bar: "hello"},
{
let bar = {foo: Foo(40), bar: "hell"};
let bar = {...bar, bar: bar.bar ++ "o"};
let bar = {
...bar,
foo:
switch (bar.foo) {
| Foo(x) => Foo(x + 2)
},
};
bar;
},
)
);
8 changes: 4 additions & 4 deletions test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
(rule
(alias runtest)
(deps
(:input ./node/test/one.mjs)
(:input ./node/test/bindings.mjs)
%{bin:node})
(action
(run time %{bin:node} %{input})))
(run %{bin:node} %{input})))

(rule
(alias runtest)
(deps
(alias_rec main)
(:input ./node/test/two.mjs)
(:input ./node/test/components.mjs)
%{bin:node})
(action
(run time %{bin:node} %{input})))
(run %{bin:node} %{input})))
22 changes: 0 additions & 22 deletions test/one.ml

This file was deleted.

0 comments on commit fd1dfba

Please sign in to comment.