Skip to content
This repository was archived by the owner on Aug 10, 2020. It is now read-only.

Updated bs-mocha #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindings/bs-mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"homepage": "https://github.com/bloomberg/bucklescript-addons#readme",
"dependencies": {
"mocha": "^2.5.3",
"bs-platform" : "^1.3.3"
"bs-platform": "^2.1.0",
"mocha": "^4.0.1"
}
}
6 changes: 3 additions & 3 deletions bindings/bs-mocha/src/bs_mocha.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

external describe : string -> (unit -> unit[@bs]) -> unit = "describe"
external describe : string -> (unit -> unit) -> unit = "describe"
[@@bs.val]

external it : string -> (unit -> unit) -> unit = "it"
Expand Down Expand Up @@ -59,7 +59,7 @@ let assert_fail = fun msg -> fail () () (Js.Undefined.return msg) ""
(* assert -- raises an AssertionError which mocha handls better
*)
let from_suites name (suite : (string * ('a -> unit)) list) =
describe name (fun [@bs] () ->
describe name (fun () ->
List.iter (fun (name, code) -> it name code) suite)

type eq =
Expand All @@ -79,7 +79,7 @@ let close_enough ?(threshold=0.0000001 (* epsilon_float *)) a b =
abs_float (a -. b) < threshold

let from_pair_suites name (suites : pair_suites) =
describe name (fun [@bs] () ->
describe name (fun () ->
suites |>
List.iter (fun (name, code) ->
it name (fun _ ->
Expand Down
46 changes: 37 additions & 9 deletions bindings/bs-mocha/src/bs_mocha.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,45 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

external describe : string -> (unit -> unit) -> unit = "describe"
[@@bs.val]

type eq =
| Eq : 'a *'a -> eq
| Neq : 'a * 'a -> eq
external it : string -> (unit -> unit) -> unit = "it"
[@@bs.val]

external eq : 'a -> 'a -> unit = "deepEqual"
[@@bs.val]
[@@bs.module "assert"]

external neq : 'a -> 'a -> unit = "notDeepEqual"
[@@bs.val]
[@@bs.module "assert"]

external ok : Js.boolean -> unit = "ok"
[@@bs.val]
[@@bs.module "assert"]

external fail : 'a -> 'a -> string Js.undefined -> string -> unit = "fail"
[@@bs.val]
[@@bs.module "assert"]

external dump : 'a array -> unit = "console.log" [@@bs.val ] [@@bs.splice]
external throws : (unit -> unit) -> unit = "throws" [@@bs.val] [@@bs.module "assert"]

val assert_equal : 'a -> 'a -> unit
val assert_notequal : 'a -> 'a -> unit
val assert_ok : bool -> unit
val assert_fail : string -> unit
val from_suites : string -> (string * (unit -> unit)) list -> unit
type eq =
Eq : 'a * 'a -> eq
| Neq : 'a * 'a -> eq
| Ok : bool -> eq
| Approx : float * float -> eq
| ApproxThreshold : float * float * float -> eq
| Approx : float * float -> eq
| ApproxThreshold : float * float * float -> eq
| ThrowAny : (unit -> unit) -> eq
| Fail : unit -> eq
| FailWith : string -> eq
type pair_suites = (string * (unit -> eq)) list

val from_suites : string -> (string * (unit -> unit)) list -> unit
val from_pair_suites : string -> pair_suites -> unit
type pair_suites = (string * (unit -> eq)) list
val close_enough : ?threshold:float -> float -> float -> bool
val from_pair_suites : string -> pair_suites -> unit