Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Thursday November 07, 2002
08:42 AM

Mac::Carbon and Testing

[ #8816 ]

I am normally loathe to write tests, but for Mac::Carbon, I am making an exception. So the other night, I started working on a test suite. It is far from exhaustive, but it is a nice beginning. It does things like get a list of your volumes, convert them from FSSpec to paths, make sure the paths exist with -d, runs an AppleScript to get the version of the Finder, gets/sets creator/type of files, displays the amount of RAM in and the clock speed of the machine, displays a notification dialog to tell you to switch various applications to the front/back, plays a sound from a resource file, talks using the speech manager, and more.

I am even using Test::More, which makes life easier. I may need to include it in MacPerl. It's all working really well thus far.

    ok(my $h = Handle->new('xyzzy'),    'new handle');
    is($h->get, 'xyzzy',            'get handle');
    is($h->size, 5,                'handle size');
    is($h->get(2, 2), 'zz',            'get handle portion');

I just need to add some more tests for Mac::Files and Mac::MoreFiles, then clean it up (which includes making it build on machines other than this one and integrating the changes with MacPerl). Then: profit! I mean: release!

Now Playing: Fired - Ben Folds (Rockin' the Suburbs)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I started writing tests for some code here at work, and it's really really helped. It's also kind of addictive. The more you write, the better you feel about your code. I find that Test::More and Test::Harness together make for a very nice testing environment, as well.


  • ... did you find any bugs with your tests?


    • Not that I can recall, but much of the test suite would have failed if not for detection of problems in my previous one-off tests (I wrote a lot of one-liners while working on the port).

      These modules have all been around so long (most of them for upwards of 6 years) that the bugs in them are few and far between. I am changing very little of the modules; most of the bugs will have to do with my ported support functions (for time conversions, GUSI replacement functions, etc.) and various unique interactions