Skip to content

Commit

Permalink
test exception type of div by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
NotFound committed Jun 26, 2011
1 parent b4ecb18 commit 3cbb4c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions t/advanced/02intops.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! winxed

// int operators

using extern Test.More plan, throws_type, diag;

$include_const 'except_types.pasm';

function main()
{
plan (1);

diag("Exceptions:");

throws_type(divzero, EXCEPTION_DIV_BY_ZERO, "division by zero");
}

function divzero()
{
// Use a function to make sure is not evaluated at compile time.
int i = divide(1, 0);
}

function divide(int a, int b)
{
return a / b;
}

// End
4 changes: 2 additions & 2 deletions t/basic/02intops.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Basic tests: int operators

using extern Test.More plan, is, throws_type, diag;
using extern Test.More plan, is, diag;

function main()
{
Expand Down Expand Up @@ -56,7 +56,7 @@ function main()

diag("Exceptions:");

is (divzero(), 1, "division by zero throws");
is(divzero(), 1, "division by zero throws");
}

function divzero()
Expand Down

0 comments on commit 3cbb4c2

Please sign in to comment.