views:

126

answers:

2

At the moment I am working (just for fun) on a kind of compiler that breaks PHP-code down to a source code for a low level VM.

As the type system and a lot of of the PHP-features are not that logical I need a much testscripts to verify that my code behaves as it would in PHP.

I started to test everything with the test from the PHP-sources (here). But a lot of the test are not only language specific, they also contain some features from the webserver handling (POST-data, etc.) Are there any other tests to test PHP as a language? The best would be, if the script itself is written in PHP.

A: 

I may be misunderstanding you, but this may be what you're looking for?
http://www.simpletest.org/

They've designed it to be like JUnit, but for php, according to the description.

Aaron
+1  A: 

If you are validating that your semantics behave as they would in the Zend implementation of PHP then I would recommend building an automated tool to generate grammar from the BNF of PHP itself. This way you would have alot of .php files expressing much of the semantics. Be sure to include alot of trace code in the generated files.

Then run it through the Zend implementation and yours to ensure you get the same validation. Use some broken code generation to ensure you catch it too. Only when you know your implementation is correct (with quirks) can you move on.

http://llvm.org/devmtg/2008-08/Lopes_PHP-JIT-InTwoDays.pdf might help. Look into people building a PHP JIT for LLVM. Might provide some information on how they test the validity of the language syntax and semantics against an existing implementation.

Aiden Bell