1N/A chdir 't' if -d 't'; 1N/A print "1..0 # skip: EBCDIC\n"; 1N/Ais( $d->get('globPrint'), 1, 'get an option correctly' );
1N/Ais( $d->get('globPrint', 'dumpReused'), qw( 1 1 ), 'get multiple options' );
1N/A# check to see if unctrl works 1N/A# check to see if stringify works 1N/A# the default is 1, but we want two single quotes 1N/Ais( $d->stringify(), "''", 'stringify skips undef when asked nicely' );
1N/A# check for double-quotes if there's an unprintable character 1N/A# if no unprintable character, escape ticks or backslashes 1N/Ais( $d->stringify('hi'), "'hi'", 'used single-quotes when appropriate' ); 1N/A$d->{unctrl} = 'unctrl'; 1N/A$d->{quoteHighBit} = 1; 1N/Alike( $d->stringify("b\205"), qr!^'b\\205!, 'high-bit now escaped in unctrl');
1N/Ais( $d->stringify("5@\033\$1"), '"5\@\e\$1"', 'quoted $ and @ and \033 fine' );
1N/A# add ticks, if necessary 1N/Ais( $d->stringify("no ticks", 1), 'no ticks', 'avoid ticks if asked' ); 1N/A# test DumpElem, it does its magic with veryCompact set 1N/A$d->{veryCompact} = 1; 1N/A$d->DumpElem([1, 2, 3]); 1N/Ais( $out->read, "0..2 1 2 3\n", 'DumpElem worked on array ref'); 1N/A$d->DumpElem({ one => 1, two => 2 }); 1N/Ais( $out->read, "'one' => 1, 'two' => 2\n", 'DumpElem worked on hash ref' ); 1N/Ais( $out->read, "'hi'\n", 'DumpElem worked on simple scalar' ); 1N/A$d->{veryCompact} = 0; 1N/Alike( $out->read, qr/ARRAY/, 'DumpElem okay with reference and no veryCompact'); 1N/A# should compact simple arrays just fine 1N/A$d->{veryCompact} = 1; 1N/A$d->DumpElem([1, 2, 3]); 1N/Ais( $out->read, "0..2 1 2 3\n", 'dumped array fine' ); 1N/A$d->{arrayDepth} = 2; 1N/A$d->DumpElem([1, 2, 3]); 1N/Ais( $out->read, "0..2 1 2 ...\n", 'dumped limited array fine' ); 1N/A# should compact simple hashes just fine 1N/A$d->DumpElem({ a => 1, b => 2, c => 3 }); 1N/Ais( $out->read, "'a' => 1, 'b' => 2, 'c' => 3\n", 'dumped hash fine' ); 1N/A$d->DumpElem({ a => 1, b => 2, c => 3 }); 1N/Ais( $out->read, "'a' => 1, 'b' => 2 ...\n", 'dumped limited hash fine' ); 1N/A# should just stringify what it is 1N/A$d->{veryCompact} = 0; 1N/Alike( $out->read, qr/ARRAY.+empty array/s, 'stringified empty array ref' ); 1N/Alike( $out->read, qr/HASH.+empty hash/s, 'stringified empty hash ref' ); 1N/Ais( $out->read, "1\n", 'stringified simple scalar' ); 1N/A$DB::signal = $d->{stopDbSignal} = 1; 1N/Ais( $d->unwrap(), undef, 'unwrap returns if DB signal is set' ); 1N/A$d->{dumpReused} = 0; 1N/Ais( $out->read, "-> 7\n", 'unwrap worked on scalar' ); 1N/A$d->unwrap({ one => 1 }); 1N/A# leaving this at zero may cause some subsequent tests to fail 1N/A# if they reuse an address creating an anonymous variable 1N/A$d->{dumpReused} = 1; 1N/Ais( $out->read, "'one' => 1\n", 'unwrap worked on hash' ); 1N/A$d->unwrap([ 2, 3 ]); 1N/Ais( $out->read, "0 2\n1 3\n", 'unwrap worked on array' ); 1N/Ais( $out->read, '', 'unwrap ignored glob on first try'); 1N/A$d->unwrap( sub {} ); 1N/Alike( $out->read, qr/^-> &CODE/, 'unwrap worked on sub ref' ); 1N/A# test to see if first arg 'eq' second 1N/Aok( Dumpvalue::matchvar(1, 1), 'matchvar matched numbers fine' ); 1N/Aok( Dumpvalue::matchvar('hi', 'hi'), 'matchvar matched strings fine' ); 1N/Aok( !Dumpvalue::matchvar('hello', 1), 'matchvar caught failed match fine' ); 1N/A# test compactDump, which doesn't do much 1N/Ais( $d->compactDump(3), 3, 'set compactDump to 3' ); 1N/Ais( $d->compactDump(1), 479, 'compactDump reset to 6*80-1 when less than 2' ); 1N/A# test veryCompact, which does slightly more, setting compactDump sometimes 1N/A$d->{compactDump} = 0; 1N/Ais( $d->veryCompact(1), 1, 'set veryCompact successfully' ); 1N/Aok( $d->compactDump(), 'and it set compactDump as well' ); 1N/A$d->set_unctrl('impossible value'); 1N/Alike( $out->read, qr/^Unknown value/, 'set_unctrl caught bad value' ); 1N/Ais( $d->set_unctrl('quote'), 'quote', 'set quote fine' ); 1N/Ais( $d->set_unctrl(), 'quote', 'retrieved quote fine' ); 1N/Ais( $d->{tick}, '"', 'set_quote set tick right' ); 1N/Ais( $d->{unctrl}, 'quote', 'set unctrl right too' ); 1N/A$d->set_quote('auto'); 1N/Ais( $d->{tick}, 'auto', 'set_quote set auto right' ); 1N/A$d->set_quote('foo'); 1N/A# should do nothing if debugger signal flag is raised 1N/A$d->{stopDbSignal} = $DB::signal = 1; 1N/Ais( $d->dumpglob(*DB::signal), undef, 'returned early with DB signal set' ); 1N/A# test dumping "normal" variables, this is a nasty glob trick 1N/A$d->dumpglob( '', 2, 'foo', local *foo = \$foo ); 1N/A# the key name is a little different here 1N/A$d->dumpglob( '', 0, 'boo', *bar ); 1N/Ais( $out->read, "\@boo = (\n 0..1 1 2\n)\n", 'dumped glob for @bar fine' ); 1N/A%baz = ( one => 1, two => 2 ); 1N/A$d->dumpglob( '', 0, 'baz', *baz ); 1N/Ais( $out->read, "\%baz = (\n 'one' => 1, 'two' => 2\n)\n", 1N/A 'dumped glob for %baz fine' ); 1N/A skip( "Couldn't open $0 for reading", 1 ) unless open(FILE, $0); 1N/A my $fileno = fileno(FILE); 1N/A $d->dumpglob( '', 0, 'FILE', *FILE ); 1N/A is( $out->read, "FileHandle(FILE) => fileno($fileno)\n", 1N/A$d->dumpglob( '', 0, 'read', *TieOut::read ); 1N/A$d->dumpglob( '', 0, 'read', \&TieOut::read, 1 ); 1N/A# see if it dumps DB-like values correctly 1N/A$d->{dumpDBFiles} = 1; 1N/A$d->dumpglob( '', 0, '_<foo', *foo ); 1N/Ais( $out->read, "&TieOut::read in TieOut\n", 'dumpsub found sub fine again' ); 1N/A# this should print just a usage message 1N/A# this should report @INC and %INC 1N/A# this should report nothing 1N/Ais( $out->read, '', 'no dump when $DB::signal is set' ); 1N/Ais( $d->arrayUsage( [1, 2, 3], 'a' ), 3, 'arrayUsage reports correct lengths' ); 1N/Ais( $out->read, "\@a = 3 items (data: 3 bytes)\n", 'arrayUsage message okay' ); 1N/Ais( $out->read, "\%b = 1 item (keys: 3; values: 1; total: 4 bytes)\n", 1N/A 'hashUsage message okay' ); 1N/Ais( $out->read, "\%c = 1 item (keys: 3; values: 3; total: 6 bytes)\n", 1N/A 'hashUsage complex message okay' ); 1N/A# and now, the real show 1N/Ais( $out->read, "undef\n", 'dumpValue caught undef value okay' ); 1N/Ais( $out->read, "'one'\n", 'dumpValue worked' ); 1N/Ais( $out->read, "'two'\n", 'dumpValue worked on array' ); 1N/Ais( $out->read, "-> 'one'\n", 'dumpValue worked on scalar ref' ); 1N/A# dumpValues (the rest of these should be caught by unwrap) 1N/Ais( $out->read, "undef\n", 'dumpValues caught undef value fine' ); 1N/Ais( $out->read, "0 0..0 'two'\n", 'dumpValues worked on array ref' ); 1N/Ais( $out->read, "0..1 'one' 'two'\n", 'dumpValues worked on multiple values' );