Created
January 18, 2013 17:42
-
-
Save follesoe/4566498 to your computer and use it in GitHub Desktop.
Example of testing in SML
This file contains hidden or 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
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 |
This file contains hidden or 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
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))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice! So simple... yet incredibly useful.