Skip to content

Instantly share code, notes, and snippets.

@mwhittaker
Created April 4, 2015 17:49
Show Gist options
  • Save mwhittaker/508fde3f5367d05ac3a8 to your computer and use it in GitHub Desktop.
Save mwhittaker/508fde3f5367d05ac3a8 to your computer and use it in GitHub Desktop.
Async Unit Tests
open Core.Std
open Async.Std
let one () =
return 1
let two () =
after (sec 2.0) >>| fun () -> 2
open Core.Std
open Async.Std
open Main
open Assertions
(* https://groups.google.com/forum/#!topic/ocaml-core/S862OC-o5hA *)
let join (d: 'a Deferred.t) : 'a =
Async_unix.Thread_safe.block_on_async_exn (fun () -> d)
TEST_UNIT "test_one" =
join (one ()) === 1
TEST_UNIT "test_two" =
join (two ()) === 2
default: all
all: compile test
compile:
cs3110 compile -t -p core -p async main.ml
cs3110 compile -t -p core -p async main_test.ml
test: compile
cs3110 test main_test.ml
clean:
cs3110 clean all
rm -f inline_tests.log
.PHONY: default all compile test clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment