Subject: | ps/current-test-count vs BEGIN block |
Date: | Thu, 08 Jul 2010 09:19:39 +1000 |
To: | bug-Devel-PerlySense [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In perlysense 0.0183 the emacs test count update doesn't work if the
plan is in a BEGIN block like
BEGIN {
plan tests => 16;
}
It seems number-at-point in ps/current-test-count returns nil if point
is just after the number, if it's within a { } block. Sounds pretty
dodgy on emacs part there, but I think ps/current-test-count might
better go straight from the match anyway. I get some joy from the
following,
(defun ps/current-test-count ()
"Return the test count of the current buffer, or nil if that couldn't be deduced."
(save-excursion
(goto-char (point-min))
(and (re-search-forward "tests\s+=>\s*\\([0-9]+\\)" nil t)
(string-to-number (match-string 1)))))