[Petal] Re: Using Test::More

Fergal Daly fergal at esatclear.ie
Wed Apr 9 00:08:32 BST 2003


On Tuesday 08 April 2003 21:45, Jean-Michel Hiver wrote:
> I probably didn't know very much about writing test suites when I 
> started Petal. One thing that worries me is that I don't think that 
> Test::More is part of the standard Perl distribution. Is it?

It comes with Perl 5.8.0 but not 5.6.1. It's used by a lot of modules so I'd 
guess most people have it. 

> That being said, I know that Test::More is immensely better than what 
> I'm doing at the moment..

I've changed a few more tests to use Test::More. The changes are all very 
mechanical, in fact a sufficiently long 1-liner would probably do most of the 
work if I was feeling adventurous!

Patch attached.

My new codegenerator passes all except 17 tests. Most of those are things I 
just didn't implement yet.

> Other than that, I've been thinking about the local / global keyword 
> issue... I think the way to do it is to tweak Petal::Hash::VAR so that 
> it has a %GLOBALS global hash, and it recognizes the 'global' keyword.
> 
> Whenever a variable is set using the 'global' keyword, it is stored in 
> the %GLOBALS hash.
> 
> Whenever a variable is fetched, it is fetched from the current context 
> ($hash) or from the %GLOBALS hash if the current context returned undef.
> 
> So that seems very doable... One think that worries me is that we need 
> the %GLOBALS hash to be reinitialized properly when using persistent 
> environments a la mod_perl.
> 
> To achieve that, I was thinking of declaring %GLOBALS as a local 
> variable in Petal::process(). This would mean that the keyword 'global' 
> would work except for included templates, which I think is fair enough 
> since the notion of 'include' doesn't exist in TAL (They use METAL 
> instead, which will have to be implemented at some point I guess...)

I don't really know enough about the innards of Petal but that scheme sounds 
ok. I did have another question about local/global stuff in general. What 
happens when you set a variable globally that has already been set locally? 
What does Zope's TAL do in that case?

Finally, in atrributes and defines you seem to be using \; when you want to 
include a ; in the value. The TAL spec says ;s should be escaped as ;; rather 
than \;. Maybe you could have both for compatibiliy,

F
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t2.patch
Type: text/x-diff
Size: 6577 bytes
Desc: not available
Url : http://www.email-lists.org/pipermail/petal/attachments/20030408/4f49539e/t2.bin


More information about the Petal mailing list