[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ProgSoc] Programming! Code!



On Thursday 19 October 2006 13:38, Myles Byrne wrote:
> > Then if you had an unimplemented function with this signature:
> >
> >  Int32 fn( Int32 );
> >
> > And these two assertions:
> >
> >  assert_equal( delegate() { return fn( 0 ); }, 1 );
> >  assert_fail( delegate() { return fn( Int32.MaxValue ); } );
> >
> > Then the only possible implementation for fn would be:
> >
> >  Int32 fn( Int32 i ) { return i + 1; }
> >
> > Any other implementation would lead to code paths which were not
> > covered... wouldn't it?
>
> Int32 fn( Int32 i ) {
>    if ( i < Int32.MaxValue ) { return 1 }
>    else { raise Error } // or throw or whatever
> }
>
> ... and there a few other implementations that would satisfy those
> assertions and still be broken.

Is there? What are they? I don't see them.

What if I restate the requirements:

  assert_equal( delegate() { return fn( 0 ); }, 1 );
  assert_equal( delegate() { return fn( 1 ); }, 2 );
  assert_fail( delegate() { return fn( Int32.MaxValue ); } );

(I always end up with that "the program *is* the formal statement of the 
requirements" feeling too. Lousy strange loops.)






-
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to progsoc-request@xxxxxxxxxxxxxxxxxxx
If you are having trouble, ask owner-progsoc@xxxxxxxxxxxxxxxxxx for help.