Skip to content
Browse files

first shot at tests

  • Loading branch information...
1 parent 8d18a72 commit 0204a8ef442ffce4e07245981ba55baef4dbff66 @bubaflub committed Jun 13, 2011
Showing with 55 additions and 0 deletions.
  1. +10 −0 t/harness
  2. +45 −0 t/integer/init/01-init.t
View
10 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();
View
45 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
Collaborator
leto commented on 0204a8e Jun 14, 2011

This makes me proud!

Please sign in to comment.
Something went wrong with that request. Please try again.