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

Re: [ProgSoc] Programming! Code!



John Elliot wrote:

Say you have a 'non-existent' function, and you want a genetic algorithm (or even a sentient flesh-and-blood software developer) to generate an implementation for you

... and there it is.

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.


-- Myles

-
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.