#! /usr/bin/perl -Tw use strict; use warnings; use Test::More tests => 9; { package Foo; use Class::OOorNO qw(myself OOorNO myargs coerce_array); sub get_myself { return myself(@_) }; sub get_OOorNO { return OOorNO(@_) }; sub get_myargs { return myargs(@_) }; }; # These three tests work as expected... is Foo::get_myself(Bar=>1), undef, 'myself: not called as method'; ok(! Foo::get_OOorNO(Bar => 1), 'OOorNO: not called as method'); is_deeply [ Foo::get_myargs( Bar => 1 ) ], [Bar => 1], 'myargs: leaves non-method call args alone'; # But these fail because your tests think they're being called # as a class method is Foo::get_myself(Foo=>1), undef, 'myself: not called as method'; ok(! Foo::get_OOorNO(Foo => 1), 'OOorNO: not called as method'); is_deeply [ Foo::get_myargs( Foo => 1 ) ], [Bar => 1], 'myargs: leaves non-method call args alone'; # Even worse, once we load another class eval q< { package Bar; use base qw(Foo); }; >; # the original test fail too - evil side effects. is Foo::get_myself(Bar=>1), undef, 'myself: not called as method'; ok(! Foo::get_OOorNO(Bar => 1), 'OOorNO: not called as method'); is_deeply [ Foo::get_myargs( Bar => 1 ) ], [Bar => 1], 'myargs: leaves non-method call args alone';