If you want to do the right way you should look at ``Twig_SimpleTest`` and the ``getTests`` function in twig.