Config-INI

 view release on metacpan or  search on metacpan

t/reader-err.t  view on Meta::CPAN

SKIP: {
  eval "require File::Temp;" or skip "File::Temp not available", 1;

  # This could probably be limited to being required for Cygwin.
  eval "require filetest;"   or skip "filetest.pm not available", 1;
  filetest->import('access');

  my ($fh, $fn) = File::Temp::tempfile('tempXXXXX', UNLINK => 1);
  close $fh;

  chmod 0222, $fn;

  if (-r $fn) {
    chmod 0666, $fh;
    skip "chmoding file 0222 left it -r", 1;
  }

  eval { Config::INI::Reader->read_file($fn); };
  like($@, qr/not readable/, "can't read an unreadable file");

  chmod 0666, $fh;
}

eval { Config::INI::Reader->read_string; };
like($@, qr/no string provided/i, 'read_string without args');

{
  my $input = 'foo bar moo';
  eval { Config::INI::Reader->read_string($input); };
  like($@, qr/Syntax error at line 1: '$input'/i, 'syntax error');
}

t/writer.t  view on Meta::CPAN


  my $new_data = { foo => { a => 1, b => 69101 } };
  $W->write_file($new_data, $fn);

  is_deeply(
    $R->read_file($fn),
    $new_data,
    "round-trip data->file->data, clobbering file",
  );

  chmod 0444, $fn;

  if (-w $fn) {
    chmod 0666, $fh;
    skip "chmoding file 0444 left it -w", 1;
  }

  eval { Config::INI::Writer->write_file($data, $fn); };
  like($@, qr/couldn't write/, "can't clobber an unwriteable file");

  chmod 0666, $fh;
}

eval { $W->write_file($data); };
like($@, qr/no filename/, "you can't set write to a file without a filename");

eval { $W->write_file($data, 't'); };
like($@, qr/not a plain file/, "you can't write to a file that's -e -d");

eval { $W->write_string(sub { 1 }) };
like($@, qr/can't output CODE/, "you can't write out non-ARRAY/HASH data");



( run in 0.668 second using v1.01-cache-2.11-cpan-496ff517765 )