Skip to content

Instantly share code, notes, and snippets.

@follesoe
Created January 18, 2013 17:42
Show Gist options
  • Save follesoe/4566498 to your computer and use it in GitHub Desktop.
Save follesoe/4566498 to your computer and use it in GitHub Desktop.
Example of testing in SML
val true_if_first_date_is_before_second_date = " -- PASS" : string
val false_if_same_date = " -- PASS" : string
val false_if_second_date_is_after_first_date = " -- PASS" : string
fun assert_true (actual : bool) =
if actual
then " -- PASS"
else "Expected true, was false. -- FAIL"
fun assert_false (actual : bool) =
if actual
then "Expected false, was true. -- FAIL"
else " -- PASS"
val true_if_first_date_is_before_second_date =
assert_true(is_older((2013,1,1), (2013,1,2)))
val false_if_same_date =
assert_false(is_older((2013,1,1), (2013,1,1)))
val false_if_second_date_is_after_first_date =
assert_false(is_older((2013,1,2), (2013,1,1)))
@cammcad
Copy link

cammcad commented Jan 18, 2013

Nice! So simple... yet incredibly useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment