#!/usr/bin/env perl

use strict;
use warnings;

my @tests = qw(TestBS TestJL TestJSL TestJHS TestHash TestIntMap TestStrMap TestDM TestHT);

sub clean_tests {
    system "rm -f *.hi *.o @tests";
}

chdir 't';
my $result;

for (@tests) {
    my $compile = "ghc --make $_.hs";
    $result = system $compile;
    
    if ($result != 0) {
        clean_tests;
        die "Error during compilation of $_.";
    }
}

my $harness = qq{HARNESS_PERL="perl -e \\"exec './' . pop; \\" " prove @{tests}};
$result = system $harness;

clean_tests;
