feat: Add Be and tbd skill, also added Roadmap file

This commit is contained in:
2026-05-10 16:32:12 -04:00
parent 3500ade13f
commit 0bb8885802
29587 changed files with 10611695 additions and 0 deletions

View File

@@ -0,0 +1,128 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima: Benchmarks</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../assets/style.css">
<link rel="stylesheet" href="../assets/foundation/foundation.min.css">
</style>
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="../index.html">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="../demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="../demo/parse.html">Online Parsing</a></li>
<li><a href="../demo/validate.html">Syntax Validator</a></li>
<li><a href="../demo/precedence.html">Operator Precedence</a></li>
<li><a href="../demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="../demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="../demo/rewrite.html">Source Rewrite</a></li>
<li><a href="../demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="../demo/highlight.html">Identifier Highlight</a></li>
<li><a href="../demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="../test/index.html">Unit Tests</a></li>
<li><a href="../test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="../test/compat.html">Compatibility Tests</a></li>
<li><a href="../test/compare.html">Speed Comparison</a></li>
<li><a href="../test/module.html">Module Loading</a></li>
<li><a href="../test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="../doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>Benchmarks</strong> show the true speed</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="eight columns">
<p>
<input id="runquick" class="medium radius button secondary" type="submit" value="Run quick benchmarks" disabled/>
<input id="runfull" class="medium radius button" type="submit" value="Run full benchmarks" disabled/>
</p>
<p id="result"></p>
<div id="status" class="alert-box secondary">Please wait...</div>
</div>
<div class="four columns">
<div class="panel">
<p><strong>Note</strong>: On a modern machine and up-to-date web browsers,
the <strong>full</strong> benchmarks suite takes ~1 minute.
For the quick benchmarks, the running time is only ~15 seconds.</p>
<p>Version being tested: <strong><span id="version"></span></strong>.</p>
</div>
<p>Time measurement is carried out using <a href="http://benchmarkjs.com" target="_blank">Benchmark.js</a><span id="benchmarkjs-version"></span>.</p>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
<script src="../esprima.js"></script>
<script src="../assets/json2.js"></script>
<script src="benchmarks.js"></script>
<script src="3rdparty/benchmark.js"></script>
<script src="3rdparty/XMLHttpRequest.js"></script>
<script>
/*jslint browser:true, sloppy:true */
/*global setupBenchmarks:true*/
window.onload = function () {
window.setTimeout(setupBenchmarks, 211);
};
</script>
</body>
</html>

View File

@@ -0,0 +1,334 @@
/*
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint browser: true node: true */
/*global load:true, print:true */
var setupBenchmarks,
fullFixture,
quickFixture;
fullFixture = [
'Underscore 1.4.1',
'Backbone 0.9.2',
'CodeMirror 2.34',
'MooTools 1.4.1',
'jQuery 1.8.2',
'jQuery.Mobile 1.2.0',
'Angular 1.0.2',
'three.js r51'
];
quickFixture = [
'Backbone 0.9.2',
'jQuery 1.8.2',
'Angular 1.0.2'
];
function slug(name) {
'use strict';
return name.toLowerCase().replace(/\.js/g, 'js').replace(/\s/g, '-');
}
function kb(bytes) {
'use strict';
return (bytes / 1024).toFixed(1);
}
if (typeof window !== 'undefined') {
// Run all tests in a browser environment.
setupBenchmarks = function () {
'use strict';
function id(i) {
return document.getElementById(i);
}
function setText(id, str) {
var el = document.getElementById(id);
if (typeof el.innerText === 'string') {
el.innerText = str;
} else {
el.textContent = str;
}
}
function enableRunButtons() {
id('runquick').disabled = false;
id('runfull').disabled = false;
}
function disableRunButtons() {
id('runquick').disabled = true;
id('runfull').disabled = true;
}
function createTable() {
var str = '',
index,
test,
name;
str += '<table>';
str += '<thead><tr><th>Source</th><th>Size (KiB)</th>';
str += '<th>Time (ms)</th><th>Variance</th></tr></thead>';
str += '<tbody>';
for (index = 0; index < fullFixture.length; index += 1) {
test = fullFixture[index];
name = slug(test);
str += '<tr>';
str += '<td>' + test + '</td>';
str += '<td id="' + name + '-size"></td>';
str += '<td id="' + name + '-time"></td>';
str += '<td id="' + name + '-variance"></td>';
str += '</tr>';
}
str += '<tr><td><b>Total</b></td>';
str += '<td id="total-size"></td>';
str += '<td id="total-time"></td>';
str += '<td></td></tr>';
str += '</tbody>';
str += '</table>';
id('result').innerHTML = str;
}
function loadTests() {
var index = 0,
totalSize = 0;
function load(test, callback) {
var xhr = new XMLHttpRequest(),
src = '3rdparty/' + test + '.js';
window.data = window.data || {};
window.data[test] = '';
try {
xhr.timeout = 30000;
xhr.open('GET', src, true);
xhr.ontimeout = function () {
setText('status', 'Error: time out while loading ' + test);
callback.apply();
};
xhr.onreadystatechange = function () {
var success = false,
size = 0;
if (this.readyState === XMLHttpRequest.DONE) {
if (this.status === 200) {
window.data[test] = this.responseText;
size = this.responseText.length;
totalSize += size;
success = true;
}
}
if (success) {
setText(test + '-size', kb(size));
} else {
setText('status', 'Please wait. Error loading ' + src);
setText(test + '-size', 'Error');
}
callback.apply();
};
xhr.send(null);
} catch (e) {
setText('status', 'Please wait. Error loading ' + src);
callback.apply();
}
}
function loadNextTest() {
var test;
if (index < fullFixture.length) {
test = fullFixture[index];
index += 1;
setText('status', 'Please wait. Loading ' + test +
' (' + index + ' of ' + fullFixture.length + ')');
window.setTimeout(function () {
load(slug(test), loadNextTest);
}, 100);
} else {
setText('total-size', kb(totalSize));
setText('status', 'Ready.');
enableRunButtons();
}
}
loadNextTest();
}
function runBenchmarks(suite) {
var index = 0,
totalTime = 0;
function reset() {
var i, name;
for (i = 0; i < fullFixture.length; i += 1) {
name = slug(fullFixture[i]);
setText(name + '-time', '');
setText(name + '-variance', '');
}
setText('total-time', '');
}
function run() {
var el, test, source, benchmark;
if (index >= suite.length) {
setText('total-time', (1000 * totalTime).toFixed(1));
setText('status', 'Ready.');
enableRunButtons();
return;
}
test = slug(suite[index]);
el = id(test);
source = window.data[test];
setText(test + '-time', 'Running...');
// Force the result to be held in this array, thus defeating any
// possible "dead core elimination" optimization.
window.tree = [];
benchmark = new window.Benchmark(test, function (o) {
var syntax = window.esprima.parse(source);
window.tree.push(syntax.body.length);
}, {
'onComplete': function () {
setText(this.name + '-time', (1000 * this.stats.mean).toFixed(1));
setText(this.name + '-variance', (1000 * this.stats.variance).toFixed(1));
totalTime += this.stats.mean;
}
});
window.setTimeout(function () {
benchmark.run();
index += 1;
window.setTimeout(run, 211);
}, 211);
}
disableRunButtons();
setText('status', 'Please wait. Running benchmarks...');
reset();
run();
}
id('runquick').onclick = function () {
runBenchmarks(quickFixture);
};
id('runfull').onclick = function () {
runBenchmarks(fullFixture);
};
setText('benchmarkjs-version', ' version ' + window.Benchmark.version);
setText('version', window.esprima.version);
createTable();
disableRunButtons();
loadTests();
};
} else {
(function (global) {
'use strict';
var Benchmark,
esprima,
dirname,
option,
fs,
readFileSync,
log;
if (typeof require === 'undefined') {
dirname = 'test';
load(dirname + '/3rdparty/benchmark.js');
load(dirname + '/../esprima.js');
Benchmark = global.Benchmark;
esprima = global.esprima;
readFileSync = global.read;
log = print;
} else {
Benchmark = require('./3rdparty/benchmark');
esprima = require('../esprima');
fs = require('fs');
option = process.argv[2];
readFileSync = function readFileSync(filename) {
return fs.readFileSync(filename, 'utf-8');
};
dirname = __dirname;
log = console.log.bind(console);
}
function runTests(tests) {
var index,
tree = [],
totalTime = 0,
totalSize = 0;
tests.reduce(function (suite, filename) {
var source = readFileSync(dirname + '/3rdparty/' + slug(filename) + '.js'),
size = source.length;
totalSize += size;
return suite.add(filename, function () {
var syntax = esprima.parse(source);
tree.push(syntax.body.length);
}, {
'onComplete': function (event, bench) {
log(this.name +
' size ' + kb(size) +
' time ' + (1000 * this.stats.mean).toFixed(1) +
' variance ' + (1000 * 1000 * this.stats.variance).toFixed(1));
totalTime += this.stats.mean;
}
});
}, new Benchmark.Suite()).on('complete', function () {
log('Total size ' + kb(totalSize) +
' time ' + (1000 * totalTime).toFixed(1));
}).run();
}
if (option === 'quick') {
runTests(quickFixture);
} else {
runTests(fullFixture);
}
}(this));
}
/* vim: set sw=4 ts=4 et tw=80 : */

140
Skills/@be/be/node_modules/esprima-fb/test/compare.html generated vendored Normal file
View File

@@ -0,0 +1,140 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima: Speed Comparisons</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../assets/style.css">
<link rel="stylesheet" href="../assets/foundation/foundation.min.css">
<script src="../esprima.js"></script>
<script src="../assets/json2.js"></script>
<script src="compare.js"></script>
<script src="3rdparty/benchmark.js"></script>
<script src="3rdparty/XMLHttpRequest.js"></script>
<script>
/*jslint browser:true, sloppy:true */
/*global setupBenchmarks:true*/
window.onload = function () {
window.setTimeout(setupBenchmarks, 211);
};
</script>
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="../index.html">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="../demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="../demo/parse.html">Online Parsing</a></li>
<li><a href="../demo/validate.html">Syntax Validator</a></li>
<li><a href="../demo/precedence.html">Operator Precedence</a></li>
<li><a href="../demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="../demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="../demo/rewrite.html">Source Rewrite</a></li>
<li><a href="../demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="../demo/highlight.html">Identifier Highlight</a></li>
<li><a href="../demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="../test/index.html">Unit Tests</a></li>
<li><a href="../test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="../test/compat.html">Compatibility Tests</a></li>
<li><a href="../test/compare.html">Speed Comparison</a></li>
<li><a href="../test/module.html">Module Loading</a></li>
<li><a href="../test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="../doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>Speed Comparison</strong> keeps everything in perspective</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="eight columns">
<p>
<input id="run" class="medium radius button" type="submit" value="Run speed comparison" disabled /></p>
</p>
<p id="status">Please wait...</p>
<p id="result"></p>
<p><strong>Warning:</strong> Since each parser may have a different format for the syntax tree, the speed is not fully comparable (the cost of constructing different result is obviously varying). These tests exist only to ensure that Esprima parser is not ridiculously slow compare to other parsers.</p>
</div>
<div class="four columns">
<div class="panel">
<p>More comparison variants will be added in the near future.</p>
<p>Esprima version: <strong><span id="version"></span></strong>.</p>
</div>
<p><strong>parse-js</strong> is the parser used in <a href="https://github.com/mishoo/UglifyJS">UglifyJS v1</a>. It's a JavaScript port of the Common LISP version. This test uses <tt>parse-js</tt> from UglifyJS version 1.3.2 (June 26 2012).</p>
<p><strong><a href="https://github.com/marijnh/acorn">Acorn</a></strong> is a compact stand-alone JavaScript parser. This test uses Acorn revision 48bbcd94 (dated Oct 19 2012).</p>
<p>Time measurement is carried out using <a href="http://benchmarkjs.com" target="_blank">Benchmark.js</a><span id="benchmarkjs-version"></span>.</p>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
<script src="3rdparty/acorn.js"></script>
<!-- parse-js, part of UglifyJS -->
<script>
/*global exports:true*/
exports = window.parseJS = {};
</script>
<script src="3rdparty/parse-js.js"></script>
</body>
</html>

328
Skills/@be/be/node_modules/esprima-fb/test/compare.js generated vendored Normal file
View File

@@ -0,0 +1,328 @@
/*
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint browser: true node: true */
/*global load:true, print:true */
var setupBenchmarks,
parsers,
fixtureList,
suite;
parsers = [
'Esprima',
'parse-js',
'Acorn'
];
fixtureList = [
'Underscore 1.4.1',
'Backbone 0.9.2',
'CodeMirror 2.34',
'jQuery 1.8.2'
];
function slug(name) {
'use strict';
return name.toLowerCase().replace(/\.js/g, 'js').replace(/\s/g, '-');
}
function kb(bytes) {
'use strict';
return (bytes / 1024).toFixed(1);
}
function inject(fname) {
'use strict';
var head = document.getElementsByTagName('head')[0],
script = document.createElement('script');
script.src = fname;
script.type = 'text/javascript';
head.appendChild(script);
}
if (typeof window !== 'undefined') {
// Run all tests in a browser environment.
setupBenchmarks = function () {
'use strict';
function id(i) {
return document.getElementById(i);
}
function setText(id, str) {
var el = document.getElementById(id);
if (typeof el.innerText === 'string') {
el.innerText = str;
} else {
el.textContent = str;
}
}
function enableRunButtons() {
id('run').disabled = false;
}
function disableRunButtons() {
id('run').disabled = true;
}
function createTable() {
var str = '',
i,
index,
test,
name;
str += '<table>';
str += '<thead><tr><th>Source</th><th>Size (KiB)</th>';
for (i = 0; i < parsers.length; i += 1) {
str += '<th>' + parsers[i] + '</th>';
}
str += '</tr></thead>';
str += '<tbody>';
for (index = 0; index < fixtureList.length; index += 1) {
test = fixtureList[index];
name = slug(test);
str += '<tr>';
str += '<td>' + test + '</td>';
if (window.data && window.data[name]) {
str += '<td id="' + name + '-size">' + kb(window.data[name].length) + '</td>';
} else {
str += '<td id="' + name + '-size"></td>';
}
for (i = 0; i < parsers.length; i += 1) {
str += '<td id="' + name + '-' + slug(parsers[i]) + '-time"></td>';
}
str += '</tr>';
}
str += '<tr><td><b>Total</b></td>';
str += '<td id="total-size"></td>';
for (i = 0; i < parsers.length; i += 1) {
str += '<td id="' + slug(parsers[i]) + '-total"></td>';
}
str += '</tr>';
str += '</tbody>';
str += '</table>';
id('result').innerHTML = str;
}
function loadFixtures() {
var index = 0,
totalSize = 0;
function load(test, callback) {
var xhr = new XMLHttpRequest(),
src = '3rdparty/' + test + '.js';
window.data = window.data || {};
window.data[test] = '';
try {
xhr.timeout = 30000;
xhr.open('GET', src, true);
xhr.ontimeout = function () {
setText('status', 'Error: time out while loading ' + test);
callback.apply();
};
xhr.onreadystatechange = function () {
var success = false,
size = 0;
if (this.readyState === XMLHttpRequest.DONE) {
if (this.status === 200) {
window.data[test] = this.responseText;
size = this.responseText.length;
totalSize += size;
success = true;
}
}
if (success) {
setText(test + '-size', kb(size));
} else {
setText('status', 'Please wait. Error loading ' + src);
setText(test + '-size', 'Error');
}
callback.apply();
};
xhr.send(null);
} catch (e) {
setText('status', 'Please wait. Error loading ' + src);
callback.apply();
}
}
function loadNextTest() {
var test;
if (index < fixtureList.length) {
test = fixtureList[index];
index += 1;
setText('status', 'Please wait. Loading ' + test +
' (' + index + ' of ' + fixtureList.length + ')');
window.setTimeout(function () {
load(slug(test), loadNextTest);
}, 100);
} else {
setText('total-size', kb(totalSize));
setText('status', 'Ready.');
enableRunButtons();
}
}
loadNextTest();
}
function setupParser() {
var i, j;
suite = [];
for (i = 0; i < fixtureList.length; i += 1) {
for (j = 0; j < parsers.length; j += 1) {
suite.push({
fixture: fixtureList[i],
parser: parsers[j]
});
}
}
createTable();
}
function runBenchmarks() {
var index = 0,
totalTime = {};
function reset() {
var i, name;
for (i = 0; i < suite.length; i += 1) {
name = slug(suite[i].fixture) + '-' + slug(suite[i].parser);
setText(name + '-time', '');
}
}
function run() {
var fixture, parser, test, source, fn, benchmark;
if (index >= suite.length) {
setText('status', 'Ready.');
enableRunButtons();
return;
}
fixture = suite[index].fixture;
parser = suite[index].parser;
source = window.data[slug(fixture)];
test = slug(fixture) + '-' + slug(parser);
setText(test + '-time', 'Running...');
setText('status', 'Please wait. Parsing ' + fixture + '...');
// Force the result to be held in this array, thus defeating any
// possible "dead code elimination" optimization.
window.tree = [];
switch (parser) {
case 'Esprima':
fn = function () {
var syntax = window.esprima.parse(source);
window.tree.push(syntax.body.length);
};
break;
case 'parse-js':
fn = function () {
var syntax = window.parseJS.parse(source);
window.tree.push(syntax.length);
};
break;
case 'Acorn':
fn = function () {
var syntax = window.acorn.parse(source);
window.tree.push(syntax.body.length);
};
break;
default:
throw 'Unknown parser type ' + parser;
}
benchmark = new window.Benchmark(test, fn, {
'onComplete': function () {
setText(this.name + '-time', (1000 * this.stats.mean).toFixed(1));
if (!totalTime[parser]) {
totalTime[parser] = this.stats.mean;
} else {
totalTime[parser] += this.stats.mean;
}
setText(slug(parser) + '-total', (1000 * totalTime[parser]).toFixed(1));
}
});
window.setTimeout(function () {
benchmark.run();
index += 1;
window.setTimeout(run, 211);
}, 211);
}
disableRunButtons();
setText('status', 'Please wait. Running benchmarks...');
reset();
run();
}
id('run').onclick = function () {
runBenchmarks();
};
setText('benchmarkjs-version', ' version ' + window.Benchmark.version);
setText('version', window.esprima.version);
setupParser();
createTable();
disableRunButtons();
loadFixtures();
};
} else {
// TODO
console.log('Not implemented yet!');
}
/* vim: set sw=4 ts=4 et tw=80 : */

115
Skills/@be/be/node_modules/esprima-fb/test/compat.html generated vendored Normal file
View File

@@ -0,0 +1,115 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima: Compatibility Tests</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../assets/style.css">
<link rel="stylesheet" href="../assets/foundation/foundation.min.css">
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="../index.html">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="../demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="../demo/parse.html">Online Parsing</a></li>
<li><a href="../demo/validate.html">Syntax Validator</a></li>
<li><a href="../demo/precedence.html">Operator Precedence</a></li>
<li><a href="../demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="../demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="../demo/rewrite.html">Source Rewrite</a></li>
<li><a href="../demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="../demo/highlight.html">Identifier Highlight</a></li>
<li><a href="../demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="../test/index.html">Unit Tests</a></li>
<li><a href="../test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="../test/compat.html">Compatibility Tests</a></li>
<li><a href="../test/compare.html">Speed Comparison</a></li>
<li><a href="../test/module.html">Module Loading</a></li>
<li><a href="../test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="../doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>Compatibility</strong> keeps everyone happy</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="eight columns">
<div id="report"></div>
</div>
<div class="four columns">
<div id="status" class="alert-box secondary">Please wait...</div>
<div class="panel">
<p>The following tests are to ensure that the syntax tree is compatible to
that produced by Mozilla SpiderMonkey
<a href="https://developer.mozilla.org/en/SpiderMonkey/Parser_API">Parser reflection</a>.</p>
<p>Version being tested: <strong><span id="version"></span></strong>.</p>
</div>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
<script src="../esprima.js"></script>
<script src="../assets/json2.js"></script>
<script id="reflect" src="reflect.js"></script>
<script src="compat.js"></script>
<script>
/*jslint browser: true */
window.onload = window.runTests;
</script>
</body>
</html>

241
Skills/@be/be/node_modules/esprima-fb/test/compat.js generated vendored Normal file
View File

@@ -0,0 +1,241 @@
/*
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint node: true */
/*global document: true, window:true, esprima: true, testReflect: true */
var runTests;
function getContext(esprima, reportCase, reportFailure) {
'use strict';
var Reflect, Pattern;
// Maps Mozilla Reflect object to our Esprima parser.
Reflect = {
parse: function (code) {
var result;
reportCase(code);
try {
result = esprima.parse(code);
} catch (error) {
result = error;
}
return result;
}
};
// This is used by Reflect test suite to match a syntax tree.
Pattern = function (obj) {
var pattern;
// Poor man's deep object cloning.
pattern = JSON.parse(JSON.stringify(obj));
// Special handling for regular expression literal since we need to
// convert it to a string literal, otherwise it will be decoded
// as object "{}" and the regular expression would be lost.
if (obj.type && obj.type === 'Literal') {
if (obj.value instanceof RegExp) {
pattern = {
type: obj.type,
value: obj.value.toString()
};
}
}
// Special handling for branch statement because SpiderMonkey
// prefers to put the 'alternate' property before 'consequent'.
if (obj.type && obj.type === 'IfStatement') {
pattern = {
type: pattern.type,
test: pattern.test,
consequent: pattern.consequent,
alternate: pattern.alternate
};
}
// Special handling for do while statement because SpiderMonkey
// prefers to put the 'test' property before 'body'.
if (obj.type && obj.type === 'DoWhileStatement') {
pattern = {
type: pattern.type,
body: pattern.body,
test: pattern.test
};
}
function adjustRegexLiteralAndRaw(key, value) {
if (key === 'value' && value instanceof RegExp) {
value = value.toString();
} else if (key === 'raw' && typeof value === "string") {
// Ignore Esprima-specific 'raw' property.
return undefined;
}
return value;
}
if (obj.type && (obj.type === 'Program')) {
pattern.assert = function (tree) {
var actual, expected;
actual = JSON.stringify(tree, adjustRegexLiteralAndRaw, 4);
expected = JSON.stringify(obj, null, 4);
if (expected !== actual) {
reportFailure(expected, actual);
}
};
}
return pattern;
};
return {
Reflect: Reflect,
Pattern: Pattern
};
}
if (typeof window !== 'undefined') {
// Run all tests in a browser environment.
runTests = function () {
'use strict';
var total = 0,
failures = 0;
function setText(el, str) {
if (typeof el.innerText === 'string') {
el.innerText = str;
} else {
el.textContent = str;
}
}
function reportCase(code) {
var report, e;
report = document.getElementById('report');
e = document.createElement('pre');
e.setAttribute('class', 'code');
setText(e, code);
report.appendChild(e);
total += 1;
}
function reportFailure(expected, actual) {
var report, e;
failures += 1;
report = document.getElementById('report');
e = document.createElement('p');
setText(e, 'Expected');
report.appendChild(e);
e = document.createElement('pre');
e.setAttribute('class', 'expected');
setText(e, expected);
report.appendChild(e);
e = document.createElement('p');
setText(e, 'Actual');
report.appendChild(e);
e = document.createElement('pre');
e.setAttribute('class', 'actual');
setText(e, actual);
report.appendChild(e);
}
setText(document.getElementById('version'), esprima.version);
window.setTimeout(function () {
var tick, context = getContext(esprima, reportCase, reportFailure);
tick = new Date();
testReflect(context.Reflect, context.Pattern);
tick = (new Date()) - tick;
if (failures > 0) {
document.getElementById('status').className = 'alert-box alert';
setText(document.getElementById('status'), total + ' tests. ' +
'Failures: ' + failures + '. ' + tick + ' ms');
} else {
document.getElementById('status').className = 'alert-box success';
setText(document.getElementById('status'), total + ' tests. ' +
'No failure. ' + tick + ' ms');
}
}, 11);
};
} else {
(function (global) {
'use strict';
var esprima = require('../esprima'),
tick,
total = 0,
failures = [],
header,
current,
context;
function reportCase(code) {
total += 1;
current = code;
}
function reportFailure(expected, actual) {
failures.push({
source: current,
expected: expected.toString(),
actual: actual.toString()
});
}
context = getContext(esprima, reportCase, reportFailure);
tick = new Date();
require('./reflect').testReflect(context.Reflect, context.Pattern);
tick = (new Date()) - tick;
header = total + ' tests. ' + failures.length + ' failures. ' +
tick + ' ms';
if (failures.length) {
console.error(header);
failures.forEach(function (failure) {
console.error(failure.source + ': Expected\n ' +
failure.expected.split('\n').join('\n ') +
'\nto match\n ' + failure.actual);
});
} else {
console.log(header);
}
process.exit(failures.length === 0 ? 0 : 1);
}(this));
}
/* vim: set sw=4 ts=4 et tw=80 : */

View File

@@ -0,0 +1,110 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima: Unit Tests</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../assets/style.css">
<link rel="stylesheet" href="../assets/foundation/foundation.min.css">
<style>iframe { border: solid 1px #ddd; }</style>
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="../index.html">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="../demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="../demo/parse.html">Online Parsing</a></li>
<li><a href="../demo/validate.html">Syntax Validator</a></li>
<li><a href="../demo/precedence.html">Operator Precedence</a></li>
<li><a href="../demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="../demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="../demo/rewrite.html">Source Rewrite</a></li>
<li><a href="../demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="../demo/highlight.html">Identifier Highlight</a></li>
<li><a href="../demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="../test/index.html">Unit Tests</a></li>
<li><a href="../test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="../test/compat.html">Compatibility Tests</a></li>
<li><a href="../test/compare.html">Speed Comparison</a></li>
<li><a href="../test/module.html">Module Loading</a></li>
<li><a href="../test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="../doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>Coverage Analysis</strong> ensures systematic exercise of the parser</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="twelve columns">
<p><strong>Note</strong>: This is not a live (in-browser) code coverage report.
The analysis is <a href="../doc/index.html#coverage"> offline</a>
(using <a href="https://github.com/yahoo/istanbul">Istanbul</a>).</p>
<iframe src="esprima.js.html" width="100%" height="800px"></iframe>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
<script src="../esprima.js"></script>
<script src="../assets/json2.js"></script>
<script src="test.js"></script>
<script src="runner.js"></script>
<script>
/*jslint browser: true */
window.onload = window.runTests;
</script>
</body>
</html>

11752
Skills/@be/be/node_modules/esprima-fb/test/esprima.js.html generated vendored Normal file

File diff suppressed because one or more lines are too long

3124
Skills/@be/be/node_modules/esprima-fb/test/fbtest.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

12518
Skills/@be/be/node_modules/esprima-fb/test/harmonytest.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

115
Skills/@be/be/node_modules/esprima-fb/test/index.html generated vendored Normal file
View File

@@ -0,0 +1,115 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima: Unit Tests</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../assets/style.css">
<link rel="stylesheet" href="../assets/foundation/foundation.min.css">
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="../index.html">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="../demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="../demo/parse.html">Online Parsing</a></li>
<li><a href="../demo/validate.html">Syntax Validator</a></li>
<li><a href="../demo/precedence.html">Operator Precedence</a></li>
<li><a href="../demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="../demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="../demo/rewrite.html">Source Rewrite</a></li>
<li><a href="../demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="../demo/highlight.html">Identifier Highlight</a></li>
<li><a href="../demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="../test/index.html">Unit Tests</a></li>
<li><a href="../test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="../test/compat.html">Compatibility Tests</a></li>
<li><a href="../test/compare.html">Speed Comparison</a></li>
<li><a href="../test/module.html">Module Loading</a></li>
<li><a href="../test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="../doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>Unit Tests</strong> ensures the correct implementation</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="eight columns">
<div id="report"></div>
</div>
<div class="four columns">
<div id="status" class="alert-box secondary">Please wait...</div>
<div class="panel">
<p>A software project is only as good as its QA workflow. This set of unit tests
makes sure that no regression is ever sneaked in.</p>
<p>Version being tested: <strong><span id="version"></span></strong>.</p>
</div>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
<script src="../esprima.js"></script>
<script src="../assets/json2.js"></script>
<script src="test.js"></script>
<script src="harmonytest.js"></script>
<script src="runner.js"></script>
<script>
/*jslint browser: true */
window.onload = window.runTests;
</script>
</body>
</html>

112
Skills/@be/be/node_modules/esprima-fb/test/module.html generated vendored Normal file
View File

@@ -0,0 +1,112 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima: Module Loading Test</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="../assets/style.css">
<link rel="stylesheet" href="../assets/foundation/foundation.min.css">
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="../index.html">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="../demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="../demo/parse.html">Online Parsing</a></li>
<li><a href="../demo/validate.html">Syntax Validator</a></li>
<li><a href="../demo/precedence.html">Operator Precedence</a></li>
<li><a href="../demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="../demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="../demo/rewrite.html">Source Rewrite</a></li>
<li><a href="../demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="../demo/highlight.html">Identifier Highlight</a></li>
<li><a href="../demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="../test/index.html">Unit Tests</a></li>
<li><a href="../test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="../test/compat.html">Compatibility Tests</a></li>
<li><a href="../test/compare.html">Speed Comparison</a></li>
<li><a href="../test/module.html">Module Loading</a></li>
<li><a href="../test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="../doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>Module Loading</strong> works also web browsers</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="eight columns">
<div id="report"></div>
</div>
<div class="four columns">
<div id="status" class="alert-box secondary">Please wait...</div>
<div class="panel">
<p>The following tests are to ensure that Esprima can be loaded using <a href="https://github.com/amdjs/amdjs-api/wiki/AMD">AMD</a> (Asynchronous Module Definition) loader such as <a href="http://requirejs.org">RequireJS</a>.</p>
</div>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
<script src="../esprima.js"></script>
<script src="../assets/json2.js"></script>
<script src="../assets/require.js"></script>
<script src="module.js"></script>
<script>
/*jslint browser: true */
window.onload = window.runTests;
</script>
</body>
</html>

131
Skills/@be/be/node_modules/esprima-fb/test/module.js generated vendored Normal file
View File

@@ -0,0 +1,131 @@
/*jslint browser:true plusplus:true */
/*global require:true */
function runTests() {
'use strict';
function setText(el, str) {
if (typeof el.innerText === 'string') {
el.innerText = str;
} else {
el.textContent = str;
}
}
function reportSuccess(code) {
var report, e;
report = document.getElementById('report');
e = document.createElement('pre');
e.setAttribute('class', 'code');
setText(e, code);
report.appendChild(e);
}
function reportFailure(code, expected, actual) {
var report, e;
report = document.getElementById('report');
e = document.createElement('pre');
e.setAttribute('class', 'code');
setText(e, code);
report.appendChild(e);
e = document.createElement('p');
setText(e, 'Expected type: ' + expected);
report.appendChild(e);
e = document.createElement('p');
setText(e, 'Actual type: ' + actual);
report.appendChild(e);
}
require(['../esprima'], function (ESParser) {
var tick, total, failures, obj, variable, variables, i, entry, entries;
// We check only the type of some members of ESParser.
variables = {
'version': 'string',
'parse': 'function',
'Syntax': 'object',
'Syntax.AssignmentExpression': 'string',
'Syntax.ArrayExpression': 'string',
'Syntax.BlockStatement': 'string',
'Syntax.BinaryExpression': 'string',
'Syntax.BreakStatement': 'string',
'Syntax.CallExpression': 'string',
'Syntax.CatchClause': 'string',
'Syntax.ConditionalExpression': 'string',
'Syntax.ContinueStatement': 'string',
'Syntax.DoWhileStatement': 'string',
'Syntax.DebuggerStatement': 'string',
'Syntax.EmptyStatement': 'string',
'Syntax.ExpressionStatement': 'string',
'Syntax.ForStatement': 'string',
'Syntax.ForInStatement': 'string',
'Syntax.FunctionDeclaration': 'string',
'Syntax.FunctionExpression': 'string',
'Syntax.Identifier': 'string',
'Syntax.IfStatement': 'string',
'Syntax.Literal': 'string',
'Syntax.LabeledStatement': 'string',
'Syntax.LogicalExpression': 'string',
'Syntax.MemberExpression': 'string',
'Syntax.NewExpression': 'string',
'Syntax.ObjectExpression': 'string',
'Syntax.Program': 'string',
'Syntax.Property': 'string',
'Syntax.ReturnStatement': 'string',
'Syntax.SequenceExpression': 'string',
'Syntax.SwitchStatement': 'string',
'Syntax.SwitchCase': 'string',
'Syntax.ThisExpression': 'string',
'Syntax.ThrowStatement': 'string',
'Syntax.TryStatement': 'string',
'Syntax.UnaryExpression': 'string',
'Syntax.UpdateExpression': 'string',
'Syntax.VariableDeclaration': 'string',
'Syntax.VariableDeclarator': 'string',
'Syntax.WhileStatement': 'string',
'Syntax.WithStatement': 'string'
};
total = failures = 0;
tick = new Date();
for (variable in variables) {
if (variables.hasOwnProperty(variable)) {
entries = variable.split('.');
obj = ESParser;
for (i = 0; i < entries.length; ++i) {
entry = entries[i];
if (typeof obj[entry] !== 'undefined') {
obj = obj[entry];
} else {
obj = undefined;
break;
}
}
total++;
if (typeof obj === variables[variable]) {
reportSuccess(variable);
} else {
failures++;
reportFailure(variable, variables[variable], typeof obj);
}
}
}
tick = (new Date()) - tick;
if (failures > 0) {
document.getElementById('status').className = 'alert-box alert';
setText(document.getElementById('status'), total + ' tests. ' +
'Failures: ' + failures + '. ' + tick + ' ms');
} else {
document.getElementById('status').className = 'alert-box success';
setText(document.getElementById('status'), total + ' tests. ' +
'No failure. ' + tick + ' ms');
}
});
}

421
Skills/@be/be/node_modules/esprima-fb/test/reflect.js generated vendored Normal file
View File

@@ -0,0 +1,421 @@
// This is modified from Mozilla Reflect.parse test suite (the file is located
// at js/src/tests/js1_8_5/extensions/reflect-parse.js in the source tree).
//
// Some notable changes:
// * Removed unsupported features (destructuring, let, comprehensions...).
// * Removed tests for E4X (ECMAScript for XML).
// * Removed everything related to builder.
// * Enclosed every 'Pattern' construct with a scope.
// * Removed the test for bug 632030 and bug 632024.
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*/
(function (exports) {
function testReflect(Reflect, Pattern) {
function program(elts) { return Pattern({ type: "Program", body: elts }) }
function exprStmt(expr) { return Pattern({ type: "ExpressionStatement", expression: expr }) }
function throwStmt(expr) { return Pattern({ type: "ThrowStatement", argument: expr }) }
function returnStmt(expr) { return Pattern({ type: "ReturnStatement", argument: expr }) }
function yieldExpr(expr) { return Pattern({ type: "YieldExpression", argument: expr }) }
function lit(val) { return Pattern({ type: "Literal", value: val }) }
var thisExpr = Pattern({ type: "ThisExpression" });
function funDecl(id, params, body) { return Pattern({ type: "FunctionDeclaration",
id: id,
params: params,
defaults: [],
body: body,
rest: null,
generator: false,
expression: false
}) }
function genFunDecl(id, params, body) { return Pattern({ type: "FunctionDeclaration",
id: id,
params: params,
defaults: [],
body: body,
rest: null,
generator: true,
expression: false
}) }
function declarator(id, init) { return Pattern({ type: "VariableDeclarator", id: id, init: init }) }
function varDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "var" }) }
function letDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "let" }) }
function constDecl(decls) { return Pattern({ type: "VariableDeclaration", declarations: decls, kind: "const" }) }
function ident(name) { return Pattern({ type: "Identifier", name: name }) }
function dotExpr(obj, id) { return Pattern({ type: "MemberExpression", computed: false, object: obj, property: id }) }
function memExpr(obj, id) { return Pattern({ type: "MemberExpression", computed: true, object: obj, property: id }) }
function forStmt(init, test, update, body) { return Pattern({ type: "ForStatement", init: init, test: test, update: update, body: body }) }
function forInStmt(lhs, rhs, body) { return Pattern({ type: "ForInStatement", left: lhs, right: rhs, body: body, each: false }) }
function forEachInStmt(lhs, rhs, body) { return Pattern({ type: "ForInStatement", left: lhs, right: rhs, body: body, each: true }) }
function breakStmt(lab) { return Pattern({ type: "BreakStatement", label: lab }) }
function continueStmt(lab) { return Pattern({ type: "ContinueStatement", label: lab }) }
function blockStmt(body) { return Pattern({ type: "BlockStatement", body: body }) }
var emptyStmt = Pattern({ type: "EmptyStatement" });
function ifStmt(test, cons, alt) { return Pattern({ type: "IfStatement", test: test, alternate: alt, consequent: cons }) }
function labStmt(lab, stmt) { return Pattern({ type: "LabeledStatement", label: lab, body: stmt }) }
function withStmt(obj, stmt) { return Pattern({ type: "WithStatement", object: obj, body: stmt }) }
function whileStmt(test, stmt) { return Pattern({ type: "WhileStatement", test: test, body: stmt }) }
function doStmt(stmt, test) { return Pattern({ type: "DoWhileStatement", test: test, body: stmt }) }
function switchStmt(disc, cases) { return Pattern({ type: "SwitchStatement", discriminant: disc, cases: cases }) }
function caseClause(test, stmts) { return Pattern({ type: "SwitchCase", test: test, consequent: stmts }) }
function defaultClause(stmts) { return Pattern({ type: "SwitchCase", test: null, consequent: stmts }) }
function catchClause(id, guard, body) { if (guard) { return Pattern({ type: "GuardedCatchClause", param: id, guard: guard, body: body }) } else { return Pattern({ type: "CatchClause", param: id, body: body }) } }
function tryStmt(body, guarded, catches, fin) { return Pattern({ type: "TryStatement", block: body, guardedHandlers: guarded, handlers: catches, finalizer: fin }) }
function letStmt(head, body) { return Pattern({ type: "LetStatement", head: head, body: body }) }
function funExpr(id, args, body, gen) { return Pattern({ type: "FunctionExpression",
id: id,
params: args,
defaults: [],
body: body,
rest: null,
generator: false,
expression: false
}) }
function genFunExpr(id, args, body) { return Pattern({ type: "FunctionExpression",
id: id,
params: args,
defaults: [],
body: body,
rest: null,
generator: true,
expression: false
}) }
function unExpr(op, arg) { return Pattern({ type: "UnaryExpression", operator: op, argument: arg }) }
function binExpr(op, left, right) { return Pattern({ type: "BinaryExpression", operator: op, left: left, right: right }) }
function aExpr(op, left, right) { return Pattern({ type: "AssignmentExpression", operator: op, left: left, right: right }) }
function updExpr(op, arg, prefix) { return Pattern({ type: "UpdateExpression", operator: op, argument: arg, prefix: prefix }) }
function logExpr(op, left, right) { return Pattern({ type: "LogicalExpression", operator: op, left: left, right: right }) }
function condExpr(test, cons, alt) { return Pattern({ type: "ConditionalExpression", test: test, consequent: cons, alternate: alt }) }
function seqExpr(exprs) { return Pattern({ type: "SequenceExpression", expressions: exprs }) }
function newExpr(callee, args) { return Pattern({ type: "NewExpression", callee: callee, arguments: args }) }
function callExpr(callee, args) { return Pattern({ type: "CallExpression", callee: callee, arguments: args }) }
function arrExpr(elts) { return Pattern({ type: "ArrayExpression", elements: elts }) }
function objExpr(elts) { return Pattern({ type: "ObjectExpression", properties: elts }) }
function objProp(key, value, kind) { return Pattern({ type: "Property", key: key, value: value, kind: kind, method: false, shorthand: false }) }
function arrPatt(elts) { return Pattern({ type: "ArrayPattern", elements: elts }) }
function objPatt(elts) { return Pattern({ type: "ObjectPattern", properties: elts }) }
function localSrc(src) { return "(function(){ " + src + " })" }
function localPatt(patt) { return program([exprStmt(funExpr(null, [], blockStmt([patt])))]) }
function blockSrc(src) { return "(function(){ { " + src + " } })" }
function blockPatt(patt) { return program([exprStmt(funExpr(null, [], blockStmt([blockStmt([patt])])))]) }
function assertBlockStmt(src, patt) {
blockPatt(patt).assert(Reflect.parse(blockSrc(src)));
}
function assertBlockExpr(src, patt) {
assertBlockStmt(src, exprStmt(patt));
}
function assertBlockDecl(src, patt, builder) {
blockPatt(patt).assert(Reflect.parse(blockSrc(src), {builder: builder}));
}
function assertLocalStmt(src, patt) {
localPatt(patt).assert(Reflect.parse(localSrc(src)));
}
function assertLocalExpr(src, patt) {
assertLocalStmt(src, exprStmt(patt));
}
function assertLocalDecl(src, patt) {
localPatt(patt).assert(Reflect.parse(localSrc(src)));
}
function assertGlobalStmt(src, patt, builder) {
program([patt]).assert(Reflect.parse(src, {builder: builder}));
}
function assertGlobalExpr(src, patt, builder) {
program([exprStmt(patt)]).assert(Reflect.parse(src, {builder: builder}));
//assertStmt(src, exprStmt(patt));
}
function assertGlobalDecl(src, patt) {
program([patt]).assert(Reflect.parse(src));
}
function assertProg(src, patt) {
program(patt).assert(Reflect.parse(src));
}
function assertStmt(src, patt) {
assertLocalStmt(src, patt);
assertGlobalStmt(src, patt);
assertBlockStmt(src, patt);
}
function assertExpr(src, patt) {
assertLocalExpr(src, patt);
assertGlobalExpr(src, patt);
assertBlockExpr(src, patt);
}
function assertDecl(src, patt) {
assertLocalDecl(src, patt);
assertGlobalDecl(src, patt);
assertBlockDecl(src, patt);
}
function assertError(src, errorType) {
try {
Reflect.parse(src);
} catch (e) {
return;
}
throw new Error("expected " + errorType.name + " for " + uneval(src));
}
// general tests
// NB: These are useful but for now jit-test doesn't do I/O reliably.
//program(_).assert(Reflect.parse(snarf('data/flapjax.txt')));
//program(_).assert(Reflect.parse(snarf('data/jquery-1.4.2.txt')));
//program(_).assert(Reflect.parse(snarf('data/prototype.js')));
//program(_).assert(Reflect.parse(snarf('data/dojo.js.uncompressed.js')));
//program(_).assert(Reflect.parse(snarf('data/mootools-1.2.4-core-nc.js')));
// declarations
assertDecl("var x = 1, y = 2, z = 3",
varDecl([declarator(ident("x"), lit(1)),
declarator(ident("y"), lit(2)),
declarator(ident("z"), lit(3))]));
assertDecl("var x, y, z",
varDecl([declarator(ident("x"), null),
declarator(ident("y"), null),
declarator(ident("z"), null)]));
assertDecl("function foo() { }",
funDecl(ident("foo"), [], blockStmt([])));
assertDecl("function foo() { return 42 }",
funDecl(ident("foo"), [], blockStmt([returnStmt(lit(42))])));
// Bug 591437: rebound args have their defs turned into uses
assertDecl("function f(a) { function a() { } }",
funDecl(ident("f"), [ident("a")], blockStmt([funDecl(ident("a"), [], blockStmt([]))])));
assertDecl("function f(a,b,c) { function b() { } }",
funDecl(ident("f"), [ident("a"),ident("b"),ident("c")], blockStmt([funDecl(ident("b"), [], blockStmt([]))])));
// expressions
assertExpr("true", lit(true));
assertExpr("false", lit(false));
assertExpr("42", lit(42));
assertExpr("(/asdf/)", lit(/asdf/));
assertExpr("this", thisExpr);
assertExpr("foo", ident("foo"));
assertExpr("foo.bar", dotExpr(ident("foo"), ident("bar")));
assertExpr("foo[bar]", memExpr(ident("foo"), ident("bar")));
assertExpr("(function(){})", funExpr(null, [], blockStmt([])));
assertExpr("(function f() {})", funExpr(ident("f"), [], blockStmt([])));
assertExpr("(function f(x,y,z) {})", funExpr(ident("f"), [ident("x"),ident("y"),ident("z")], blockStmt([])));
assertExpr("(++x)", updExpr("++", ident("x"), true));
assertExpr("(x++)", updExpr("++", ident("x"), false));
assertExpr("(+x)", unExpr("+", ident("x")));
assertExpr("(-x)", unExpr("-", ident("x")));
assertExpr("(!x)", unExpr("!", ident("x")));
assertExpr("(~x)", unExpr("~", ident("x")));
assertExpr("(delete x)", unExpr("delete", ident("x")));
assertExpr("(typeof x)", unExpr("typeof", ident("x")));
assertExpr("(void x)", unExpr("void", ident("x")));
assertExpr("(x == y)", binExpr("==", ident("x"), ident("y")));
assertExpr("(x != y)", binExpr("!=", ident("x"), ident("y")));
assertExpr("(x === y)", binExpr("===", ident("x"), ident("y")));
assertExpr("(x !== y)", binExpr("!==", ident("x"), ident("y")));
assertExpr("(x < y)", binExpr("<", ident("x"), ident("y")));
assertExpr("(x <= y)", binExpr("<=", ident("x"), ident("y")));
assertExpr("(x > y)", binExpr(">", ident("x"), ident("y")));
assertExpr("(x >= y)", binExpr(">=", ident("x"), ident("y")));
assertExpr("(x << y)", binExpr("<<", ident("x"), ident("y")));
assertExpr("(x >> y)", binExpr(">>", ident("x"), ident("y")));
assertExpr("(x >>> y)", binExpr(">>>", ident("x"), ident("y")));
assertExpr("(x + y)", binExpr("+", ident("x"), ident("y")));
assertExpr("(w + x + y + z)", binExpr("+", binExpr("+", binExpr("+", ident("w"), ident("x")), ident("y")), ident("z")));
assertExpr("(x - y)", binExpr("-", ident("x"), ident("y")));
assertExpr("(w - x - y - z)", binExpr("-", binExpr("-", binExpr("-", ident("w"), ident("x")), ident("y")), ident("z")));
assertExpr("(x * y)", binExpr("*", ident("x"), ident("y")));
assertExpr("(x / y)", binExpr("/", ident("x"), ident("y")));
assertExpr("(x % y)", binExpr("%", ident("x"), ident("y")));
assertExpr("(x | y)", binExpr("|", ident("x"), ident("y")));
assertExpr("(x ^ y)", binExpr("^", ident("x"), ident("y")));
assertExpr("(x & y)", binExpr("&", ident("x"), ident("y")));
assertExpr("(x in y)", binExpr("in", ident("x"), ident("y")));
assertExpr("(x instanceof y)", binExpr("instanceof", ident("x"), ident("y")));
assertExpr("(x = y)", aExpr("=", ident("x"), ident("y")));
assertExpr("(x += y)", aExpr("+=", ident("x"), ident("y")));
assertExpr("(x -= y)", aExpr("-=", ident("x"), ident("y")));
assertExpr("(x *= y)", aExpr("*=", ident("x"), ident("y")));
assertExpr("(x /= y)", aExpr("/=", ident("x"), ident("y")));
assertExpr("(x %= y)", aExpr("%=", ident("x"), ident("y")));
assertExpr("(x <<= y)", aExpr("<<=", ident("x"), ident("y")));
assertExpr("(x >>= y)", aExpr(">>=", ident("x"), ident("y")));
assertExpr("(x >>>= y)", aExpr(">>>=", ident("x"), ident("y")));
assertExpr("(x |= y)", aExpr("|=", ident("x"), ident("y")));
assertExpr("(x ^= y)", aExpr("^=", ident("x"), ident("y")));
assertExpr("(x &= y)", aExpr("&=", ident("x"), ident("y")));
assertExpr("(x || y)", logExpr("||", ident("x"), ident("y")));
assertExpr("(x && y)", logExpr("&&", ident("x"), ident("y")));
assertExpr("(w || x || y || z)", logExpr("||", logExpr("||", logExpr("||", ident("w"), ident("x")), ident("y")), ident("z")))
assertExpr("(x ? y : z)", condExpr(ident("x"), ident("y"), ident("z")));
assertExpr("(x,y)", seqExpr([ident("x"),ident("y")]))
assertExpr("(x,y,z)", seqExpr([ident("x"),ident("y"),ident("z")]))
assertExpr("(a,b,c,d,e,f,g)", seqExpr([ident("a"),ident("b"),ident("c"),ident("d"),ident("e"),ident("f"),ident("g")]));
assertExpr("(new Object)", newExpr(ident("Object"), []));
assertExpr("(new Object())", newExpr(ident("Object"), []));
assertExpr("(new Object(42))", newExpr(ident("Object"), [lit(42)]));
assertExpr("(new Object(1,2,3))", newExpr(ident("Object"), [lit(1),lit(2),lit(3)]));
assertExpr("(String())", callExpr(ident("String"), []));
assertExpr("(String(42))", callExpr(ident("String"), [lit(42)]));
assertExpr("(String(1,2,3))", callExpr(ident("String"), [lit(1),lit(2),lit(3)]));
assertExpr("[]", arrExpr([]));
assertExpr("[1]", arrExpr([lit(1)]));
assertExpr("[1,2]", arrExpr([lit(1),lit(2)]));
assertExpr("[1,2,3]", arrExpr([lit(1),lit(2),lit(3)]));
assertExpr("[1,,2,3]", arrExpr([lit(1),,lit(2),lit(3)]));
assertExpr("[1,,,2,3]", arrExpr([lit(1),,,lit(2),lit(3)]));
assertExpr("[1,,,2,,3]", arrExpr([lit(1),,,lit(2),,lit(3)]));
assertExpr("[1,,,2,,,3]", arrExpr([lit(1),,,lit(2),,,lit(3)]));
assertExpr("[,1,2,3]", arrExpr([,lit(1),lit(2),lit(3)]));
assertExpr("[,,1,2,3]", arrExpr([,,lit(1),lit(2),lit(3)]));
assertExpr("[,,,1,2,3]", arrExpr([,,,lit(1),lit(2),lit(3)]));
assertExpr("[,,,1,2,3,]", arrExpr([,,,lit(1),lit(2),lit(3)]));
assertExpr("[,,,1,2,3,,]", arrExpr([,,,lit(1),lit(2),lit(3),undefined]));
assertExpr("[,,,1,2,3,,,]", arrExpr([,,,lit(1),lit(2),lit(3),undefined,undefined]));
assertExpr("[,,,,,]", arrExpr([undefined,undefined,undefined,undefined,undefined]));
assertExpr("({})", objExpr([]));
assertExpr("({x:1})", objExpr([objProp(ident("x"), lit(1), "init")]));
assertExpr("({x:1, y:2})", objExpr([objProp(ident("x"), lit(1), "init"),
objProp(ident("y"), lit(2), "init")]));
assertExpr("({x:1, y:2, z:3})", objExpr([objProp(ident("x"), lit(1), "init"),
objProp(ident("y"), lit(2), "init"),
objProp(ident("z"), lit(3), "init") ]));
assertExpr("({x:1, 'y':2, z:3})", objExpr([objProp(ident("x"), lit(1), "init"),
objProp(lit("y"), lit(2), "init"),
objProp(ident("z"), lit(3), "init") ]));
assertExpr("({'x':1, 'y':2, z:3})", objExpr([objProp(lit("x"), lit(1), "init"),
objProp(lit("y"), lit(2), "init"),
objProp(ident("z"), lit(3), "init") ]));
assertExpr("({'x':1, 'y':2, 3:3})", objExpr([objProp(lit("x"), lit(1), "init"),
objProp(lit("y"), lit(2), "init"),
objProp(lit(3), lit(3), "init") ]));
// Bug 571617: eliminate constant-folding
assertExpr("2 + 3", binExpr("+", lit(2), lit(3)));
// Bug 632026: constant-folding
assertExpr("typeof(0?0:a)", unExpr("typeof", condExpr(lit(0), lit(0), ident("a"))));
// Bug 632056: constant-folding
program([exprStmt(ident("f")),
ifStmt(lit(1),
funDecl(ident("f"), [], blockStmt([])),
null)]).assert(Reflect.parse("f; if (1) function f(){}"));
// statements
assertStmt("throw 42", throwStmt(lit(42)));
assertStmt("for (;;) break", forStmt(null, null, null, breakStmt(null)));
assertStmt("for (x; y; z) break", forStmt(ident("x"), ident("y"), ident("z"), breakStmt(null)));
assertStmt("for (var x; y; z) break", forStmt(varDecl([declarator(ident("x"), null)]), ident("y"), ident("z"), breakStmt(null)));
assertStmt("for (var x = 42; y; z) break", forStmt(varDecl([declarator(ident("x"), lit(42))]), ident("y"), ident("z"), breakStmt(null)));
assertStmt("for (x; ; z) break", forStmt(ident("x"), null, ident("z"), breakStmt(null)));
assertStmt("for (var x; ; z) break", forStmt(varDecl([declarator(ident("x"), null)]), null, ident("z"), breakStmt(null)));
assertStmt("for (var x = 42; ; z) break", forStmt(varDecl([declarator(ident("x"), lit(42))]), null, ident("z"), breakStmt(null)));
assertStmt("for (x; y; ) break", forStmt(ident("x"), ident("y"), null, breakStmt(null)));
assertStmt("for (var x; y; ) break", forStmt(varDecl([declarator(ident("x"), null)]), ident("y"), null, breakStmt(null)));
assertStmt("for (var x = 42; y; ) break", forStmt(varDecl([declarator(ident("x"),lit(42))]), ident("y"), null, breakStmt(null)));
assertStmt("for (var x in y) break", forInStmt(varDecl([declarator(ident("x"),null)]), ident("y"), breakStmt(null)));
assertStmt("for (x in y) break", forInStmt(ident("x"), ident("y"), breakStmt(null)));
assertStmt("{ }", blockStmt([]));
assertStmt("{ throw 1; throw 2; throw 3; }", blockStmt([ throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]));
assertStmt(";", emptyStmt);
assertStmt("if (foo) throw 42;", ifStmt(ident("foo"), throwStmt(lit(42)), null));
assertStmt("if (foo) throw 42; else true;", ifStmt(ident("foo"), throwStmt(lit(42)), exprStmt(lit(true))));
assertStmt("if (foo) { throw 1; throw 2; throw 3; }",
ifStmt(ident("foo"),
blockStmt([throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]),
null));
assertStmt("if (foo) { throw 1; throw 2; throw 3; } else true;",
ifStmt(ident("foo"),
blockStmt([throwStmt(lit(1)), throwStmt(lit(2)), throwStmt(lit(3))]),
exprStmt(lit(true))));
assertStmt("foo: for(;;) break foo;", labStmt(ident("foo"), forStmt(null, null, null, breakStmt(ident("foo")))));
assertStmt("foo: for(;;) continue foo;", labStmt(ident("foo"), forStmt(null, null, null, continueStmt(ident("foo")))));
assertStmt("with (obj) { }", withStmt(ident("obj"), blockStmt([])));
assertStmt("with (obj) { obj; }", withStmt(ident("obj"), blockStmt([exprStmt(ident("obj"))])));
assertStmt("while (foo) { }", whileStmt(ident("foo"), blockStmt([])));
assertStmt("while (foo) { foo; }", whileStmt(ident("foo"), blockStmt([exprStmt(ident("foo"))])));
assertStmt("do { } while (foo);", doStmt(blockStmt([]), ident("foo")));
assertStmt("do { foo; } while (foo)", doStmt(blockStmt([exprStmt(ident("foo"))]), ident("foo")));
assertStmt("switch (foo) { case 1: 1; break; case 2: 2; break; default: 3; }",
switchStmt(ident("foo"),
[ caseClause(lit(1), [ exprStmt(lit(1)), breakStmt(null) ]),
caseClause(lit(2), [ exprStmt(lit(2)), breakStmt(null) ]),
defaultClause([ exprStmt(lit(3)) ]) ]));
assertStmt("switch (foo) { case 1: 1; break; case 2: 2; break; default: 3; case 42: 42; }",
switchStmt(ident("foo"),
[ caseClause(lit(1), [ exprStmt(lit(1)), breakStmt(null) ]),
caseClause(lit(2), [ exprStmt(lit(2)), breakStmt(null) ]),
defaultClause([ exprStmt(lit(3)) ]),
caseClause(lit(42), [ exprStmt(lit(42)) ]) ]));
assertStmt("try { } catch (e) { }",
tryStmt(blockStmt([]),
[],
[ catchClause(ident("e"), null, blockStmt([])) ],
null));
assertStmt("try { } catch (e) { } finally { }",
tryStmt(blockStmt([]),
[],
[ catchClause(ident("e"), null, blockStmt([])) ],
blockStmt([])));
assertStmt("try { } finally { }",
tryStmt(blockStmt([]),
[],
[],
blockStmt([])));
// redeclarations (TOK_NAME nodes with lexdef)
assertStmt("function f() { function g() { } function g() { } }",
funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])),
funDecl(ident("g"), [], blockStmt([]))])));
assertStmt("function f() { function g() { } function g() { return 42 } }",
funDecl(ident("f"), [], blockStmt([funDecl(ident("g"), [], blockStmt([])),
funDecl(ident("g"), [], blockStmt([returnStmt(lit(42))]))])));
assertStmt("function f() { var x = 42; var x = 43; }",
funDecl(ident("f"), [], blockStmt([varDecl([declarator(ident("x"),lit(42))]),
varDecl([declarator(ident("x"),lit(43))])])));
// getters and setters
assertExpr("({ get x() { return 42 } })",
objExpr([ objProp(ident("x"),
funExpr(null, [], blockStmt([returnStmt(lit(42))])),
"get" ) ]));
assertExpr("({ set x(v) { return 42 } })",
objExpr([ objProp(ident("x"),
funExpr(null, [ident("v")], blockStmt([returnStmt(lit(42))])),
"set" ) ]));
}
exports.testReflect = testReflect;
}(typeof exports === 'undefined' ? this : exports));

66
Skills/@be/be/node_modules/esprima-fb/test/run.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
/*
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint node:true */
(function () {
'use strict';
var child = require('child_process'),
nodejs = '"' + process.execPath + '"',
ret = 0,
suites,
index;
suites = [
'runner',
'compat'
];
function nextTest() {
var suite = suites[index];
if (index < suites.length) {
child.exec(nodejs + ' ./test/' + suite + '.js', function (err, stdout, stderr) {
if (stdout) {
process.stdout.write(suite + ': ' + stdout);
}
if (stderr) {
process.stderr.write(suite + ': ' + stderr);
}
if (err) {
ret = err.code;
}
index += 1;
nextTest();
});
} else {
process.exit(ret);
}
}
index = 0;
nextTest();
}());

445
Skills/@be/be/node_modules/esprima-fb/test/runner.js generated vendored Normal file
View File

@@ -0,0 +1,445 @@
/*
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2011 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2011 Arpad Borsos <arpad.borsos@googlemail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint browser:true node:true */
/*global esprima:true, testFixture:true */
var runTests;
// Special handling for regular expression literal since we need to
// convert it to a string literal, otherwise it will be decoded
// as object "{}" and the regular expression would be lost.
function adjustRegexLiteral(key, value) {
'use strict';
if (key === 'value' && value instanceof RegExp) {
value = value.toString();
}
return value;
}
function NotMatchingError(expected, actual) {
'use strict';
Error.call(this, 'Expected ');
this.expected = expected;
this.actual = actual;
}
NotMatchingError.prototype = new Error();
function errorToObject(e) {
'use strict';
var msg = e.toString();
// Opera 9.64 produces an non-standard string in toString().
if (msg.substr(0, 6) !== 'Error:') {
if (typeof e.message === 'string') {
msg = 'Error: ' + e.message;
}
}
return {
index: e.index,
lineNumber: e.lineNumber,
column: e.column,
message: msg
};
}
function testParse(esprima, code, syntax) {
'use strict';
var expected, tree, actual, options, StringObject, i, len, err;
// alias, so that JSLint does not complain.
StringObject = String;
options = {
comment: (typeof syntax.comments !== 'undefined'),
range: true,
loc: true,
tokens: (typeof syntax.tokens !== 'undefined'),
raw: true,
tolerant: (typeof syntax.errors !== 'undefined'),
source: null
};
if (typeof syntax.tokens !== 'undefined') {
if (syntax.tokens.length > 0) {
options.range = (typeof syntax.tokens[0].range !== 'undefined');
options.loc = (typeof syntax.tokens[0].loc !== 'undefined');
}
}
if (typeof syntax.comments !== 'undefined') {
if (syntax.comments.length > 0) {
options.range = (typeof syntax.comments[0].range !== 'undefined');
options.loc = (typeof syntax.comments[0].loc !== 'undefined');
}
}
if (options.loc) {
options.source = syntax.loc.source;
}
expected = JSON.stringify(syntax, null, 4);
try {
tree = esprima.parse(code, options);
tree = (options.comment || options.tokens || options.tolerant) ? tree : tree.body[0];
if (options.tolerant) {
for (i = 0, len = tree.errors.length; i < len; i += 1) {
tree.errors[i] = errorToObject(tree.errors[i]);
}
}
actual = JSON.stringify(tree, adjustRegexLiteral, 4);
// Only to ensure that there is no error when using string object.
esprima.parse(new StringObject(code), options);
} catch (e) {
throw new NotMatchingError(expected, e.toString());
}
if (expected !== actual) {
throw new NotMatchingError(expected, actual);
}
function filter(key, value) {
if (key === 'value' && value instanceof RegExp) {
value = value.toString();
}
return (key === 'loc' || key === 'range') ? undefined : value;
}
if (options.tolerant) {
return;
}
// Check again without any location info.
options.range = false;
options.loc = false;
expected = JSON.stringify(syntax, filter, 4);
try {
tree = esprima.parse(code, options);
tree = (options.comment || options.tokens) ? tree : tree.body[0];
if (options.tolerant) {
for (i = 0, len = tree.errors.length; i < len; i += 1) {
tree.errors[i] = errorToObject(tree.errors[i]);
}
}
actual = JSON.stringify(tree, filter, 4);
} catch (e) {
throw new NotMatchingError(expected, e.toString());
}
if (expected !== actual) {
throw new NotMatchingError(expected, actual);
}
}
function testTokenize(esprima, code, tokens) {
'use strict';
var options, expected, actual, tree;
options = {
comment: true,
tolerant: true,
loc: true,
range: true
};
expected = JSON.stringify(tokens, null, 4);
try {
tree = esprima.tokenize(code, options);
actual = JSON.stringify(tree, null, 4);
} catch (e) {
throw new NotMatchingError(expected, e.toString());
}
if (expected !== actual) {
throw new NotMatchingError(expected, actual);
}
}
function testError(esprima, code, exception) {
'use strict';
var i, options, expected, actual, err, handleInvalidRegexFlag, tokenize;
// Different parsing options should give the same error.
options = [
{},
{ comment: true },
{ raw: true },
{ raw: true, comment: true }
];
// If handleInvalidRegexFlag is true, an invalid flag in a regular expression
// will throw an exception. In some old version V8, this is not the case
// and hence handleInvalidRegexFlag is false.
handleInvalidRegexFlag = false;
try {
'test'.match(new RegExp('[a-z]', 'x'));
} catch (e) {
handleInvalidRegexFlag = true;
}
exception.description = exception.message.replace(/Error: Line [0-9]+: /, '');
if (exception.tokenize) {
tokenize = true;
exception.tokenize = undefined;
}
expected = JSON.stringify(exception);
for (i = 0; i < options.length; i += 1) {
try {
if (tokenize) {
esprima.tokenize(code, options[i])
} else {
esprima.parse(code, options[i]);
}
} catch (e) {
err = errorToObject(e);
err.description = e.description;
actual = JSON.stringify(err);
}
if (expected !== actual) {
// Compensate for old V8 which does not handle invalid flag.
if (exception.message.indexOf('Invalid regular expression') > 0) {
if (typeof actual === 'undefined' && !handleInvalidRegexFlag) {
return;
}
}
throw new NotMatchingError(expected, actual);
}
}
}
function testAPI(esprima, code, result) {
'use strict';
var expected, res, actual;
expected = JSON.stringify(result.result, null, 4);
try {
if (typeof result.property !== 'undefined') {
res = esprima[result.property];
} else {
res = esprima[result.call].apply(esprima, result.args);
}
actual = JSON.stringify(res, adjustRegexLiteral, 4);
} catch (e) {
throw new NotMatchingError(expected, e.toString());
}
if (expected !== actual) {
throw new NotMatchingError(expected, actual);
}
}
function runTest(esprima, code, result) {
'use strict';
if (result.hasOwnProperty('lineNumber')) {
testError(esprima, code, result);
} else if (result.hasOwnProperty('result')) {
testAPI(esprima, code, result);
} else if (result instanceof Array) {
testTokenize(esprima, code, result);
} else {
testParse(esprima, code, result);
}
}
if (typeof window !== 'undefined') {
// Run all tests in a browser environment.
runTests = function () {
'use strict';
var total = 0,
failures = 0,
category,
fixture,
source,
tick,
expected,
index,
len;
function setText(el, str) {
if (typeof el.innerText === 'string') {
el.innerText = str;
} else {
el.textContent = str;
}
}
function startCategory(category) {
var report, e;
report = document.getElementById('report');
e = document.createElement('h4');
setText(e, category);
report.appendChild(e);
}
function reportSuccess(code) {
var report, e;
report = document.getElementById('report');
e = document.createElement('pre');
e.setAttribute('class', 'code');
setText(e, code);
report.appendChild(e);
}
function reportFailure(code, expected, actual) {
var report, e;
report = document.getElementById('report');
e = document.createElement('p');
setText(e, 'Code:');
report.appendChild(e);
e = document.createElement('pre');
e.setAttribute('class', 'code');
setText(e, code);
report.appendChild(e);
e = document.createElement('p');
setText(e, 'Expected');
report.appendChild(e);
e = document.createElement('pre');
e.setAttribute('class', 'expected');
setText(e, expected);
report.appendChild(e);
e = document.createElement('p');
setText(e, 'Actual');
report.appendChild(e);
e = document.createElement('pre');
e.setAttribute('class', 'actual');
setText(e, actual);
report.appendChild(e);
}
setText(document.getElementById('version'), esprima.version);
tick = new Date();
for (category in testFixture) {
if (testFixture.hasOwnProperty(category)) {
startCategory(category);
fixture = testFixture[category];
for (source in fixture) {
if (fixture.hasOwnProperty(source)) {
expected = fixture[source];
total += 1;
try {
runTest(esprima, source, expected);
reportSuccess(source, JSON.stringify(expected, null, 4));
} catch (e) {
failures += 1;
reportFailure(source, e.expected, e.actual);
}
}
}
}
}
tick = (new Date()) - tick;
if (failures > 0) {
document.getElementById('status').className = 'alert-box alert';
setText(document.getElementById('status'), total + ' tests. ' +
'Failures: ' + failures + '. ' + tick + ' ms.');
} else {
document.getElementById('status').className = 'alert-box success';
setText(document.getElementById('status'), total + ' tests. ' +
'No failure. ' + tick + ' ms.');
}
};
} else {
(function () {
'use strict';
var esprima = require('../esprima'),
vm = require('vm'),
fs = require('fs'),
diff = require('json-diff').diffString,
total = 0,
failures = [],
tick = new Date(),
expected,
header;
vm.runInThisContext(fs.readFileSync(__dirname + '/test.js', 'utf-8'));
vm.runInThisContext(fs.readFileSync(__dirname + '/harmonytest.js', 'utf-8'));
vm.runInThisContext(fs.readFileSync(__dirname + '/fbtest.js', 'utf-8'));
Object.keys(testFixture).forEach(function (category) {
Object.keys(testFixture[category]).forEach(function (source) {
total += 1;
expected = testFixture[category][source];
try {
runTest(esprima, source, expected);
} catch (e) {
e.source = source;
failures.push(e);
}
});
});
tick = (new Date()) - tick;
header = total + ' tests. ' + failures.length + ' failures. ' +
tick + ' ms';
if (failures.length) {
console.error(header);
failures.forEach(function (failure) {
try {
var expectedObject = JSON.parse(failure.expected);
var actualObject = JSON.parse(failure.actual);
console.error(failure.source + ': Expected\n ' +
failure.expected.split('\n').join('\n ') +
'\nto match\n ' + failure.actual + '\nDiff:\n' +
diff(expectedObject, actualObject));
} catch (ex) {
console.error(failure.source + ': Expected\n ' +
failure.expected.split('\n').join('\n ') +
'\nto match\n ' + failure.actual);
}
});
} else {
console.log(header);
}
process.exit(failures.length === 0 ? 0 : 1);
}());
}

22331
Skills/@be/be/node_modules/esprima-fb/test/test.js generated vendored Normal file

File diff suppressed because it is too large Load Diff