I'm currently grading assignments for a course on SML. I've written some test cases to automatically check correctness of functions in the students' assignments, and I'd like to be able to import their code and then run the test cases against that code. I'm imagining something similar to python import semantics. Right now, the best solution I have is to copy-paste this code at the bottom of each assignment. Is this possible with SML?
Asked
Active
Viewed 5,070 times
2 Answers
8
Use use
:
use "filename.sml";
(* your test cases here *)
If you have the student solution in "student.sml" and your test cases in "tests.sml":
use "student.sml";
use "tests.sml";

Emil Vikström
- 90,431
- 16
- 141
- 175
-
2Can you use the `use` function inside another SML file? I have tried and I always get an `operator is not a function` error. – rlandster Feb 09 '13 at 14:55
-
1rlandster, yes, you can have use in your SML files. It behaves as any other function. – Emil Vikström Feb 10 '13 at 21:00
-
1Just as a note, ML implementations are not required to implement the `use` function. – Hunter McMillen Oct 23 '16 at 03:10