Re: STAREAST, May 17-21 2004, The Rosen Centre Hotel, Orlando, FL
We are pleased to welcome you as a Track Speaker at STAREAST 2004...
This begins my letter of acceptance as a speaker at Star East 2004. I'll be speaking on Test Driven Development in Perl. Obviously, this would never have happened without Scwhern, Chromatic, Lester, Scwartz, Wall, and Kent Beck.
Anyone want to peer review a 1-hour presentation?
So, I've got some code that uses Net::Ftp.pm.
Now and again, I have to transfer really really big files. The whole system is automated, but it hangs and dies on a call to $ftp->put($filename).
So, the app dies, the sysadmin re-starts it, and it starts over again, transmitting the same file, hangs and dies. Never gets to the rest of the files, some of whom go to FTP sites that actually, you know, work.
I'm thinking of refactoring the code so that it just reports error instead of die-ing. Then it can process the ones that might work, and then come back and try again with the big file that only works rarely.
To do so, I'm planning on wrapping an eval block around the offensive code, and checking $@ to see if the call 'dies.'
Does this sound like a good approach?
regards,
Someone on JoelonSoftware wanted to figure out how to do automated unit tests in TCL, so I wrote up this post:
Mike Scwern wrote test::More for Perl as well as test::Tutorial.
http://magnonel.guild.net/~schwern/talks/Test_Tutorial/Test-Tutorial.pdf
Basically, I'd suggest making a simple library with functions like this:
sub tests(int);
sub eq(string, int, int);
sub eq(string, bool, bool);
sub eq(string, double, double);
sub eq(string, string, string);
sub ok(string, bool);
The psuedo code looks something like this:
GLOBAL iTestNum int;
sub tests(i int)
{
printf("1..%d\n", i);
iTestNum = 1;
}
sub ok(s string, b bool)
{
if (b)
{
print("ok %d - %s\n", iTestNum, s);
}
else
{
print("not ok %d - %s\n", iTestNum, s);
}
iTestNum++;
}
sub eq(s string, i int, i2 int)
{
if (i==i2)
{
print("ok %d - %s\n", iTestNum, s);
}
else
{
print("not ok %d - %s\nGot %d\nExpected %d\n",
iTestNum, s, i, i2);
}
iTestNum++;
}
So your output to STDIO looks like this:
1..5
ok 1 - Foo with valid input
ok 2 - Foo with invalid group number
ok 3 - Error Message for invalid group number
not ok 4 - Foo with invalid date
not ok 5 - Error Message for invalid date
Expected - "Date 10/35/2003 is not a valid date"
Got - ""
Obviously, your function is something like:
func foo(iGroupNum int, sDate string) returns BOOL;
--All this is pseduo code you can write up in any langauge.
If you write it correctly, you can pump it through Test::Harness or Prove automatically.
That's the 5 minute version, anyway. You can write test harnesses in any language. (If you die after test 3 because of an unhandled exception, you know you SHOULD have had 5 tests because of the 1..5, so that too is a test.)
Thoughts? I think there's some interesting potential stuff about a "Generic Unit Test Framework", but it needs more work
I've got a program that looks something like this:
#Begin code
$sth->bind_param(1, 'blahblah');
$sth->bind_param(2, $somevar);
#End Code
I want to change it to this:
#Begin code
$sth->bind_param(1, $somevar);
$sth->bind_param(2, 'blahblah');
#End Code
Here's how I would do it in VI:
Go to the 1. Type 'I' (Insert Mode), change it to 2. Go to the 2, change it to 1. Type 'ESC'
Do to the first line. Press DD (Delete). Arrow down. Press P (Paste). Arrow up, and DD the blank line inserted. Arrow down, press I (Insert), backspace, hit return, then fix the indenting on the next line.
I'm 100% convinced this is a silly, inefficient way to type. Yes, it beats the heck out of some GUI Windows-like text editor, but still, it should be faster. I just don't know enought about VI (or vim) yet.
Ideas are welcome.