Showing posts from May, 2009

perltidy and block labels

perltidy has its own mind at times. Most of the time, its mind is better than my hands reformatting code.

But I've been writing lots of test code recently and found that I use blocks and labels, along with nested blocks with labels. Stuff that looks like:
my $shared_db_thingy = create_db_thingy( %params );

# create user tests
skip 'DB Thingy not created', $test_count
unless $shared_db_thingy;

lives_ok { $shared_db_thingy->create_user( %user_parameters ) } 'create_user';

# retrieve user tests
}Frustratingly, perltidy likes to tidy this into:
}I had to do some real digging into perltidy to find the -ola that outdents labels.

Setting the -nola fixes it. And doesn't having any (seen) side effects.


vim productive note

When writing tests for Perl objects (or modules), I like to store the name of the module in a named buffer/register in vim.

I usually visually highlight the object(or module) name, then put it in the "n" buffer.
Yank into n: "ny
Paste out of n: "np
I guess the m or n buffer might make sense.

If you forget like I do what buffer your using you can dump them in vim with:

So it was...