Skip to content

Commit

Permalink
first shot at tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bubaflub committed Jun 14, 2011
1 parent 8d18a72 commit 0204a8e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
10 changes: 10 additions & 0 deletions t/harness
@@ -0,0 +1,10 @@
#! parrot-nqp
INIT { pir::load_bytecode('rosella/harness.pbc'); }
my $factory := Rosella::construct(Rosella::Harness::TestRun::Factory);
$factory.add_test_dirs("Winxed", "t/integer", :recurse(1));
my $testrun := $factory.create();
my $harness := Rosella::construct(Rosella::Harness);
my $testview := $harness.default_view();
$testview.add_run($testrun, 0);
$harness.run($testrun, $testview);
$testview.show_results();
45 changes: 45 additions & 0 deletions t/integer/init/01-init.t
@@ -0,0 +1,45 @@
$load "rosella/test.pbc";
$load "src/GMP.pbc";

namespace GMP {
class Integer;
}

class Test_GMP_Init {

function test_empty_init() {
try {
var x = new GMP.Integer();
self.assert.instance_of(class 'Integer', x);
} catch(e) {
self.assert.fail('cannot construct GMP Integer - empty');
}
}

function test_integer_init() {
try {
var x = new GMP.Integer(32);
self.assert.instance_of(class 'Integer', x);
int i = mpz_get_ui(x);
self.assert.equal(i, 32);
} catch(e) {
self.assert.fail('cannot construct GMP Integer - int');
}
}

function test_string_init() {
try {
var x = new GMP.Integer("33");
self.assert.instance_of(class 'Integer', x);
int i = mpz_get_ui(x);
self.assert.equal(i, 33);
} catch(e) {
self.assert.fail('cannot construct GMP Integer - string');
}
}
}

function main[main]() {
using Rosella.Test.test;
test(class Test_GMP_Init);
}

1 comment on commit 0204a8e

@leto
Copy link
Collaborator

@leto leto commented on 0204a8e Jun 14, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me proud!

Please sign in to comment.