I am going to write a JavaScript parser, I would like a set of test cases, i.e., things that should parse into what (and possibly things that should not parse) that I can throw at my parser to test its correctness. I don't want to test running of JavaScript, just parsing.
I am reading through the ECMAScript spec and creating a set of test-cases from that, but if someone's already done it, that's great.
I also had a look at the V8 and SpiderMonkey sources for test cases but, apart fro开发者_JAVA技巧m being baffled by the hand-coded parsers, the parse tests seem to be combined with evaluation tests.
I can give you two starting points, from two recent projects:
A couple of months ago, Peter van der Zee (aka @kuvos) made an ECMAScript 5 parser, his parser includes some syntax-dedicated tests and a fuzzer, jsfunfuz by Jesse Ruderman.
Check EsParser.js (look for the EsParser.testSuite
function) to find some of those tests.
There's other ECMAScript 5 parser written in ECMAScript, this one if from the Google's ES-Lab project, they have also a good set of syntax-oriented unit tests that you can find here.
精彩评论