Move remaining test files to t/binding
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/8e729e10 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/8e729e10 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/8e729e10 Branch: refs/heads/master Commit: 8e729e103f153bbdf5d5fdaab25d7fb3098a802d Parents: a0a54b8 Author: Nick Wellnhofer <[email protected]> Authored: Tue Nov 17 19:31:09 2015 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Tue Nov 17 19:31:09 2015 +0100 ---------------------------------------------------------------------- runtime/perl/t/002-clownfish.t | 52 --------------------------- runtime/perl/t/018-host.t | 42 ---------------------- runtime/perl/t/021-class.t | 54 ----------------------------- runtime/perl/t/binding/002-clownfish.t | 52 +++++++++++++++++++++++++++ runtime/perl/t/binding/010-class.t | 54 +++++++++++++++++++++++++++++ runtime/perl/t/binding/018-host.t | 42 ++++++++++++++++++++++ 6 files changed, 148 insertions(+), 148 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8e729e10/runtime/perl/t/002-clownfish.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/002-clownfish.t b/runtime/perl/t/002-clownfish.t deleted file mode 100644 index d3e36b7..0000000 --- a/runtime/perl/t/002-clownfish.t +++ /dev/null @@ -1,52 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; - -use Test::More; -use File::Find 'find'; - -my @modules; - -# None for now -- until we remove a module. -my %excluded = map { ( $_ => 1 ) } qw(); - -find( - { no_chdir => 1, - wanted => sub { - return unless $File::Find::name =~ /\.pm$/; - push @modules, $File::Find::name; - } - }, - 'lib' -); - -plan( tests => scalar @modules ); - -for (@modules) { - s/^.*?Clownfish/Clownfish/; - s/\.pm$//; - s/\W+/::/g; - if ( $excluded{$_} ) { - eval qq|use $_;|; - like( $@, qr/removed|replaced|renamed/i, - "Removed module '$_' throws error on load" ); - } - else { - use_ok($_); - } -} - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8e729e10/runtime/perl/t/018-host.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/018-host.t b/runtime/perl/t/018-host.t deleted file mode 100644 index dc546fd..0000000 --- a/runtime/perl/t/018-host.t +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; - -use Test::More tests => 3; -use Clownfish qw( to_clownfish ); - -my %complex_data_structure = ( - a => [ 1, 2, 3, { ooga => 'booga' } ], - b => { foo => 'foofoo', bar => 'barbar' }, -); -my $kobj = to_clownfish( \%complex_data_structure ); -isa_ok( $kobj, 'Clownfish::Obj' ); -my $transformed = $kobj->to_perl; -is_deeply( $transformed, \%complex_data_structure, - "transform from Perl to Clownfish data structures and back" ); - -my $bread_and_butter = Clownfish::Hash->new; -$bread_and_butter->store( 'bread', Clownfish::Blob->new('butter') ); -my $salt_and_pepper = Clownfish::Hash->new; -$salt_and_pepper->store( 'salt', Clownfish::ByteBuf->new('pepper') ); -$complex_data_structure{c} = $bread_and_butter; -$complex_data_structure{d} = $salt_and_pepper; -$transformed = to_clownfish( \%complex_data_structure )->to_perl; -$complex_data_structure{c} = { bread => 'butter' }; -$complex_data_structure{d} = { salt => 'pepper' }; -is_deeply( $transformed, \%complex_data_structure, - "handle mixed data structure correctly" ); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8e729e10/runtime/perl/t/021-class.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/021-class.t b/runtime/perl/t/021-class.t deleted file mode 100644 index 21872ff..0000000 --- a/runtime/perl/t/021-class.t +++ /dev/null @@ -1,54 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use strict; -use warnings; - -package MyObj; -use base qw( Clownfish::Obj ); - -sub oodle { } - -package main; - -use Test::More tests => 5; - -my $stringified; -my $storage = Clownfish::Hash->new; - -{ - my $subclassed_obj = MyObj->new; - $stringified = $subclassed_obj->to_string; - - isa_ok( $subclassed_obj, "MyObj", "Perl isa reports correct subclass" ); - - # Store the subclassed object. At the end of this block, the Perl object - # will go out of scope and DESTROY will be called, but the Clownfish object - # will persist. - $storage->store( "test", $subclassed_obj ); -} - -my $resurrected = $storage->fetch("test"); - -isa_ok( $resurrected, "MyObj", "subclass name survived Perl destruction" ); -is( $resurrected->to_string, $stringified, - "It's the same Hash from earlier (though a different Perl object)" ); - -is( $resurrected->get_class_name, - "MyObj", "subclassed object still performs correctly at the C level" ); - -my $methods = Clownfish::Class::_fresh_host_methods('MyObj'); -is_deeply( $methods->to_perl, ['oodle'], "fresh_host_methods" ); - http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8e729e10/runtime/perl/t/binding/002-clownfish.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/binding/002-clownfish.t b/runtime/perl/t/binding/002-clownfish.t new file mode 100644 index 0000000..d3e36b7 --- /dev/null +++ b/runtime/perl/t/binding/002-clownfish.t @@ -0,0 +1,52 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +use strict; +use warnings; + +use Test::More; +use File::Find 'find'; + +my @modules; + +# None for now -- until we remove a module. +my %excluded = map { ( $_ => 1 ) } qw(); + +find( + { no_chdir => 1, + wanted => sub { + return unless $File::Find::name =~ /\.pm$/; + push @modules, $File::Find::name; + } + }, + 'lib' +); + +plan( tests => scalar @modules ); + +for (@modules) { + s/^.*?Clownfish/Clownfish/; + s/\.pm$//; + s/\W+/::/g; + if ( $excluded{$_} ) { + eval qq|use $_;|; + like( $@, qr/removed|replaced|renamed/i, + "Removed module '$_' throws error on load" ); + } + else { + use_ok($_); + } +} + http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8e729e10/runtime/perl/t/binding/010-class.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/binding/010-class.t b/runtime/perl/t/binding/010-class.t new file mode 100644 index 0000000..21872ff --- /dev/null +++ b/runtime/perl/t/binding/010-class.t @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +use strict; +use warnings; + +package MyObj; +use base qw( Clownfish::Obj ); + +sub oodle { } + +package main; + +use Test::More tests => 5; + +my $stringified; +my $storage = Clownfish::Hash->new; + +{ + my $subclassed_obj = MyObj->new; + $stringified = $subclassed_obj->to_string; + + isa_ok( $subclassed_obj, "MyObj", "Perl isa reports correct subclass" ); + + # Store the subclassed object. At the end of this block, the Perl object + # will go out of scope and DESTROY will be called, but the Clownfish object + # will persist. + $storage->store( "test", $subclassed_obj ); +} + +my $resurrected = $storage->fetch("test"); + +isa_ok( $resurrected, "MyObj", "subclass name survived Perl destruction" ); +is( $resurrected->to_string, $stringified, + "It's the same Hash from earlier (though a different Perl object)" ); + +is( $resurrected->get_class_name, + "MyObj", "subclassed object still performs correctly at the C level" ); + +my $methods = Clownfish::Class::_fresh_host_methods('MyObj'); +is_deeply( $methods->to_perl, ['oodle'], "fresh_host_methods" ); + http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/8e729e10/runtime/perl/t/binding/018-host.t ---------------------------------------------------------------------- diff --git a/runtime/perl/t/binding/018-host.t b/runtime/perl/t/binding/018-host.t new file mode 100644 index 0000000..dc546fd --- /dev/null +++ b/runtime/perl/t/binding/018-host.t @@ -0,0 +1,42 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +use strict; +use warnings; + +use Test::More tests => 3; +use Clownfish qw( to_clownfish ); + +my %complex_data_structure = ( + a => [ 1, 2, 3, { ooga => 'booga' } ], + b => { foo => 'foofoo', bar => 'barbar' }, +); +my $kobj = to_clownfish( \%complex_data_structure ); +isa_ok( $kobj, 'Clownfish::Obj' ); +my $transformed = $kobj->to_perl; +is_deeply( $transformed, \%complex_data_structure, + "transform from Perl to Clownfish data structures and back" ); + +my $bread_and_butter = Clownfish::Hash->new; +$bread_and_butter->store( 'bread', Clownfish::Blob->new('butter') ); +my $salt_and_pepper = Clownfish::Hash->new; +$salt_and_pepper->store( 'salt', Clownfish::ByteBuf->new('pepper') ); +$complex_data_structure{c} = $bread_and_butter; +$complex_data_structure{d} = $salt_and_pepper; +$transformed = to_clownfish( \%complex_data_structure )->to_perl; +$complex_data_structure{c} = { bread => 'butter' }; +$complex_data_structure{d} = { salt => 'pepper' }; +is_deeply( $transformed, \%complex_data_structure, + "handle mixed data structure correctly" );
