CS 550
Spring 2015
Programming Languages
Thursdays 18:30-21:20
Korman Center 104C

Instructor:
Geoffrey Mainland
mainland+cs550@cs.drexel.edu
University Crossings 106
Teaching Assistant:
Mark Boady
mwb33@drexel.edu
Warning! This material is for an old version of the course.

For this homework, you will write property-based tests for interval sets.

Please download the file PropertyTests.hs here and add it to your existing hw6 directory.

You may build a binary property-tests that will execute your property-based tests by typing make property-tests. Run the resulting binary, named property-tests, to run your property-based tests.

Your code must run on tux under the version of ghc that we provide.

Be sure to commit your work to the repository.

This assignment is worth 50 points. There are 51 possible points.

In the Makefile we distributed for Homework 6, please change the line

SRC = $(wildcard src/*.hs)

to

SRC = $(wildcard *.hs)

Problem 1: Property-based Testing (50 points total)

You must complete the implementations of the following QuickCheck properties in PropertyTests.hs. Each test is worth 10 points.

prop_empty :: Bool
prop_member :: Int -> IS -> Bool
prop_merge :: IS -> IS -> Bool
prop_insert :: Int -> IS -> Bool
prop_delete :: Int -> IS -> Bool

We have provided an Arbitrary instance that you can use for testing and a function, model, that takes a value of type IntSet and returns a model of the IntSet. This model consists of a sorted list of integers in the IntSet. This model is an inefficient way to implement a set of integers, but it is easy to reason about. Your tests should use model to relate operations on values of type IntSet to operations on lists of integers.

You will likely want to use the functions sort, which sorts a list, and nub, which removes duplicate entries from a list.

For example, consider the prop_insert test. It should test that the model of the IntSet obtained by inserting a value x into an IntSet s is the same as inserting the value x into the list that is the model of s.

Problem 2: Homework Statistics (1 point)

How long did it take you to complete each problem? Please tell us in a comment in PropertyTests.hs. You must tell us how long each problem took you, expressed as a quantitative measure of time, to receive the point.