File: 3-undef.t

package info (click to toggle)
libdata-javascript-perl 1.15-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 288 kB
  • sloc: perl: 319; makefile: 5
file content (25 lines) | stat: -rw-r--r-- 645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env perl

use Modern::Perl;

use Test2::V0;

use Data::JavaScript ( ':all' => { UNDEF => 0 } );

#Test undef value overloading
is join( q//, jsdump( 'foo', [ 1, undef, 1 ] ) ),
  'var foo = new Array;foo[0] = 1;foo[1] = undefined;foo[2] = 1;',
  'Literal undefined.';

is join( q//, jsdump( 'bar', [ 1, undef, 1 ], 'null' ) ),
  'var bar = new Array;bar[0] = 1;bar[1] = null;bar[2] = 1;',
  'Literal null';

#Test hashes
is
  join( q//, jsdump( 'qux', { color => 'monkey', age => 2, eyes => 'blue' } ) ),
  'var qux = new Object;qux["age"] = 2;'
  . 'qux["color"] = "monkey";qux["eyes"] = "blue";',
  'Simple hashref';

done_testing;