Repository: lucy-clownfish Updated Branches: refs/heads/master 1ea150153 -> dafc3801b
Rework test for invalid callbacks The old test relied on To_Host being called from the constructor. Add a custom test class to invoke an invalid callback from C. Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/e702b272 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/e702b272 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/e702b272 Branch: refs/heads/master Commit: e702b2722850a1070fe05f108d85b02da4d35c22 Parents: f6960c5 Author: Nick Wellnhofer <[email protected]> Authored: Fri May 29 13:44:31 2015 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Fri May 29 13:53:27 2015 +0200 ---------------------------------------------------------------------- runtime/core/Clownfish/Test/TestObj.c | 7 +++++++ runtime/core/Clownfish/Test/TestObj.cfh | 10 ++++++++++ runtime/perl/t/binding/019-obj.t | 8 ++++---- 3 files changed, 21 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e702b272/runtime/core/Clownfish/Test/TestObj.c ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestObj.c b/runtime/core/Clownfish/Test/TestObj.c index c0d25ea..1bac642 100644 --- a/runtime/core/Clownfish/Test/TestObj.c +++ b/runtime/core/Clownfish/Test/TestObj.c @@ -151,6 +151,13 @@ TestObj_Run_IMP(TestObj *self, TestBatchRunner *runner) { /*********************************************************************/ +void +CallbackTestObj_Invoke_Callback_IMP(CallbackTestObj *self) { + CallbackTestObj_Invalid_Callback(self); +} + +/*********************************************************************/ + String* AliasTestObj_Aliased_IMP(AliasTestObj *self) { UNUSED_VAR(self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e702b272/runtime/core/Clownfish/Test/TestObj.cfh ---------------------------------------------------------------------- diff --git a/runtime/core/Clownfish/Test/TestObj.cfh b/runtime/core/Clownfish/Test/TestObj.cfh index 958224b..885ad7f 100644 --- a/runtime/core/Clownfish/Test/TestObj.cfh +++ b/runtime/core/Clownfish/Test/TestObj.cfh @@ -26,6 +26,16 @@ class Clownfish::Test::TestObj Run(TestObj *self, TestBatchRunner *runner); } +class Clownfish::Test::CallbackTestObj { + /** A method that can't be overridden from the host language. + */ + abstract void* + Invalid_Callback(CallbackTestObj *self); + + void + Invoke_Callback(CallbackTestObj *self); +} + class Clownfish::Test::AliasTestObj { incremented String* Aliased(AliasTestObj *self); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e702b272/runtime/perl/t/binding/019-obj.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/binding/019-obj.t b/runtime/perl/t/binding/019-obj.t index 93ad0e8..5de41df 100644 --- a/runtime/perl/t/binding/019-obj.t +++ b/runtime/perl/t/binding/019-obj.t @@ -46,9 +46,9 @@ use base qw( Clownfish::Obj ); } package InvalidCallbackTestObj; -use base qw( Clownfish::Obj ); +use base qw( Clownfish::Test::CallbackTestObj ); { - sub to_host {} + sub invalid_callback {} } package OverriddenAliasTestObj; @@ -138,8 +138,8 @@ SKIP: { like( $@, qr/NULL/, "Don't allow methods without nullable return values to return NULL" ); - eval { InvalidCallbackTestObj->new; }; - like( $@, qr/Can't override to_host via binding/ ); + eval { InvalidCallbackTestObj->new->invoke_callback; }; + like( $@, qr/Can't override invalid_callback via binding/ ); } my $alias_test = Clownfish::Test::AliasTestObj->new;
