recount a little about the first findings
[acme-study-perl.git] / lib / Acme / Study / Perl.pm
blobcf6ab9ac1901b99ddd54ff7dcdcaced0d4389568
1 package Acme::Study::Perl;
3 use warnings;
4 use strict;
5 require Data::Dumper;
6 use Test::Builder;
7 use Exporter;
8 use base 'Exporter';
9 our @EXPORT_OK = qw(studyperl);
11 =encoding utf-8
13 =head1 NAME
15 Acme::Study::Perl - empirical studies about how perl behaves
17 =cut
19 use version; our $VERSION = qv('0.0.2');
21 =head1 SYNOPSIS
23 use Acme::Study::Perl qw(studyperl);
24 studyperl("your expression goes here", "optional comment");
26 =head1 DESCRIPTION
28 This module provides nothing that you cannot do yourself. Its focus
29 is the test suite. If cpantesters deliver what they promise, this
30 module's test suite can be used to study the behaviour of perl on
31 multiple platforms.
33 The single function C<studyperl> only does some trivial formatting
34 which will help deciphering the output of the testsuite.
36 =head1 EXAMPLE
38 My first descriptive table overview after I first released
39 Acme::Study::Perl was generated with the following command:
41 ctgetreports --q meta:perl -q conf:use64bitint -q conf:use64bitall --q qr:"(native big math float/int.*)" Acme-Study-Perl
43 The result showed me six perls that have a bug in their conversion of
44 strings to numbers and 28 perls that did it right. To find out more
45 about the parameters that might have an influence, I called
46 ctgetreports with --solve and --ycb (example in the ctgetreports
47 manpage).
49 The calculation provided a hint that conf:ivtype is a candidate.
50 Looking closer helped confirm the finding that all perls with ivtype
51 C<long long> have this bug. And only one architecture with ivtype
52 C<long>, namely C<alpha-netbsd>. All others either provided the
53 correct result, C<-1> because they were native 64 bit processors or
54 the expected wrong-by-rounding result C<0>.
56 =head1 EXPORT
58 =head1 FUNCTIONS
60 =head2 (void) studyperl ($expr, $comment)
62 Evals the expression and sends with the diag() command from Test::More
63 a terse Data::Dumper representation for STDERR.
65 So far we have defined four characters as hash keys per study:
67 # comment
68 < input
69 > output
70 @ error ($@)
72 We have configured Data::Dumpe to write one line and sort the keys
74 =cut
76 sub studyperl {
77 my($expr, $comment) = @_;
78 my $out = eval $expr;
79 my $err = $@;
80 my @err = $err ? ('@' => $err) : ();
81 my @comment = $comment ? ("#" => $comment) : ();
82 our $Test;
83 $Test ||= Test::Builder->new;
84 $Test->diag(Data::Dumper->new([{"<"=>$expr, ">"=>$out, @comment, @err}])
85 ->Sortkeys(1)->Indent(0)->Useqq(1)->Terse(1)->Dump);
86 return;
89 =head1 AUTHOR
91 Andreas König, C<< <andreas.koenig.7os6VVqR at franz.ak.mind.de> >>
93 =head1 BUGS
95 Please report any bugs or feature requests through the web interface
96 at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-Study-Perl>.
97 I will be notified, and then you'll automatically be notified of
98 progress on your bug as I make changes.
100 =head1 SUPPORT
102 You can find documentation for this module with the perldoc command.
104 perldoc Acme::Study::Perl
106 You can also look for information at:
108 =over 4
110 =item * RT: CPAN's request tracker
112 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Acme-Study-Perl>
114 =item * AnnoCPAN: Annotated CPAN documentation
116 L<http://annocpan.org/dist/Acme-Study-Perl>
118 =item * CPAN Ratings
120 L<http://cpanratings.perl.org/d/Acme-Study-Perl>
122 =item * Search CPAN
124 L<http://search.cpan.org/dist/Acme-Study-Perl>
126 =back
128 =head1 ACKNOWLEDGEMENTS
130 Thanks to RJBS for Module::Starter.
132 =head1 COPYRIGHT & LICENSE
134 Copyright 2008 Andreas König.
136 This program is free software; you can redistribute it and/or modify it
137 under the same terms as Perl itself.
140 =cut
142 1; # End of Acme::Study::Perl