Skip to content

Commit

Permalink
fix several tests, remove a few unneeded debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Mar 19, 2011
1 parent 27b9ccd commit acf6e7a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 78 deletions.
9 changes: 9 additions & 0 deletions src/core/Rosella.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,14 @@ namespace Rosella
return null;
return find_method(object, meth_name);
}

function get_unique_count()
{
int i = 0;
loop_top:
i = i + 1;
yield i;
goto loop_top;
}
}

4 changes: 3 additions & 1 deletion src/proxy/Factory.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ namespace Rosella { namespace Proxy

say("Proxy.create_internal: " + string(target_class));
var proxy_class = null;
string proxy_class_name = "!!!PROXY_" + string(target_class);
using Rosella.get_unique_count;
int id = get_unique_count();
string proxy_class_name = sprintf("!!!PROXY_%s_%d", [string(target_class), id]);
say("\tproxy_class_name: " + proxy_class_name);
${ newclass proxy_class, proxy_class_name };
say("\tproxy_class: " + string(typeof(proxy_class)));
Expand Down
38 changes: 19 additions & 19 deletions src/test/TestCase.winxed
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
namespace Rosella { namespace Test
{
class FooBar
class TestCase
{
var method;
var context;
var test_method;
var test_context;

//function set_attr_str[vtable](string attr, var value)
//{
// die("Cannot modify the details of the TestCase");
//}
function set_attr_str[vtable](string attr, var value)
{
die("Cannot modify the details of the TestCase");
}

//function get_attr_str[vtable](string attr)
//{
// var myclass = class Rosella.Test.TestCase;
// var value = null;
// if (attr == 'context' || attr == '$!context')
// ${ getattribute value, self, myclass, "test_context" };
// else if (attr == 'method' || attr == '$!method')
// ${ getattribute value, self, myclass, "test_method" };
// else
// die("TestCase has attributes 'context' and 'method'. Not " + attr);
// return value;
//}
function get_attr_str[vtable](string attr)
{
var myclass = class Rosella.Test.TestCase;
var value = null;
if (attr == 'context' || attr == '$!context')
${ getattribute value, self, myclass, "test_context" };
else if (attr == 'method' || attr == '$!method')
${ getattribute value, self, myclass, "test_method" };
else
die("TestCase has attributes 'context' and 'method'. Not " + attr);
return value;
}
}
}}
12 changes: 4 additions & 8 deletions src/test/TestFactory.winxed
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace Rosella { namespace Test

function create(var p [slurpy], var n [slurpy,named])
{
say(int(p));
return self.create_typed(class Rosella.Test.FooBar, p:[flat], n:[flat,named]);
return self.create_typed(class Rosella.Test.TestCase, p:[flat], n:[flat,named]);
}

function create_typed(var type, var test_name, var test_method,
Expand All @@ -23,14 +22,11 @@ namespace Rosella { namespace Test
using Rosella.get_type_class;

var test_class = get_type_class(type);
var testcase_class = class Rosella.Test.FooBar;
var testcase_class = class Rosella.Test.TestCase;
var test = build(testcase_class, test_method);
var context = self.test_context;
say("building test " + string(test_name));
say("\tbuilding test for " + string(test_method));
say("\tbuilding test type " + string(typeof(type)));
${ setattribute test, testcase_class, "context", context };
${ setattribute test, testcase_class, "method", test_method };
${ setattribute test, testcase_class, "test_context", context };
${ setattribute test, testcase_class, "test_method", test_method };

return test;
}
Expand Down
2 changes: 1 addition & 1 deletion t/action/Action.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ActionTest {
}

method test_prepare_args_empty() {
self.todo("Oh noes!");
$!context.todo("Oh noes!");
my $action := Rosella::build(Rosella::Action, "foo", []);
my @pos := [];
my %named := {};
Expand Down
10 changes: 5 additions & 5 deletions t/action/Argument.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ class Action::Argument::Test {
}

method test_name() {
self.unimplemented("This");
$!context.unimplemented("This");
}

method test_position() {
self.unimplemented("This");
$!context.unimplemented("This");
}

method test_set_positioning() {
self.unimplemented("This");
$!context.unimplemented("This");
}

method test_type() {
self.unimplemented("This");
$!context.unimplemented("This");
}

method test_resolve_to() {
self.unimplemented("This");
$!context.unimplemented("This");
}
}
20 changes: 11 additions & 9 deletions t/test/Result.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,24 @@ class Test::Result::Test {
}

method test_start_test() {
my $c := get_listener_controller();
my $clistener := get_listener_controller();
$clistener.expect_method("start_test").once.with_any_args;
my $mlistener := $clistener.mock();
my $testcontext := "dummy";
my $result := Rosella::build(Rosella::Test::Result, [$mlistener]);
my $faketest := MyFakeTest.new();
$c.expect_method("start_test").once.with_any_args;
my $m := $c.mock();
my $result := Rosella::build(Rosella::Test::Result, [$m]);
$result.start_test($faketest);
$c.verify();
$result.start_test($faketest, $testcontext);
$clistener.verify();
}

method test_end_test() {
my $c := get_listener_controller();
my $faketest := MyFakeTest.new();
$c.expect_method("end_test").once.with_any_args;
my $m := $c.mock();
my $testcontext := "dummy";
my $result := Rosella::build(Rosella::Test::Result, [$m]);
$result.end_test($faketest);
$result.end_test($faketest, $testcontext);
$c.verify();
}

Expand All @@ -60,7 +62,7 @@ class Test::Result::Test {
my $m := $c.mock();
my $result := Rosella::build(Rosella::Test::Result, [$m]);
Assert::equal($result.was_successful, 1);
$result.add_error($faketest, "oops");
$result.add_error($faketest, "context", "oops");
$c.verify();
Assert::equal($result.was_successful, 0);
}
Expand All @@ -72,7 +74,7 @@ class Test::Result::Test {
my $m := $c.mock();
my $result := Rosella::build(Rosella::Test::Result, [$m]);
Assert::equal($result.was_successful, 1);
$result.add_failure($faketest, "oops");
$result.add_failure($faketest, "context", "oops");
$c.verify();
Assert::equal($result.was_successful, 0);
}
Expand Down
35 changes: 0 additions & 35 deletions t/test/Suite.t
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,4 @@ class Test::Suite::Test {

method test_run() {
}

method test_run_test() {
my $factory := Rosella::build(Rosella::MockObject::Factory);

# verify that we call all the right methods on the test.
# TODO: These expectations are ordered
#my $ctest := $factory.create_typed(MyFakeTest);
#$ctest.expect_get("name").once.will_return("test_one");
#$ctest.expect_method("__set_up").once.with_no_args;
#$ctest.expect_method("test_one").once.with_no_args;
#$ctest.expect_method("__tear_down").once.with_no_args;

# Verify that the result gets the correct details.
#my $cresult := $factory.create_typed(Rosella::Test::Result);
#$cresult.expect_method("start_test").once.with_any_args;
#$cresult.expect_method("end_test").once.with_any_args;

#my $test := $ctest.mock();
#my $result := $cresult.mock();
#my $suite := Rosella::build(Rosella::Test::Suite, [$test], "suite");
#$suite.run_test($test, $result);
#$ctest.verify();
}

method test_run_test_method() {
my $factory := Rosella::build(Rosella::MockObject::Factory);
pir::say(pir::typeof__SP(MyFakeTest));
my $controller := $factory.create_typed(MyFakeTest);
$controller.expect_get("name").once.will_return("test_one");
$controller.expect_method("test_one").once.with_no_args();
my $m := $controller.mock();
my $suite := Rosella::build(Rosella::Test::Suite, [$m], "suite");
$suite.run_test_method($m);
$controller.verify();
}
}

0 comments on commit acf6e7a

Please sign in to comment.