aspose file tools*
The moose likes Functional Programming and the fly likes Coursera ProgLang: testing in Standard ML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Functional Programming
Bookmark "Coursera ProgLang: testing in Standard ML" Watch "Coursera ProgLang: testing in Standard ML" New topic
Forums: Functional Programming Blog around the Campfire
Author

Coursera ProgLang: testing in Standard ML

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

So far so good. I liked week 1. Can anyone who has taken the course take a look at this? I'm curious what you think.

And learning emacs has been fine. I'm not great at it yet but at a speed comparable to notepad. (I'm really fast in vi). That'll be another blog post - how to learn emacs.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1775
    
  14

Hi Jeanne - I moved your post as I think it's a topic that deserves its own thread.

You're already ahead of me in your use of a testing framework for SML. I just wrote ad hoc boolean functions to test specific functions e.g. to test if rev_string() actually reverses a given string:


I haven't used ML since the course, but it seems sensible to use a unit testing library - even a simple one - if one is available.

The printing thing is a new one on me - I just put my test results in a list then inspected the list. I know I/O is problematic in pure functional languages because it has side effects - each time you call the read/print operation you leave the system in a different state - but I though most languages had a way around this by encapsulating the side effects with monads or something. Maybe somebody else knows more about how to manage this kind of thing in SML?

As for learning Emacs, respect! I need to find time to try it again, as it seems all the Cool Kids are using Emacs these days...


No more Blub for me, thank you, Vicar.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

Looks good. If I did it again I'd definitely want to investigate a unit testing framework. I did take the time to use a proper framework for the next two languages in the course (Racket and Ruby), but for SML I took a similar approach to Chris. I did try to make the tests a little more "expressive" by assigning a comparison to a variable with a relevant name (helpful because when I ran the file these are printed along with the True/False), but it was still a matter of scanning the output for any Falses.

As a quick example, here's one of my tests from the first assignment.

chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1775
    
  14

Yes, I used RackUnit for Racket testing, which was very useful (I vaguely recall that Matt may have recommended it in the course forum - if so, thanks!), and RSpec for Ruby, but we didn't do all that much with Ruby, so I didn't really make much use of RSpec either.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Chris: The problem isn't printing from SML. That worked fine. The problem is keeping track of state to print out at the end if any of the tests failed. The author of the suite uses Python for that and I used a shell script. I don't see myself using emacs much after the class. It's fine though. Just because I'm so much faster in vi and I don't see the need to invest time to become THAT proficient in emacs. But I'm fast enough for the purposes of the class in one day. I expect I'll get better in the next few weeks too.

Matthew: That's what the professor's sample tests look like. I rely too much on JUnit in my real job (and coderanch development for that matter) that I want to be able to push one button and know if I'm good. I don't have the desire to go back to scanning output to see if there are any falses printed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Coursera ProgLang: testing in Standard ML