From: Michael G. Schwern Date: Fri, 29 Aug 2003 22:55:07 +0000 (-0700) Subject: XSLoader nits and tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9e8c31cc7f224d58a5cb5107b5900855526a273c;p=p5sagit%2Fp5-mst-13.2.git XSLoader nits and tests Message-ID: <20030830055507.GI25970@windhund.schwern.org> p4raw-id: //depot/perl@20944 --- diff --git a/MANIFEST b/MANIFEST index c75aa5e..0103366 100644 --- a/MANIFEST +++ b/MANIFEST @@ -214,6 +214,7 @@ ext/DynaLoader/hints/netbsd.pl Hint for DynaLoader for named architecture ext/DynaLoader/hints/openbsd.pl Hint for DynaLoader for named architecture ext/DynaLoader/Makefile.PL Dynamic Loader makefile writer ext/DynaLoader/README Dynamic Loader notes and intro +ext/DynaLoader/t/XSLoader.t See if XSLoader works ext/DynaLoader/XSLoader_pm.PL Simple XS Loader perl module ext/Encode/AUTHORS List of authors ext/Encode/bin/enc2xs Encode module generator diff --git a/ext/DynaLoader/XSLoader_pm.PL b/ext/DynaLoader/XSLoader_pm.PL index 9f3aaed..26e67c8 100644 --- a/ext/DynaLoader/XSLoader_pm.PL +++ b/ext/DynaLoader/XSLoader_pm.PL @@ -14,19 +14,7 @@ print OUT <<'EOT'; package XSLoader; -# And Gandalf said: 'Many folk like to know beforehand what is to -# be set on the table; but those who have laboured to prepare the -# feast like to keep their secret; for wonder makes the words of -# praise louder.' - -# (Quote from Tolkien sugested by Anno Siegel.) -# -# See pod text at end of file for documentation. -# See also ext/DynaLoader/README in source tree for other information. -# -# Tim.Bunce@ig.co.uk, August 1994 - -$VERSION = "0.01"; # avoid typo warning +$VERSION = "0.02"; # enable debug/trace messages from DynaLoader perl code # $dl_debug = $ENV{PERL_DL_DEBUG} || 0 unless defined $dl_debug; @@ -45,14 +33,11 @@ boot_DynaLoader('DynaLoader') if defined(&boot_DynaLoader) && !defined(&dl_error); package XSLoader; -1; # End of main code - -# The bootstrap function cannot be autoloaded (without complications) -# so we define it here: - sub load { package DynaLoader; + die q{XSLoader::load('Your::Module', $Your::Module::VERSION)} unless @_; + my($module) = $_[0]; # work with static linking too @@ -137,6 +122,8 @@ print OUT <<'EOT'; goto &DynaLoader::bootstrap_inherit; } +1; + __END__ =head1 NAME @@ -148,7 +135,7 @@ XSLoader - Dynamically load C libraries into Perl code package YourPackage; use XSLoader; - XSLoader::load 'YourPackage', @args; + XSLoader::load 'YourPackage', $YourPackage::VERSION; =head1 DESCRIPTION diff --git a/ext/DynaLoader/t/XSLoader.t b/ext/DynaLoader/t/XSLoader.t new file mode 100644 index 0000000..1654a2e --- /dev/null +++ b/ext/DynaLoader/t/XSLoader.t @@ -0,0 +1,20 @@ +#!/usr/bin/perl -w + +BEGIN { + chdir 't'; +# @INC = '../lib'; +} + +use Test; +plan tests => 4; + +use XSLoader; +ok(1); +ok( ref XSLoader->can('load') ); + +eval { XSLoader::load(); }; +ok( $@ =~ /^XSLoader::load\('Your::Module', \$Your::Module::VERSION\)/ ); + +package SDBM_File; +XSLoader::load('SDBM_File'); +::ok( ref SDBM_File->can('TIEHASH') );