agt

atom-grammar-test

Grammar testing framework for atom based on syntax test files

Showing:

Popularity

Downloads/wk

337

GitHub Stars

14

Maintenance

Last Commit

2yrs ago

Contributors

4

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Atom Grammar Test

npm version Build Status

Atom Grammar Test is a testing framework for Atom Grammar definitions inspired by the Syntax Testing format for Sublime Text 3. It allows you to define grammar fixtures for testing your grammar rules. Because the fixtures match the source code format, they can be both programmatically tested as well as visually inspected for easily development.

View the grammar

Here's an adaption of the example provided in the Sublime docs where you define your tokenization assertions in-line as comments. Note how it visually annotates how the grammar should be parsed.

// SYNTAX TEST "source.c"
#pragma once
// <- punctuation.definition.directive meta.preprocessor.c
 // <- keyword.control.directive.pragma

// foo
// ^ source.c comment.line
// <- punctuation.definition.comment

/* foo */
// ^ source.c comment.block
// <- punctuation.definition.comment.begin
//     ^ punctuation.definition.comment.end

#include "stdio.h"
// <- keyword.control.directive.include
//       ^ meta string punctuation.definition.string.begin
//               ^ meta string punctuation.definition.string.end
int square(int x)
// <- storage.type
//  ^ meta.function entity.name.function
//         ^ storage.type
{
    return x * x;
//  ^^^^^^ keyword.control
}

"Hello, World! // not a comment";
// ^ string.quoted.double
//                  ^ string.quoted.double

// EOF Check (root scope)
// >> =source.c

Once you've defined your grammar test, you can simply plug into the Jasmine 1.3 provided by Atom:

grammarTest = require 'atom-grammar-test'

describe 'My Grammar', ->

  beforeEach ->
    # Ensure you're language package is loaded
    waitsForPromise ->
      atom.packages.activatePackage 'language-<your-grammar>',

  grammarTest('<path to your grammar test file>')

Installation Instructions

You can install atom-grammar-test via npm and should add it to your devDependencies of your atom package's package.json:

npm install atom-grammar-test --save-dev

Projects Using Atom Grammar Test

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100