6 use Test::More no_plan => 1;
9 use_ok('Moose::Autobox');
14 SCALAR->meta->add_method('bytes' => sub {
18 SCALAR->meta->add_method('byte' => SCALAR->meta->get_method('bytes'));
20 SCALAR->meta->add_method('kilobytes' => sub {
24 SCALAR->meta->add_method('kilobyte' => SCALAR->meta->get_method('kilobytes'));
26 SCALAR->meta->add_method('megabytes' => sub {
27 $_[0] * 1024->kilobytes;
30 SCALAR->meta->add_method('metabyte' => SCALAR->meta->get_method('megabytes'));
32 SCALAR->meta->add_method('gigabytes' => sub {
33 $_[0] * 1024->megabytes;
36 SCALAR->meta->add_method('gigabyte' => SCALAR->meta->get_method('gigabytes'));
38 SCALAR->meta->add_method('terabytes' => sub {
39 $_[0] * 1024->gigabytes;
42 SCALAR->meta->add_method('terabyte' => SCALAR->meta->get_method('terabytes'));
44 is(5->bytes, 5, '... got 5 bytes');
45 is(5->kilobytes, 5120, '... got 5 kilobytes');
46 is(2->megabytes, 2097152, '... got 2 megabytes');
47 is(1->gigabyte, 1073741824, '... got 1 gigabyte');
48 is(2->terabytes, 2199023255552, '... got 2 terabyte');