I must admit I’ve liked the concept of QuickCheck ever since I first found it. I tend to write tests that are “too nice” to my code, often missing corner cases and errors caused by strange input. QuickCheck helps me avoid this by generating test data for me. Even in trivial projects it has helped me detect bugs I wouldn’t have found through unit tests written myself.

In this entry I begin testing the parser for HST – A Smalltalk interpreter developed in Haskell (the code developed so far for the parser can be found here and here). To do this I’m going to make use of QuickCheck. I couldn’t find much information on testing a Parsec based parser using QuickCheck, but I’ll have a go and see what happens.

The approach I’ve decided to try here is to have QuickCheck randomly generate an instance of the Abstract Syntax Tree (AST) I’ve developed. I’ll develop a pretty printer that can convert this to a String. Parsing the String should then result in the originally generated AST. I’m not entirely sure this will work, but at least it should give me a good starting point.

Read the rest of this entry »

Completing the Spike

July 23, 2007

This entry continues work on the Spike Solution for HST – a simple Smalltalk interpreter developed in Haskell. In my previous two posts, I developed a parser that was able to parse a Smalltalk version of ‘Hello World’. In this entry I begin developing the execution phase.

I’m going to continue with my approach of keeping it simple and naive for now. I’m aiming for an interpreter than can parse and execute ‘Hello World’ before I begin adding features and improving robustness.

Read the rest of this entry »