On Tue, 14 Mar 2006, Smylers wrote:

> Dr Bean writes:

> > I've gotten comfortable with Test::More conventions, but it's
> > difficult in my editor to really quickly create lots of tests.

> > is($o->index('You'), 1, 'objects index 1');
> > isnt($o->index(1), 1, 'objects index 2');
> > isnt($o->index(2), 2, 'objects index 2');
> > is($o->index($t), 3, 'objects index 3');

> > Incrementing numbers and substituting words and letters takes
> > time

> If your editor happens to be Vim then be aware that Ctrl+A adds 1 to the
> number currently under the cursor, or the next number on the current
> line if the cursor isn't on a number.

Actually, I am using vim, and probably I used Ctrl+A to increment
the numbers here.

> And if there's a second number you wish to increment on the same line
> then simply press l to move to the right of the first number (which the
> cursor will have moved to on pressing Ctrl+A the first time) and then
> press Ctrl+A again.

That's what I actually do do to increment more than one number in
the same line. It's handy that you don't have to have the cursor
above the number you want to increment.

Vim actually has a nrformats option to allow you to increment
letters, like perl allows you to. The reason that I don't have
nrformats=alpha as my default is that it means I then have to
align the cursor with the number I want to increment.

But even using Ctrl+A my fingers can't keep up with where my
thoughts are and creating tests degenerates into mechanical
keypressing busywork.

You can see in my example above that 2 of the test labels are the
same. I probably yanked and put one of the lines, but didn't
finish fixing the test label.

Judging from the lack of meaningful labels on perl tests, it
appears most people probably have the same problem.

> If you're doing this a lot then you can use q to record a keyboard macro
> for processing one line and moving on to the next, then it's just a case
> of holding down the @ key to do as many lines as you want.

I guess if I knew what tests I was going to create beforehand and
there was a pattern I might do this, but so far I haven't seen
the pattern.

[I guess a macro to do something with the 3 parts of a subtest:
input, expected output, and label along the lines of the
vim bracketing macros might be worth thinking about.]

I'm probably going to try David Golden's foreach loop accessing
the input, expected output and label in a hash or array, at the
same time as I play with Test::Base and switch between them,
depending on how they go.

-- 
Dr Bean                      Vent the Pent.
                             --Samuel Beckett

Reply via email to