Created
April 4, 2015 17:49
-
-
Save mwhittaker/508fde3f5367d05ac3a8 to your computer and use it in GitHub Desktop.
Async Unit Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Core.Std | |
open Async.Std | |
let one () = | |
return 1 | |
let two () = | |
after (sec 2.0) >>| fun () -> 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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