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

Re: Perl, OOP, and Unit Testing

Expand Messages
  • Asim Jalis
    Hey Rob, ... What do you mean by declarative tests ? Could you give an example? Asim __________________________________________________ Do You Yahoo!? Yahoo!
    Message 1 of 4 , Jul 22, 2002
    • 0 Attachment
      Hey Rob,

      > My #1 goal in testing is to have a test case per
      > line. I find declarative testing is the easiest
      > way to do this. It also gives more control to the
      > test framework. To me, it's completely natural
      > and easy to write declarative tests in Perl. In
      > Java it's cumbersome, because it lacks simple data
      > structures like lists. Can't say for Python.

      What do you mean by "declarative tests"? Could you
      give an example?

      Asim


      __________________________________________________
      Do You Yahoo!?
      Yahoo! Health - Feel better, live better
      http://health.yahoo.com
    • 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 2 of 4 , Jul 23, 2002
      • 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.