r16033 - in /branches/upstream/libdata-javascript-perl: ./ current/ current/t/
jaldhar at users.alioth.debian.org
jaldhar at users.alioth.debian.org
Sat Mar 1 19:29:24 UTC 2008
Author: jaldhar
Date: Sat Mar 1 19:29:23 2008
New Revision: 16033
URL: http://svn.debian.org/wsvn/?sc=1&rev=16033
Log:
[svn-inject] Installing original source of libdata-javascript-perl
Added:
branches/upstream/libdata-javascript-perl/
branches/upstream/libdata-javascript-perl/current/
branches/upstream/libdata-javascript-perl/current/CHANGES
branches/upstream/libdata-javascript-perl/current/JavaScript.pm
branches/upstream/libdata-javascript-perl/current/MANIFEST
branches/upstream/libdata-javascript-perl/current/Makefile.PL
branches/upstream/libdata-javascript-perl/current/README
branches/upstream/libdata-javascript-perl/current/TODO
branches/upstream/libdata-javascript-perl/current/example.pl
branches/upstream/libdata-javascript-perl/current/t/
branches/upstream/libdata-javascript-perl/current/t/1.t
branches/upstream/libdata-javascript-perl/current/t/2.t
branches/upstream/libdata-javascript-perl/current/t/3.t
branches/upstream/libdata-javascript-perl/current/t/4.t
branches/upstream/libdata-javascript-perl/current/t/5.t
Added: branches/upstream/libdata-javascript-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/CHANGES?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/CHANGES (added)
+++ branches/upstream/libdata-javascript-perl/current/CHANGES Sat Mar 1 19:29:23 2008
@@ -1,0 +1,58 @@
+Revision history for Perl extension Data::JavaScript.
+
+1.11 Tue Nov 15 14:30:22 EST 2005
+ - Touched up documentation
+ - Fixed syntax errors for hash key names that are also JS keywords
+ Reported by Kevin J. of Activestate
+ - Hash keys are now dumped in alphabetical order, this makes code
+ easier to debug (as suggested by Scott Wessels) and is necessary
+ for thorough testing.
+ - Special characters tab, newline, carriage return, ", and \ are
+ now escaped in place instead of as hex: \t, \n, \r, \", \\
+
+1.10 Sun Nov 13 03:50 EST 2005
+ - Touched up documentation
+ - Explicitly requires Perl 5
+ - Previously undocumented, "private", quotemeta is now __quotemeta
+ though you may still import and use it
+ - Defaults to JavaScript1.3 compatible code with Unicode and undefined
+ support, specifc JS=>1.2 on the use line for backwards compatbility.
+ - Removed unnecessary evaluation of numeric elements, this fixes octal
+ interpretation of zipcodes, etc. Still, zipcodes such as 02137 would
+ be *correctly* evaluated by the client as 1119. However, in keeping
+ with the principle of least surprise any purely numeric string with
+ a leading zero will be treated as a string and quoted. If you really
+ meant to send a literal octal value, you can always eval the var
+ Similarly, engineering and hex notations are passed through to
+ strings as well.
+
+ Thanks for reports from Javier Arturo Rodriguez, Marius Feraru,
+ Joseph Annino, Alan Fairless, Kevin J.
+ - quotemeta has been completely rewritten with support for Unicode
+
+ Thanks for reports from Slaven Rezic, Marius Feraru, Sean Burke
+
+1.08 Thu Feb 13 09:04:27 EST 2003
+ - Touched up the documentation
+
+1.07 Sat Feb 8 12:40:16 EST 2003
+ - Added means to control how undef is dumped, suggested by Slaven Rezic
+ In doing so I have removed the undocumented feature that a list
+ was silently transformed into a list reference.
+ - Touched up the documentation
+
+****
+
+Ariel Brosh passed away a few months ago. I volunteered to maintain this
+module as it was the inspiration for my own Data::JavaScript::LiteObject
+
+http://use.perl.org/article.pl?sid=03/01/12/226258&mode=nested
+
+****
+
+1.04 Thu Jul 19 2001
+ - Fixed quoting back, thanks to Garick Hamlin
+
+1.00 Mon Jun 12 21:03:29 2000
+ - original version; created by h2xs 1.19
+
Added: branches/upstream/libdata-javascript-perl/current/JavaScript.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/JavaScript.pm?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/JavaScript.pm (added)
+++ branches/upstream/libdata-javascript-perl/current/JavaScript.pm Sat Mar 1 19:29:23 2008
@@ -1,0 +1,229 @@
+package Data::JavaScript;
+require 5;
+use vars qw(@EXPORT @EXPORT_OK @ISA %OPT $VERSION);
+%OPT = (JS=>1.3);
+$VERSION = 1.11;
+
+use Exporter;
+ at EXPORT = qw(jsdump hjsdump);
+ at EXPORT_OK = '__quotemeta';
+ at ISA = qw(Exporter);
+
+use strict;
+require Encode unless $] < 5.007;
+
+sub import{
+ foreach( @_ ){
+ if(ref($_) eq 'HASH'){
+ foreach my $opt ( 'UNDEF', 'JS' ){
+ if(exists($_->{$opt})){
+ $OPT{$opt} = $_->{$opt};
+ }
+ }
+ }
+ }
+ $OPT{UNDEF} = exists($OPT{UNDEF}) || $OPT{JS} > 1.2 ? 'undefined' : q('');
+ Data::JavaScript->export_to_level(1, grep {!ref($_)} @_);
+}
+
+#XXX version, ECMAscript even. Charset!
+sub hjsdump {
+ my @res = (qq(<script type="text/javascript" language="JavaScript$OPT{JS}" />),
+ '<!--', &jsdump(@_), '// -->', '</script>');
+ wantarray ? @res : join("\n", @res, "");
+}
+
+sub jsdump {
+ my $sym = shift;
+ return "var $sym;\n" unless (@_);
+ my $elem = shift;
+ my $undef = shift;
+ my %dict;
+ my @res = __jsdump($sym, $elem, \%dict, $undef);
+ $res[0] = "var " . $res[0];
+ wantarray ? @res : join("\n", @res, "");
+}
+
+if( $] < 5.007 ){
+ eval <<'EO5';
+sub __quotemeta {
+ local $_ = shift;
+
+ s<([^ \x21-\x5B\x5D-\x7E]+)>{sprintf(join('', '\x%02X' x length$1), unpack'C*',$1)}ge;
+
+ #This is kind of ugly/inconsistent output for munged UTF-8
+ s/\\x09/\\t/g;
+ s/\\x0A/\\n/g;
+ s/\\x0D/\\r/g;
+ s/"/\\"/g;
+ s/\\x5C/\\\\/g;
+
+ return $_;
+}
+EO5
+}
+ else{
+ eval<<'EO58';
+sub __quotemeta {
+ local $_ = shift;
+ if( $OPT{JS} >= 1.3 && Encode::is_utf8($_) ){
+ s<([\x{0080}-\x{fffd}]+)>{sprintf '\u%0*v4X', '\u', $1}ge;
+ }
+
+ {
+ use bytes;
+ s<((?:[^ \x21-\x7E]|(?:\\(?!u)))+)>{sprintf '\x%0*v2X', '\x', $1}ge;
+ }
+
+ s/\\x09/\\t/g;
+ s/\\x0A/\\n/g;
+ s/\\x0D/\\r/g;
+ s/"/\\"/g;
+ s/\\x5C/\\\\/g;
+
+ return $_;
+}
+EO58
+}
+
+sub __jsdump {
+ my ($sym, $elem, $dict, $undef) = @_;
+
+ unless (ref($elem)) {
+ unless( defined($elem) ){
+ return "$sym = @{[defined($undef) ? $undef : $OPT{UNDEF}]};";
+ }
+
+ #Translated from $Regexp::Common::RE{num}{real}
+ if( $elem =~ /^[+-]?(?:(?=\d|\.)\d*(?:\.\d{0,})?)$/ ){
+# (?:[eE][+-]?\d+)?
+ return qq($sym = "$elem";) if $elem =~ /^0\d+$/;
+ return "$sym = $elem;";
+ }
+
+ #Fall-back to quoted string
+ return qq($sym = ") . __quotemeta($elem) . '";';
+ }
+
+ #Circular references
+ if ($dict->{$elem}) {
+ return "$sym = " . $dict->{$elem} . ";";
+ }
+ $dict->{$elem} = $sym;
+
+ if (UNIVERSAL::isa($elem, 'ARRAY')) {
+ my @list = ("$sym = new Array;");
+ my $n = 0;
+ foreach (@$elem) {
+ my $newsym = "$sym\[$n]";
+ push(@list, __jsdump($newsym, $_, $dict, $undef));
+ $n++;
+ }
+ return @list;
+ }
+
+ if (UNIVERSAL::isa($elem, 'HASH')) {
+ my @list = ("$sym = new Object;");
+ my ($k, $old_k, $v);
+ foreach $k (sort keys %$elem) {
+ $k = __quotemeta($old_k=$k);
+ my $newsym = qq($sym\["$k"]);
+ push(@list, __jsdump($newsym, $elem->{$old_k}, $dict, $undef));
+ }
+ return @list;
+ }
+}
+
+
+1;
+__END__
+
+=head1 NAME
+
+Data::JavaScript - Dump perl data structures into JavaScript code
+
+=head1 SYNOPSIS
+
+ use Data::JavaScript; # Use defaults
+
+ @code = jsdump('my_array', $array_ref); # Return array for formatting
+ $code = jsdump('my_object', $hash_ref); # Return convenient string
+ $html = hjsdump('my_stuff', $reference); # Convenience wrapper
+
+=head1 DESCRIPTION
+
+This module is mainly inteded for CGI programming, when a perl script
+generates a page with client side JavaScript code that needs access to
+structures created on the server.
+
+It works by creating one line of JavaScript code per datum. Therefore,
+structures cannot be created anonymously and need to be assigned to
+variables. However, this format enables dumping large structures.
+
+The module can output code for different versions of JavaScript.
+It currently supports 1.1, 1.3 and you specify the version on the
+C<use> line like so:
+
+ use Data::JavaScript {JS=>1.3}; # The new default
+ use Data::JavaScript {JS=>1.1}; # Old (pre module v1.10) format
+
+JavaScript 1.3 contains support for UTF-8 and a native C<undefined> datatype.
+Earlier versions support neither, and will default to an empty string C<''>
+for undefined values. You may define your own default--for either version--at
+compile time by supplying the default value on the C<use> line:
+
+ use Data::JavaScript {JS=>1.1, UNDEF=>'null'};
+
+Other useful values might be C<0>, C<null>, or C<NaN>.
+
+=over
+
+=item jsdump('name', \$reference, [$undef]);
+
+The first argument is required, the name of JavaScript object to create.
+
+The second argument is required, a hashref or arrayref.
+Structures can be nested, circular referrencing is supported (experimentally).
+
+The third argument is optional, a scalar whose value is to be used en lieu
+of undefined values when dumping a structure.
+
+When called in list context, the function returns a list of lines.
+In scalar context, it returns a string.
+
+=item hjsdump('name', \$reference, [$undef]);
+
+hjsdump is identical to jsdump except that it wraps the content in script tags.
+
+=item __quotemeta($str)
+
+Not exported by default, this function escapes non-printable and Unicode
+characters to promote playing nice with others.
+
+=back
+
+=head1 CAVEATS
+
+Previously, the module eval'd any data it received that looked like a number;
+read: real, hexadecimal, octal, or engineering notations. It now passes all
+non-decimal values through as strings. You will need to C<eval> on the client
+or server side if you wish to use other notations as numbers.
+
+Unicode support requires perl 5.8 or later. Older perls will gleefully escape
+the non-printable portions of any UTF-8 they are fed, likely munging it in
+the process as far as JavaScript is concerned. If this turns out to be a
+problem and there is sufficient interest it may be possible to hack-in UTF-8
+escaping for older perls.
+
+=head1 SEE ALSO
+
+L<Data::JavaScript::LiteObject>, L<Data::JavaScript::Anon>, L<CGI::AJAX>
+
+=head1 AUTHOR
+
+Maintained by Jerrad Pierce <jpierce at cpan.org>
+
+Created by Ariel Brosh <schop cpan.org>.
+Inspired by WDDX.pm JavaScript support.
+
+=cut
Added: branches/upstream/libdata-javascript-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/MANIFEST?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/MANIFEST (added)
+++ branches/upstream/libdata-javascript-perl/current/MANIFEST Sat Mar 1 19:29:23 2008
@@ -1,0 +1,12 @@
+CHANGES
+MANIFEST
+README
+TODO
+JavaScript.pm
+Makefile.PL
+t/1.t
+t/2.t
+t/3.t
+t/4.t
+t/5.t
+example.pl
Added: branches/upstream/libdata-javascript-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/Makefile.PL?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/Makefile.PL (added)
+++ branches/upstream/libdata-javascript-perl/current/Makefile.PL Sat Mar 1 19:29:23 2008
@@ -1,0 +1,7 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'Data::JavaScript',
+ 'VERSION_FROM' => 'JavaScript.pm', # finds $VERSION
+ );
Added: branches/upstream/libdata-javascript-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/README?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/README (added)
+++ branches/upstream/libdata-javascript-perl/current/README Sat Mar 1 19:29:23 2008
@@ -1,0 +1,67 @@
+Dump perl structures to JavaScript code.
+
+example.pl:
+
+use Data::JavaScript;
+
+$hash = {'string' => 'Joseph',
+ 'array' => [qw(0 1 2 3 4 5 6 7 8 9 a b c d e f)],
+ 'capitals' => {'Sverige' => 'Stockholm',
+ 'Norge' => 'Oslo',
+ 'Danmark' => 'Koebenhavn'},
+ 'and' => [[0, 0], [0, 1]],
+ 'or' => [[0, 1], [1, 1]],
+ 'xor' => [[0, 1], [1, 0]]};
+$hash->{'ref'} = $hash;
+
+print scalar(jsdump("facts", $hash, 31.4e-1));
+
+Output:
+
+var facts = new Array;
+facts[0] = new Object;
+facts[0].xor = new Array;
+facts[0].xor[0] = new Array;
+facts[0].xor[0][0] = 0;
+facts[0].xor[0][1] = 1;
+facts[0].xor[1] = new Array;
+facts[0].xor[1][0] = 1;
+facts[0].xor[1][1] = 0;
+facts[0].or = new Array;
+facts[0].or[0] = new Array;
+facts[0].or[0][0] = 0;
+facts[0].or[0][1] = 1;
+facts[0].or[1] = new Array;
+facts[0].or[1][0] = 1;
+facts[0].or[1][1] = 1;
+facts[0].capitals = new Object;
+facts[0].capitals.Norge = 'Oslo';
+facts[0].capitals.Sverige = 'Stockholm';
+facts[0].capitals.Danmark = 'Koebenhavn';
+facts[0].and = new Array;
+facts[0].and[0] = new Array;
+facts[0].and[0][0] = 0;
+facts[0].and[0][1] = 0;
+facts[0].and[1] = new Array;
+facts[0].and[1][0] = 0;
+facts[0].and[1][1] = 1;
+facts[0].ref = facts[0];
+facts[0].array = new Array;
+facts[0].array[0] = 0;
+facts[0].array[1] = 1;
+facts[0].array[2] = 2;
+facts[0].array[3] = 3;
+facts[0].array[4] = 4;
+facts[0].array[5] = 5;
+facts[0].array[6] = 6;
+facts[0].array[7] = 7;
+facts[0].array[8] = 8;
+facts[0].array[9] = 9;
+facts[0].array[10] = 'a';
+facts[0].array[11] = 'b';
+facts[0].array[12] = 'c';
+facts[0].array[13] = 'd';
+facts[0].array[14] = 'e';
+facts[0].array[15] = 'f';
+facts[0].string = 'Joseph';
+facts[1] = 3.14;
Added: branches/upstream/libdata-javascript-perl/current/TODO
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/TODO?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/TODO (added)
+++ branches/upstream/libdata-javascript-perl/current/TODO Sat Mar 1 19:29:23 2008
@@ -1,0 +1,46 @@
+ECMAScript and charset support for hjsdump
+ Encoding, escape [^[:print:]]
+
+Numbers
+ Infinity
+
+ NaN
+
+ const
+
+Lightweight (object initializer) output for 1.2+
+ JavaScript 1.2 and later support a compact object notation known
+ as object literals. Instead of the verbose...
+
+ HASH = {key:val}
+ ARRAY= [0, 1, 2]
+
+ See nuclear wessels, wait for Anon/Lite merger because it requires
+ inline dumping
+
+More robust var naming (get & use perl names?)
+
+Unify:
+ How to scan & determine which format is best?
+ constructor, flat, literal, class/prototype
+
+ Data::JavaScript
+ Data::JavaScript::LiteObject
+ allow objects to be stuffed into an array and use the key names
+ as var names? to what end, would have to know var names
+
+ Data::JavaScript::Anon (Perl : anonymous :: JS : literal)
+ jsdump takes undef as name
+
+ worries too much about valid numbers but not strings,
+ validation belongs elsewhere
+
+ Template::Plugin::JavaScript
+ __quotemeta
+
+ JSON
+ why oh why
+ is it a top-level name?
+ didn't he look around first?
+
+ XML feed, Atom feed?
Added: branches/upstream/libdata-javascript-perl/current/example.pl
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/example.pl?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/example.pl (added)
+++ branches/upstream/libdata-javascript-perl/current/example.pl Sat Mar 1 19:29:23 2008
@@ -1,0 +1,14 @@
+use Data::JavaScript;
+
+$hash = {'string' => 'Joseph',
+ 'array' => [qw(0 1 2 3 4 5 6 7 8 9 a b c d e f)],
+ 'capitals' => {'Sverige' => 'Stockholm',
+ 'Norge' => 'Oslo',
+ 'Danmark' => 'Koebenhavn'},
+ 'and' => [[0, 0], [0, 1]],
+ 'or' => [[0, 1], [1, 1]],
+ 'xor' => [[0, 1], [1, 0]]};
+$hash->{'ref'} = $hash;
+
+print scalar(jsdump("facts", $hash, 31.4e-1));
+
Added: branches/upstream/libdata-javascript-perl/current/t/1.t
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/t/1.t?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/t/1.t (added)
+++ branches/upstream/libdata-javascript-perl/current/t/1.t Sat Mar 1 19:29:23 2008
@@ -1,0 +1,6 @@
+BEGIN { $| = 1; print "1..1\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Data::JavaScript;
+$loaded = 1;
+print "ok 1 #Loads fine\n";
+
Added: branches/upstream/libdata-javascript-perl/current/t/2.t
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/t/2.t?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/t/2.t (added)
+++ branches/upstream/libdata-javascript-perl/current/t/2.t Sat Mar 1 19:29:23 2008
@@ -1,0 +1,20 @@
+BEGIN { $| = 1; print "1..3\n"; }
+use Data::JavaScript {UNDEF=>0};
+
+#Test undef value overloading
+
+$_ = join('', jsdump('foo', [1,undef,1]));
+print 'not ' unless $_ eq
+ 'var foo = new Array;foo[0] = 1;foo[1] = undefined;foo[2] = 1;';
+print "ok 1 #$_\n";
+
+$_ = join('', jsdump('bar', [1,undef,1], 'null'));
+print 'not ' unless $_ eq
+ 'var bar = new Array;bar[0] = 1;bar[1] = null;bar[2] = 1;';
+print "ok 2 #$_\n";
+
+#Test hashes
+$_ = join('', jsdump('qux', {color=>'monkey', age=>2, eyes=>'blue'}));
+print 'not ' unless $_ eq
+ 'var qux = new Object;qux["age"] = 2;qux["color"] = "monkey";qux["eyes"] = "blue";';
+print "ok 3 #$_\n";
Added: branches/upstream/libdata-javascript-perl/current/t/3.t
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/t/3.t?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/t/3.t (added)
+++ branches/upstream/libdata-javascript-perl/current/t/3.t Sat Mar 1 19:29:23 2008
@@ -1,0 +1,25 @@
+BEGIN { $| = 1; $] < 5.007 ?
+ do{ print "1..0 # Skipped: No real Unicode\n"; exit} : print "1..4\n"; }
+use Data::JavaScript;
+
+#Test undef default
+
+$_ = join('', jsdump('foo', [1,undef,1]));
+print 'not ' unless $_ eq
+ 'var foo = new Array;foo[0] = 1;foo[1] = undefined;foo[2] = 1;';
+print "ok 1 #$_\n";
+
+#Test alphanumeric string output: quoting, ASCII/ANSI escaping, Unicode
+
+$_ = join('', jsdump("ANSI", "M\xF6tley Cr\xFce"));
+print 'not ' unless $_ eq 'var ANSI = "M\xF6tley Cr\xFCe";';
+print "ok 2 #$_\n";
+
+$_ = join('', jsdump("unicode", "Euros (\x{20ac}) aren't Ecus (\x{20a0})"));
+print 'not ' unless $_ eq
+ q(var unicode = "Euros (\u20AC) aren't Ecus (\u20A0)";);
+print "ok 3 #$_\n";
+
+$_ = join('', jsdump("Cherokee", "\x{13E3}\x{13E3}\x{13E3}"));
+print 'not ' unless $_ eq q(var Cherokee = "\u13E3\u13E3\u13E3";);
+print "ok 5 #$_\n";
Added: branches/upstream/libdata-javascript-perl/current/t/4.t
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/t/4.t?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/t/4.t (added)
+++ branches/upstream/libdata-javascript-perl/current/t/4.t Sat Mar 1 19:29:23 2008
@@ -1,0 +1,30 @@
+#Lame switch because old Test::Harness does not support trailing test count
+BEGIN { $| = 1; print "1..4\n" }
+use Data::JavaScript {JS=>1.2}; #No Unicode, undef yields empty strings
+
+#Test undef default
+
+$_ = join('', jsdump('foo', [1,undef,1]));
+print 'not ' unless $_ eq
+ "var foo = new Array;foo[0] = 1;foo[1] = '';foo[2] = 1;";
+print "ok 1 #$_\n";
+
+#Test alphanumeric string output: quoting, ASCII/ANSI escaping, Unicode
+
+$_ = join('', jsdump("ANSI", "M\xF6tley Cr\xFce"));
+print 'not ' unless $_ eq 'var ANSI = "M\xF6tley Cr\xFCe";';
+print "ok 2 #$_\n";
+
+if( $] >= 5.006 ){
+ $_ = join('', jsdump("unicode", "Euros (\x{20ac}) aren't Ecus (\x{20a0})"));
+ print 'not ' unless $_ eq
+ q(var unicode = "Euros (\xE2\x82\xAC) aren't Ecus (\xE2\x82\xA0)";);
+ print "ok 3 #$_\n";
+}
+else{
+ print "ok 3 # Skipped: No real Unicode\n";
+}
+
+$_ = join('', jsdump('thang', qq(' "\n\\\xa0) ));
+print 'not ' unless $_ eq q(var thang = "'\t\"\n\\\\\xA0";);
+print "ok 4 #$_\n";
Added: branches/upstream/libdata-javascript-perl/current/t/5.t
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-javascript-perl/current/t/5.t?rev=16033&op=file
==============================================================================
--- branches/upstream/libdata-javascript-perl/current/t/5.t (added)
+++ branches/upstream/libdata-javascript-perl/current/t/5.t Sat Mar 1 19:29:23 2008
@@ -1,0 +1,25 @@
+BEGIN { $| = 1; print "1..5\n"; }
+
+use Data::JavaScript;
+
+#Test numbers: negative, real, engineering, octal/zipcode
+
+$_ = join('', jsdump('ixi', -1));
+print 'not ' unless $_ eq 'var ixi = -1;';
+print "ok 1 #$_\n";
+
+$_ = join('', jsdump('pi', 3.14159));
+print 'not ' unless $_ eq 'var pi = 3.14159;';
+print "ok 2 #$_\n";
+
+$_ = join('', jsdump('c', '3E8'));
+print 'not ' unless $_ eq 'var c = "3E8";';
+print "ok 3 #$_\n";
+
+$_ = join('', jsdump('zipcode', '02139'));
+print 'not ' unless $_ eq 'var zipcode = "02139";';
+print "ok 4 #$_\n";
+
+$_ = join('', jsdump('hex', '0xdeadbeef'));
+print 'not ' unless $_ eq 'var hex = "0xdeadbeef";';
+print "ok 5 #$_\n";
More information about the Pkg-perl-cvs-commits
mailing list