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

Re: [extremeperl] Re: Perl, OOP, and Unit Testing

Expand Messages
  • Rob Nagler
    ... A declarative language allows you to specify your intent and the interpreter executes the program in whatever order it sees fit. SQL is a declarative
    Message 1 of 4 , Jul 23 4:41 AM
    • 0 Attachment
      Asim Jalis writes:
      > What do you mean by "declarative tests"? Could you
      > give an example?

      A declarative language allows you to specify your intent and the
      interpreter executes the program in whatever order it sees fit. SQL
      is a declarative language. Here's a declarative test:

      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],
      ],
      ]]);

      This test is compiled by Bivio::Test->unit first. This generates the
      standard 1..n header for Perl tests. It also outputs ok/not ok.
      Catches exceptions and so on. All I need to do is declare the
      relationships between API calls and values. I don't particularly care
      what order the tests are executed in or *how* it executes them. I
      only care that *what* Bivio::Test->unit executes is as I have defined
      it.

      Rob
    Your message has been successfully submitted and would be delivered to recipients shortly.