diff --git a/CHANGES b/CHANGES index 21e8994..f12a916 100644 --- a/CHANGES +++ b/CHANGES @@ -1,2 +1,2 @@ -0.1 (2013-06-09): +0.1 (2013-06-10): * first alpha release diff --git a/TODO b/TODO index 58c4e79..7b10000 100644 --- a/TODO +++ b/TODO @@ -1,2 +1 @@ -* Fix Lwt type unification bug (that renders it unusable) * Async backend ? diff --git a/lib/smtp.ml b/lib/smtp.ml index dfc9e22..babbeb0 100644 --- a/lib/smtp.ml +++ b/lib/smtp.ml @@ -95,8 +95,8 @@ module Make (IO : IO) = struct let finally f g = try - let ret = f () in g (); ret - with exn -> g (); IO.fail exn + f () >>= fun ret -> g () >>= fun () -> IO.return ret + with exn -> g () >>= fun () -> IO.fail exn let sendmail ?(host="") ?(port="smtp") ~name ~from ~to_ ~body () = connect ~host ~port ~name () >>= fun h -> diff --git a/lwt/smtp_lwt.ml b/lwt/smtp_lwt.ml index 41099cd..447830f 100644 --- a/lwt/smtp_lwt.ml +++ b/lwt/smtp_lwt.ml @@ -1,4 +1,4 @@ -module IO : Smtp.IO = struct +module IO = struct type 'a t = 'a Lwt.t let return = Lwt.return let bind = Lwt.bind diff --git a/smtp.obuild b/smtp.obuild index f9d796e..a99f9e9 100644 --- a/smtp.obuild +++ b/smtp.obuild @@ -12,10 +12,22 @@ library smtp library smtp_unix modules: Smtp_unix - builddepends: smtp + builddepends: smtp, unix src-dir: unix library smtp_lwt modules: Smtp_lwt builddepends: smtp, lwt, lwt.unix src-dir: lwt + +test test_lwt + mainis: test_lwt.ml + builddepends: smtp_lwt + src-dir: test + rundir: test + +test test_unix + mainis: test_unix.ml + builddepends: smtp_unix + src-dir: test + rundir: test diff --git a/test/test_lwt.ml b/test/test_lwt.ml new file mode 100644 index 0000000..5a073e7 --- /dev/null +++ b/test/test_lwt.ml @@ -0,0 +1,11 @@ +open Smtp_lwt + +let () = match Lwt_main.run + (sendmail + ~port:"2525" + ~name:"localhost" + ~from:Addr.(of_string "vb@luminar.eu.org") + ~to_:[Addr.(of_string "vb@luminar.eu.org")] + ~body:"Bleh" ()) with + | `Ok (code, msg) -> Printf.printf "OK %d %s\n" code msg + | `Failure (code, msg) -> Printf.eprintf "Failure %d %s\n" code msg diff --git a/test/test_unix.ml b/test/test_unix.ml new file mode 100644 index 0000000..3633939 --- /dev/null +++ b/test/test_unix.ml @@ -0,0 +1,11 @@ +open Smtp_unix + +let () = match + (sendmail + ~port:"2525" + ~name:"localhost" + ~from:Addr.(of_string "vb@luminar.eu.org") + ~to_:[Addr.(of_string "vb@luminar.eu.org")] + ~body:"Bleh" ()) with + | `Ok (code, msg) -> Printf.printf "OK %d %s\n" code msg + | `Failure (code, msg) -> Printf.eprintf "Failure %d %s\n" code msg diff --git a/unix/smtp_unix.ml b/unix/smtp_unix.ml index 9679756..314796e 100644 --- a/unix/smtp_unix.ml +++ b/unix/smtp_unix.ml @@ -1,4 +1,4 @@ -module IO : Smtp.IO = struct +module IO = struct type 'a t = 'a let return v = v let bind v f = f v