Gtk2-Ex-Clock

 view release on metacpan or  search on metacpan

t/Clock.t  view on Meta::CPAN

ok (  Gtk2::Ex::Clock->strftime_is_seconds("%6s"),   "%6s");
ok (! Gtk2::Ex::Clock->strftime_is_seconds("%6dS"),  "%6dS");
ok (  Gtk2::Ex::Clock->strftime_is_seconds("%S"),    "%S");
ok (! Gtk2::Ex::Clock->strftime_is_seconds("%H:%M"), "%H:%M");
ok (  Gtk2::Ex::Clock->strftime_is_seconds("%ES"),   "%ES");
ok (  Gtk2::Ex::Clock->strftime_is_seconds("%OS"),   "%OS");
ok (  Gtk2::Ex::Clock->strftime_is_seconds("%0S"),   "%0S");
ok (! Gtk2::Ex::Clock->strftime_is_seconds("%MS"),   "%MS");
ok (  Gtk2::Ex::Clock->strftime_is_seconds("%-12S"), "%-12S");
ok (! Gtk2::Ex::Clock->strftime_is_seconds("%%Something %H:%M"),
    "%%Something %H:%M");

# DateTime method forms
foreach my $method ('second', 'sec', 'hms', 'time', 'datetime', 'iso8601',
                    'epoch', 'utc_rd_as_seconds') {
  my $format = "blah %{$method} blah";
  ok (Gtk2::Ex::Clock->strftime_is_seconds($format), $format);
}

#-----------------------------------------------------------------------------
# timezone / timezone-string

{
  my $clock = Gtk2::Ex::Clock->new;
  is ($clock->get('timezone'), undef,
      'timezone - default undef');
  is ($clock->get('timezone-string'), undef,
      'timezone-string - default undef');
  SKIP: {
    eval{Glib->VERSION(1.240);1}
      or skip 'no Glib::ParamSpec->scalar get_default_value until glib 1.240', 1;
    my $pspec = $clock->find_property('timezone');
    is ($pspec->get_default_value, undef,
        'timezone - pspec get_default_value undef');
  }
 SKIP: {
    eval{Glib->VERSION(1.240);1}
      or skip 'no Glib::ParamSpec->string default undef until glib 1.240', 1;
    my $pspec = $clock->find_property('timezone-string');
    is ($pspec->get_default_value, undef,
        'timezone-string - pspec get_default_value undef');
  }

  $clock->set (timezone_string => 'ABC');
  is ($clock->get('timezone'), 'ABC');
  is ($clock->get('timezone-string'), 'ABC');
  is ($clock->get('timezone_string'), 'ABC');

  $clock->set('timezone-string', 'DEF');
  is ($clock->get('timezone'), 'DEF');
  is ($clock->get('timezone-string'), 'DEF');
  is ($clock->get('timezone_string'), 'DEF');

  $clock->set('timezone', 'GHI');
  is ($clock->get('timezone'), 'GHI');
  is ($clock->get('timezone-string'), 'GHI');
  is ($clock->get('timezone_string'), 'GHI');
}

#-----------------------------------------------------------------------------
# weakening

# no circular reference between the clock and the timer callback it
# installs
{
  my $clock = Gtk2::Ex::Clock->new;
  require Scalar::Util;
  Scalar::Util::weaken ($clock);
  is ($clock, undef, 'should be garbage collected when weakened');
}

exit 0;



( run in 2.438 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )