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

Re: [ProgSoc] Programming! Code!



On Thursday 19 October 2006 04:27, John Elliot wrote:
> I kind of like the idea of 'unit tests' as 'fitness tests' (albeit
> (necessarily) 'lossy' and 'incomplete' ones).

Here's an interesting idea...

One of the big unsolved problems (AIUI) in computer science right now is 
how to write the 'fitness tests' for genetic algorithms for software 
development.

I know very little about the topic, but I've heard that it's tricky, and 
it kind of makes sense to me that it's tricky (i.e. chicken and egg, 
Strange Loop, stuff).

However... what about this idea.

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, how about this as a 'convention'...

Some test cases are given and held to be 'representative', that's 
one 'side'. On the other side the assumption is that the test cases 
given must lead to 100% code coverage. I.e. that it is not valid to 
have a code path in your function which would not be exercised by the 
set of test cases.

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?










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