Christopher Done
Christopher Done

Reputation: 5974

Is there available a complete set of JavaScript (ECMAScript) parser test cases?

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 from being baffled by the hand-coded parsers, the parse tests seem to be combined with evaluation tests.

Upvotes: 2

Views: 1126

Answers (1)

Christian C. Salvadó
Christian C. Salvadó

Reputation: 827762

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.

Upvotes: 2

Related Questions