summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2003-08-29 15:55:07 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2003-08-30 05:50:41 +0000
commit9e8c31cc7f224d58a5cb5107b5900855526a273c (patch)
treedb62fe953e66600c6f5cf2e9ef4958d061f12c3e /ext
parentd84c672d23e941bae9d05e88fa42ae466c892856 (diff)
downloadperl-9e8c31cc7f224d58a5cb5107b5900855526a273c.tar.gz
XSLoader nits and tests
Message-ID: <20030830055507.GI25970@windhund.schwern.org> p4raw-id: //depot/perl@20944
Diffstat (limited to 'ext')
-rw-r--r--ext/DynaLoader/XSLoader_pm.PL25
-rw-r--r--ext/DynaLoader/t/XSLoader.t20
2 files changed, 26 insertions, 19 deletions
diff --git a/ext/DynaLoader/XSLoader_pm.PL b/ext/DynaLoader/XSLoader_pm.PL
index 9f3aaed83c..26e67c8347 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 0000000000..1654a2ec03
--- /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') );