I am implementing a function that takes two dates that are of type (int * int * int)
: the first part is the year, the second part is the month and the third part is the day. It should return true
if the first date is older than the second.
I want to test the function and I'm having problems with that. This is the file ex1.sml
fun is_older(d1 : (int * int * int), d2 : (int * int * int)) =
if #1 d1 < #2 d2 then
true
else if #2 d1 < #2 d2 then
true
else
#3 d1 < #3 d2
And this is the file ex1-test.sml
that should test the function:
use "ex1.sml"
val test1 = is_older ((1,2,3),(2,3,4)) = true
Whenever I try to run this last file, by loading in the REPL, I always end up with the error: Error: syntax error: replacing VAL with EQUALOP
However if I put the test in ex1.ml
and load it in the REPL it doesn't give any error.
fun is_older(d1 : (int * int * int), d2 : (int * int * int)) =
if #1 d1 < #2 d2 then
true
else if #2 d1 < #2 d2 then
true
else
#3 d1 < #3 d2
val test1 = is_older ((1,2,3),(2,3,4)) = true
I would like to have the tests in a separate file which then includes the definitions and runs the tests, as I was trying to do above. Why doesn't it work?