Loading ...
Sorry, an error occurred while loading the content.

3Re: XPiP / bOP

Expand Messages
  • Rob Nagler
    Jan 28, 2002
    • 0 Attachment
      [I apologize in advance if you didn't want me to take these
      conversations public. -- Rob]

      Uwe Voelker writes:
      > Great! When do you expect the book to come out?

      Hopefully by June, but maybe July...

      > So far I have read "unit testing". I will read the other two in the next
      > few days.

      Thanks.

      > I have a few questions:
      > Why don't you use Test::Simple or Test::More?

      They are too verbose imo, they don't understand Bivio::DieCode. See
      the tests at the end of this note to understand better.

      > In Bivio::Test - why don't you use hashes? ('=>' but arrayref)

      array_refs are ordered and you don't lose duplicate keys.

      > What is wrong with HTML Templates? (as stated on the website, "Screen
      > COBOL")
      > Where can I read more about Model-View-Controller?

      http://www.bivio.biz/hm/why-bOP
      covers it in detail, and has a reference section.

      > Thank you. It is a pity that there are no messages :-)

      Check now. :)

      > I have read the three slides and the article about bOP. I will have a
      > look at it. Maybe the Petshops helps me to understand the whole thing.
      > For now I need to know more about MVC or I won't be able to understand bOP.

      I have another talk, but it has no notes, so it is essentially
      worthless. The petshop is an important learning tool, because you can
      easily see the code for every page.

      Rob
      ----------------------------------------------------------------
      #!perl -w
      # $Id: Integer.t,v 1.7 2001/11/24 04:30:19 nagler Exp $
      #
      use strict;
      use Bivio::Test;
      use Bivio::Type::Integer;
      use Bivio::TypeError;
      Bivio::Test->unit([
      'Bivio::Type::Integer' => [
      get_min => -999999999,
      get_max => 999999999,
      get_precision => 9,
      get_width => 10,
      get_decimals => 0,
      can_be_zero => 1,
      can_be_positive => 1,
      can_be_negative => 1,
      from_literal => [
      ['9'] => [9],
      ['+00009'] => [9],
      ['-00009'] => [-9],
      ['x'] => [undef, Bivio::TypeError->INTEGER],
      [undef] => [undef],
      [''] => [undef],
      [' '] => [undef],
      ['-99999999999999'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      ['-00000000000009'] => [-9],
      ['+00000000000009'] => [9],
      ['-999999999'] => [-999999999],
      ['+999999999'] => [999999999],
      ['+1000000000'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      ['-1000000000'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      ],
      ],
      Bivio::Type::Integer->new(1,10) => [
      get_min => 1,
      get_max => 10,
      get_precision => 2,
      get_width => 2,
      get_decimals => 0,
      can_be_zero => 0,
      can_be_positive => 1,
      can_be_negative => 0,
      from_literal => [
      ['00001'] => [1],
      ['+00001'] => [1],
      ['0'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      ['11'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      ['-00001'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      [undef] => [undef],
      ['-00000000000009'] => [undef, Bivio::TypeError->NUMBER_RANGE],
      ['+00000000000009'] => [9],
      ],
      ],
      ]);
      ----------------------------------------------------------------
      use strict;
      use Bivio::Test;
      use Bivio::Type::DateTime;
      use Bivio::Type::Date;
      use Bivio::Type::Time;
      use Bivio::Agent::Request;

      # Set the timezone to something specific
      Bivio::Agent::Request->get_current_or_new->put(timezone => 120);

      # Tests
      Bivio::Test->unit([
      'Bivio::Type::DateTime' => [
      from_literal => [
      [undef] => [undef],
      ['2378497 9'] => ['2378497 9'],
      ['-9'] => [undef, Bivio::TypeError->DATE_TIME],
      ['Feb 29 0:0:0 MST 1972'] => ['2441377 0'],
      ['Feb 29 13:13:13 XXX 2000'] => ['2451604 47593'],
      ['1972/2/29 0:0:0'] => ['2441377 0'],
      ['2000/2/29 13:13:13'] => ['2451604 47593'],
      ['Sun Dec 16 13:47:35 GMT 2001'] => ['2452260 49655'],
      ],
      from_local_literal => [
      [undef] => [undef, undef],
      ['2378497 9'] => ['2378497 7209'],
      ['-9'] => [undef, Bivio::TypeError->DATE_TIME],
      ['Feb 29 0:0:0 MST 1972'] => ['2441377 7200'],
      ['Feb 29 13:13:13 XXX 2000'] => ['2451604 54793'],
      ['1972/2/29 0:0:0'] => ['2441377 7200'],
      ['2000/2/29 13:13:13'] => ['2451604 54793'],
      ],
      to_string => [
      ['2378497 9'] => ['01/01/1800 00:00:09 GMT'],
      ['2441377 0'] => ['02/29/1972 00:00:00 GMT'],
      ['2451604 47593'] => ['02/29/2000 13:13:13 GMT'],
      ],
      to_local_string => [
      ['2378497 7209'] => ['01/01/1800 00:00:09'],
      ['2441377 7200'] => ['02/29/1972 00:00:00'],
      ['2451604 54793'] => ['02/29/2000 13:13:13'],
      ],
      to_parts => [
      [Bivio::Type::DateTime->get_min]
      => ['0', '0', '0', '1', '1', '1800'],
      [Bivio::Type::DateTime->get_max]
      => ['59', '59', '23', '31', '12', '2199'],
      ['2440588 0'] => ['0', '0', '0', '1', '1', '1970'],
      ['2441377 0'] => ['0', '0', '0', '29', '2', '1972'],
      ['2451604 47593'] => ['13', '13', '13', '29', '2', '2000'],
      ],
      add_days => [
      ['2440588 0', 1] => ['2440589 0'],
      ['2440588 0', -1] => ['2440587 0'],
      ],
      add_seconds => [
      ['2440588 0', 1] => ['2440588 1'],
      ['2440588 0', 86401] => ['2440589 1'],
      ['2440588 0', -86401] => ['2440586 86399'],
      ['2440588 0', -1] => ['2440587 86399'],
      ],
      {
      method => 'set_end_of_month',
      compute_params => sub {
      my($obj, $method, $params) = @_;
      return [$obj->from_literal_or_die($params->[0])];
      },
      result_ok => sub {
      my($obj, $method, $params, $expect, $actual) = @_;
      return $actual->[0] eq $obj->from_literal_or_die($expect->[0]);
      },
      } => [
      ['12/1/2000 0:0:0'] => ['12/31/2000 0:0:0'],
      ['2/1/2000 0:0:0'] => ['2/29/2000 0:0:0'],
      ['2/26/1900 0:0:0'] => ['2/28/1900 0:0:0'],
      ['2/26/1980 0:32:0'] => ['2/29/1980 0:32:0'],
      ],
      ],
      ]);
      ----------------------------------------------------------------
      #!perl -w
      # $Id: DateInterval.t,v 1.7 2002/01/09 03:29:48 nagler Exp $
      #
      use strict;
      use Bivio::Test;
      use Bivio::Type::DateInterval;
      use Bivio::Type::Date;
      my($_D) = 'Bivio::Type::Date';
      my($_DI) = 'Bivio::Type::DateInterval';
      Bivio::Test->new({
      compute_params => sub {
      my($object, $method, $params) = @_;
      $params->[0] = Bivio::Type::Date->from_literal_or_die(
      $params->[0]);
      return $params;
      },
      result_ok => sub {
      my($object, $method, $params, $expected, $actual) = @_;
      return Bivio::Test->default_result_ok(@_)
      if ref($expected) eq 'Bivio::DieCode';
      return $_D->from_literal_or_die($expected->[0]) eq $actual->[0];
      }
      })->unit([
      $_DI->NONE => [
      inc => [
      ['1/1/1911'] => ['1/1/1911'],
      #TODO: This is the current behavior. It probably shouldn't die.
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['1/1/1911'] => ['1/1/1911'],
      [$_D->get_min] => [$_D->get_min],
      ],
      inc_to_end => [
      ['1/1/1911'] => ['1/1/1911'],
      [$_D->get_min] => [$_D->get_min],
      ],
      ],
      $_DI->DAY => [
      inc => [
      ['1/1/1911'] => ['1/2/1911'],
      ['1/31/2000'] => ['2/1/2000'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['1/1/1911'] => ['12/31/1910'],
      ['1/31/2000'] => ['1/30/2000'],
      [$_D->get_min] => Bivio::DieCode->DIE,
      ],
      inc_to_end => [
      ['1/1/1911'] => ['1/1/1911'],
      [$_D->get_min] => [$_D->get_min],
      [$_D->get_max] => [$_D->get_max],
      ],
      ],
      $_DI->WEEK => [
      inc => [
      ['1/1/1911'] => ['1/8/1911'],
      ['12/31/2000'] => ['1/7/2001'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['1/1/1911'] => ['12/25/1910'],
      ['3/3/2000'] => ['2/25/2000'],
      [$_D->get_min] => Bivio::DieCode->DIE,
      ],
      inc_to_end => [
      ['1/1/1911'] => ['1/7/1911'],
      ['12/31/2000'] => ['1/6/2001'],
      ],
      ],
      $_DI->BEGINNING_OF_YEAR => [
      inc => [
      ['5/5/1999'] => ['1/1/2000'],
      ['1/1/1911'] => ['1/1/1912'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['5/5/1999'] => ['1/1/1999'],
      ['1/1/1911'] => ['1/1/1911'],
      [$_D->get_min] => [$_D->get_min],
      ],
      ],
      $_DI->MONTH => [
      inc => [
      ['1/1/1911'] => ['2/1/1911'],
      ['1/31/2000'] => ['2/29/2000'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['1/1/1911'] => ['12/1/1910'],
      ['2/29/2000'] => ['1/29/2000'],
      ['7/31/2000'] => ['6/30/2000'],
      [$_D->get_min] => Bivio::DieCode->DIE,
      ],
      inc_to_end => [
      ['1/1/1911'] => ['1/31/1911'],
      ['2/29/2000'] => ['3/28/2000'],
      ],
      ],
      $_DI->YEAR => [
      inc => [
      ['1/1/1911'] => ['1/1/1912'],
      ['2/29/2000'] => ['2/28/2001'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['1/1/1911'] => ['1/1/1910'],
      ['2/29/2000'] => ['2/28/1999'],
      [$_D->get_min] => Bivio::DieCode->DIE,
      [$_D->get_max] => ['12/31/2198'],
      ],
      inc_to_end => [
      ['1/1/1911'] => ['12/31/1911'],
      ['2/29/2000'] => ['2/27/2001'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      ],
      $_DI->FISCAL_YEAR => [
      inc => [
      ['3/3/1911'] => ['1/1/1912'],
      ['1/1/1999'] => ['1/1/2000'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['3/3/1911'] => ['1/1/1911'],
      ['1/1/1999'] => ['1/1/1998'],
      [$_D->get_min] => Bivio::DieCode->DIE,
      ],
      inc_to_end => [
      ['3/3/1911'] => ['12/31/1911'],
      ['1/1/1999'] => ['12/31/1999'],
      ['12/31/1999'] => ['12/31/1999'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      ],
      $_DI->IRS_TAX_SEASON => [
      inc => [
      ['3/3/1911'] => ['1/1/1912'],
      ['1/1/1999'] => ['1/1/2000'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      dec => [
      ['3/3/1911'] => Bivio::DieCode->DIE,
      ['1/1/1999'] => Bivio::DieCode->DIE,
      [$_D->get_min] => Bivio::DieCode->DIE,
      ],
      inc_to_end => [
      ['3/3/1911'] => ['4/15/1911'],
      ['1/1/1999'] => ['4/15/1999'],
      ['12/31/1999'] => ['4/15/2000'],
      ['4/15/1999'] => ['4/15/1999'],
      ['4/16/1999'] => ['4/15/2000'],
      [$_D->get_max] => Bivio::DieCode->DIE,
      ],
      ],
      ]);