npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

test262-parser-tests

v0.0.5

Published

Test cases for ECMAScript parsers

Downloads

2,433

Readme

Parser Tests

This repository contains tests designed for parsers. There are three directories of tests:

  • pass/, which contains syntactically valid ECMAScript programs,
  • early/, which contains programs which match the grammar of ECMAScript but which trigger early errors, and
  • fail/, which contains files which do not match the grammar of ECMAScript.

A fourth directory, pass-explicit/, contains alternative versions of the programs in pass/, for reasons discussed below.

Note that these tests are not intended to be evaluated, only parsed. Most would throw an error if run. Because they are testing syntax without depending on a functioning eval(), they include no metadata; each file is a utf8-encoded sequence of bytes which is to be parsed in full. The file LICENSES.md gives the origin and license of each file.

Equivalence tests

Every file in pass/ has a corresponding file in pass-explicit/ of the same name. The explicit version (in pass-explicit/) is intended to appear as a human might write it, with parentheses included where there could conceivably be unclear precedence.

The two versions of each file should be parsed to structures which are equivalent excepting unnecessary whitespace, comments, grouping parentheses, and semicolons.

Contributing

New pass/ and early/ tests should be normalized using the NPM module normalize-parser-test. pass/ tests should additionally have an explicit version created using the provided node.js program make-explicit.js, which requires node v5 or later.

Add copyright information for new tests to licenses.md.

Sample consumer

Below is a node.js program which checks that a particular choice of parser has the correct behavior for all of the tests in this directory. Note that a parser which does not distinguish between early errors and other invalid syntax should treat the tests in early/ just as they would the tests in fail/.

const fs = require('fs');
const shift = require('shift-parser');
const assert = require('assert');

function parse(src, {isModule, earlyErrors}) {
  (isModule ? shift.parseModule : shift.parseScript)(src, {earlyErrors});
}

let passExcludes = [];
let failExcludes = [];
let earlyExcludes = ['557.script.js', '558.script.js', '559.script.js', '560.script.js', '561.script.js', '563.script.js', '564.script.js', '565.script.js', '566.script.js', '567.script.js', '568.script.js', '569.script.js', '570.script.js', '571.script.js', '572.script.js', '574.script.js', '575.script.js', '576.script.js', '577.script.js', '578.script.js', '579.script.js', '580.script.js', '581.script.js', '582.script.js', '583.script.js', '585.script.js', '586.script.js', '587.script.js', '588.script.js', '589.script.js', '590.script.js', '591.script.js', '592.script.js', '593.script.js', '594.script.js', '596.script.js', '597.script.js', '598.script.js', '599.script.js', '600.script.js', '601.script.js', '602.script.js'];

fs.readdirSync('pass').filter(f => !passExcludes.includes(f)).forEach(f => {
  let firstTree, secondTree;
  assert.doesNotThrow(() => {
    firstTree = parse(
      fs.readFileSync(`pass/${f}`, 'utf8'),
      {isModule: f.match('.module.js'), earlyErrors: true}
    );
  });
  assert.doesNotThrow(() => {
    secondTree = parse(
      fs.readFileSync(`pass-explicit/${f}`, 'utf8'),
      {isModule: f.match('.module.js'), earlyErrors: true}
    );
  });
  assert.deepStrictEqual(firstTree, secondTree);
});

fs.readdirSync('fail').filter(f => !failExcludes.includes(f)).forEach(f => {
  assert.throws(() => {
    parse(
      fs.readFileSync(`fail/${f}`, 'utf8'),
      {isModule: f.match('.module.js'), earlyErrors: false}
    );
  });
});

fs.readdirSync('early').filter(f => !earlyExcludes.includes(f)).forEach(f => {
  assert.doesNotThrow(() => {
    parse(
      fs.readFileSync(`early/${f}`, 'utf8'),
      {isModule: f.match('.module.js'), earlyErrors: false}
    );
  });
  assert.throws(() => {
    parse(
      fs.readFileSync(`early/${f}`, 'utf8'),
      {isModule: f.match('.module.js'), earlyErrors: true}
    );
  });
});