smlunit hello world – with a python dependency

Main menu:

Topics

Recent Posts

Feeds

RSS Feed RSS - Posts

July 2016
M T W T F S S
« Jun   Aug »
 123
45678910
11121314151617
18192021222324
25262728293031

Past Posts

Java/Java EE

JDBC

Other

smlunit hello world – with a python dependency

July 31st, 2016 by Jeanne Boyarsky

Three years is long enough to forget a lot so I managed to forget that I got this working with python shortly after writing this blog post. Writing this down so I don’t forget again.

  1. Download the smlunit github project. (at a minimum you need the smlunit file and the lib directory)
  2. Download the asserts file and put it in your directory (or elsewhere and refer to it from there)
  3. Write a simple function in a file named helloWorld.sml:
    fun hello(name : string) = "Hello " ^ name
  4. Write a simple test in a file named helloWorldTest.sml:
    use "asserts.sml";
    use "helloWorld.sml";
    
    assertEqual "hello" (hello("Jeanne")) "did it work?";
  5. Run it:
    Jjeanne$ ./smlunit helloWorldTest.sml 
    did it work?..........................................................FAIL
        Expected: "Hello Jeanne"
        Actual: "hello"
    
    ---------------------------------------
    Ran 1 test in 0.204 seconds (1 failure)
    
  6. It didn’t work! Fix the expected string in the test (should be assertEqual “Hello Jeanne”…
  7. Run the test again
    jeanne$ ./smlunit helloWorldTest.sml 
    did it work?............................................................OK
    
    ---------------------------
    Ran 1 test in 0.207 seconds
    
  8. Success!

Write a comment