#!/usr/bin/env ferite

uses "console";

function throw_error()
{
    number i;
    i = "blarg";
}

number blarg = 10;
string blarg2 = "Yesh";

Console.println( "Running error tests" );

Console.println( "Test One:" );
iferr
{
    blarg = "blarg";
}
fix
{
    Console.println( "First Block Failed: " + err.str + " (" + err.num +") (correct)" );
}
else
{
    Console.println( "First Block Succeded (error: this shouldn't happen)" );
}

Console.println( "Test Two:" );
iferr
{
    blarg2 = "Russpect";
}
fix
{
    Console.println( "Second Block Failed (error: this shouldn't happen)" );
}
else
{
    Console.println( "Second Block Succeded (correct)" );
}

Console.println( "Test Three:" );
iferr
{
    blarg2 = 2;
}
fix
{
    Console.println( "Third Block Failed (correct)" );
}
else
{
    Console.println( "Third Block Succeded (error: this shouldn't happen)" );
}

Console.println( "Test Four:" );

iferr
{
    iferr
    {
        throw_error();
    }
    fix
    {
        Console.println( "Handled here (correct)" );
    }
}
fix
{
    Console.println( "And not here....As..." );
    Console.println( "You should never see this." );
}
