Skip to main content
Module

x/ohm_js/test/examples/test-prettyPrint.js

A library and language for building parsers, interpreters, compilers, etc.
Go to Latest
File
'use strict';
const test = require('ava');
const prettyPrint = require('../../../../examples/prettyPrint');
test('basic', t => { t.is(prettyPrint('G { Start=#("a"|b + ) ? }'), 'G {\n Start = #("a" | b+)?\n}');});
test('grammar with supergrammar', t => { t.is( prettyPrint('G<:Foo{Start=& (~ digit letter)"\\\\n" * }'), 'G <: Foo {\n Start = &(~digit letter) "\\\\n"*\n}' );});
test('multiple rules', t => { t.is( prettyPrint(' G { Start (the start )=a< "b" >-- start\na< arg >=arg "a" .. "z"}'), [ 'G {', ' Start (the start)', ' = a<"b"> -- start', ' a<arg> = arg "a".."z"', '}', ].join('\n') );});