forked from enviPath/enviPy
Current Dev State
This commit is contained in:
77
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/ChangeLog
generated
vendored
Normal file
77
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/ChangeLog
generated
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
2015-03-03: Version 1.2.5
|
||||
|
||||
* Fix scanning of implicit octal literals (issue 565)
|
||||
|
||||
2015-02-05: Version 1.2.4
|
||||
|
||||
* Fix parsing of LeftHandSideExpression in ForInStatement (issue 560)
|
||||
* Fix the handling of automatic semicolon insertion (issue 574)
|
||||
|
||||
2015-01-18: Version 1.2.3
|
||||
|
||||
* Fix division by this (issue 616)
|
||||
|
||||
2014-05-18: Version 1.2.2
|
||||
|
||||
* Fix duplicated tokens when collecting comments (issue 537)
|
||||
|
||||
2014-05-04: Version 1.2.1
|
||||
|
||||
* Ensure that Program node may still have leading comments (issue 536)
|
||||
|
||||
2014-04-29: Version 1.2.0
|
||||
|
||||
* Fix semicolon handling for expression statement (issue 462, 533)
|
||||
* Disallow escaped characters in regular expression flags (issue 503)
|
||||
* Performance improvement for location tracking (issue 520)
|
||||
* Improve the speed of comment attachment (issue 522)
|
||||
|
||||
2014-03-26: Version 1.1.1
|
||||
|
||||
* Fix token handling of forward slash after an array literal (issue 512)
|
||||
|
||||
2014-03-23: Version 1.1.0
|
||||
|
||||
* Optionally attach comments to the owning syntax nodes (issue 197)
|
||||
* Simplify binary parsing with stack-based shift reduce (issue 352)
|
||||
* Always include the raw source of literals (issue 376)
|
||||
* Add optional input source information (issue 386)
|
||||
* Tokenizer API for pure lexical scanning (issue 398)
|
||||
* Improve the web site and its online demos (issue 337, 400, 404)
|
||||
* Performance improvement for location tracking (issue 417, 424)
|
||||
* Support HTML comment syntax (issue 451)
|
||||
* Drop support for legacy browsers (issue 474)
|
||||
|
||||
2013-08-27: Version 1.0.4
|
||||
|
||||
* Minimize the payload for packages (issue 362)
|
||||
* Fix missing cases on an empty switch statement (issue 436)
|
||||
* Support escaped ] in regexp literal character classes (issue 442)
|
||||
* Tolerate invalid left-hand side expression (issue 130)
|
||||
|
||||
2013-05-17: Version 1.0.3
|
||||
|
||||
* Variable declaration needs at least one declarator (issue 391)
|
||||
* Fix benchmark's variance unit conversion (issue 397)
|
||||
* IE < 9: \v should be treated as vertical tab (issue 405)
|
||||
* Unary expressions should always have prefix: true (issue 418)
|
||||
* Catch clause should only accept an identifier (issue 423)
|
||||
* Tolerate setters without parameter (issue 426)
|
||||
|
||||
2012-11-02: Version 1.0.2
|
||||
|
||||
Improvement:
|
||||
|
||||
* Fix esvalidate JUnit output upon a syntax error (issue 374)
|
||||
|
||||
2012-10-28: Version 1.0.1
|
||||
|
||||
Improvements:
|
||||
|
||||
* esvalidate understands shebang in a Unix shell script (issue 361)
|
||||
* esvalidate treats fatal parsing failure as an error (issue 361)
|
||||
* Reduce Node.js package via .npmignore (issue 362)
|
||||
|
||||
2012-10-22: Version 1.0.0
|
||||
|
||||
Initial release.
|
||||
19
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/LICENSE.BSD
generated
vendored
Normal file
19
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/LICENSE.BSD
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
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.
|
||||
24
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/README.md
generated
vendored
Normal file
24
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/README.md
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
|
||||
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
|
||||
parser written in ECMAScript (also popularly known as
|
||||
[JavaScript](http://en.wikipedia.org/wiki/JavaScript>JavaScript)).
|
||||
Esprima is created and maintained by [Ariya Hidayat](http://twitter.com/ariyahidayat),
|
||||
with the help of [many contributors](https://github.com/ariya/esprima/contributors).
|
||||
|
||||
### Features
|
||||
|
||||
- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
|
||||
- Sensible [syntax tree format](http://esprima.org/doc/index.html#ast) compatible with Mozilla
|
||||
[Parser AST](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)
|
||||
- Optional tracking of syntax node location (index-based and line-column)
|
||||
- Heavily tested (> 650 [unit tests](http://esprima.org/test/) with [full code coverage](http://esprima.org/test/coverage.html))
|
||||
- [Partial support](http://esprima.org/doc/es6.html) for ECMAScript 6
|
||||
|
||||
Esprima serves as a **building block** for some JavaScript
|
||||
language tools, from [code instrumentation](http://esprima.org/demo/functiontrace.html)
|
||||
to [editor autocompletion](http://esprima.org/demo/autocomplete.html).
|
||||
|
||||
Esprima runs on many popular web browsers, as well as other ECMAScript platforms such as
|
||||
[Rhino](http://www.mozilla.org/rhino), [Nashorn](http://openjdk.java.net/projects/nashorn/), and [Node.js](https://npmjs.org/package/esprima).
|
||||
|
||||
For more information, check the web site [esprima.org](http://esprima.org).
|
||||
127
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/bin/esparse.js
generated
vendored
Executable file
127
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/bin/esparse.js
generated
vendored
Executable file
@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
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 sloppy:true node:true rhino:true */
|
||||
|
||||
var fs, esprima, fname, content, options, syntax;
|
||||
|
||||
if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
esprima = require('esprima');
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = { argv: arguments, exit: quit };
|
||||
process.argv.unshift('esparse.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esparse [options] file.js');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --comment Gather all line and block comments in an array');
|
||||
console.log(' --loc Include line-column location info for each syntax node');
|
||||
console.log(' --range Include index-based range for each syntax node');
|
||||
console.log(' --raw Display the raw value of literals');
|
||||
console.log(' --tokens List all tokens in an array');
|
||||
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
|
||||
console.log(' -v, --version Shows program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.argv.length <= 2) {
|
||||
showUsage();
|
||||
}
|
||||
|
||||
options = {};
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry === '--comment') {
|
||||
options.comment = true;
|
||||
} else if (entry === '--loc') {
|
||||
options.loc = true;
|
||||
} else if (entry === '--range') {
|
||||
options.range = true;
|
||||
} else if (entry === '--raw') {
|
||||
options.raw = true;
|
||||
} else if (entry === '--tokens') {
|
||||
options.tokens = true;
|
||||
} else if (entry === '--tolerant') {
|
||||
options.tolerant = true;
|
||||
} else if (entry.slice(0, 2) === '--') {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
} else if (typeof fname === 'string') {
|
||||
console.log('Error: more than one input file.');
|
||||
process.exit(1);
|
||||
} else {
|
||||
fname = entry;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof fname !== 'string') {
|
||||
console.log('Error: no input file.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
if (key === 'value' && value instanceof RegExp) {
|
||||
value = value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
content = fs.readFileSync(fname, 'utf-8');
|
||||
syntax = esprima.parse(content, options);
|
||||
console.log(JSON.stringify(syntax, adjustRegexLiteral, 4));
|
||||
} catch (e) {
|
||||
console.log('Error: ' + e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
199
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/bin/esvalidate.js
generated
vendored
Executable file
199
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/bin/esvalidate.js
generated
vendored
Executable file
@ -0,0 +1,199 @@
|
||||
#!/usr/bin/env node
|
||||
/*
|
||||
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 sloppy:true plusplus:true node:true rhino:true */
|
||||
/*global phantom:true */
|
||||
|
||||
var fs, system, esprima, options, fnames, count;
|
||||
|
||||
if (typeof esprima === 'undefined') {
|
||||
// PhantomJS can only require() relative files
|
||||
if (typeof phantom === 'object') {
|
||||
fs = require('fs');
|
||||
system = require('system');
|
||||
esprima = require('./esprima');
|
||||
} else if (typeof require === 'function') {
|
||||
fs = require('fs');
|
||||
esprima = require('esprima');
|
||||
} else if (typeof load === 'function') {
|
||||
try {
|
||||
load('esprima.js');
|
||||
} catch (e) {
|
||||
load('../esprima.js');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under PhantomJS 1.7+.
|
||||
if (typeof phantom === 'object') {
|
||||
fs.readFileSync = fs.read;
|
||||
process = {
|
||||
argv: [].slice.call(system.args),
|
||||
exit: phantom.exit
|
||||
};
|
||||
process.argv.unshift('phantomjs');
|
||||
}
|
||||
|
||||
// Shims to Node.js objects when running under Rhino.
|
||||
if (typeof console === 'undefined' && typeof process === 'undefined') {
|
||||
console = { log: print };
|
||||
fs = { readFileSync: readFile };
|
||||
process = { argv: arguments, exit: quit };
|
||||
process.argv.unshift('esvalidate.js');
|
||||
process.argv.unshift('rhino');
|
||||
}
|
||||
|
||||
function showUsage() {
|
||||
console.log('Usage:');
|
||||
console.log(' esvalidate [options] file.js');
|
||||
console.log();
|
||||
console.log('Available options:');
|
||||
console.log();
|
||||
console.log(' --format=type Set the report format, plain (default) or junit');
|
||||
console.log(' -v, --version Print program version');
|
||||
console.log();
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.argv.length <= 2) {
|
||||
showUsage();
|
||||
}
|
||||
|
||||
options = {
|
||||
format: 'plain'
|
||||
};
|
||||
|
||||
fnames = [];
|
||||
|
||||
process.argv.splice(2).forEach(function (entry) {
|
||||
|
||||
if (entry === '-h' || entry === '--help') {
|
||||
showUsage();
|
||||
} else if (entry === '-v' || entry === '--version') {
|
||||
console.log('ECMAScript Validator (using Esprima version', esprima.version, ')');
|
||||
console.log();
|
||||
process.exit(0);
|
||||
} else if (entry.slice(0, 9) === '--format=') {
|
||||
options.format = entry.slice(9);
|
||||
if (options.format !== 'plain' && options.format !== 'junit') {
|
||||
console.log('Error: unknown report format ' + options.format + '.');
|
||||
process.exit(1);
|
||||
}
|
||||
} else if (entry.slice(0, 2) === '--') {
|
||||
console.log('Error: unknown option ' + entry + '.');
|
||||
process.exit(1);
|
||||
} else {
|
||||
fnames.push(entry);
|
||||
}
|
||||
});
|
||||
|
||||
if (fnames.length === 0) {
|
||||
console.log('Error: no input file.');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (options.format === 'junit') {
|
||||
console.log('<?xml version="1.0" encoding="UTF-8"?>');
|
||||
console.log('<testsuites>');
|
||||
}
|
||||
|
||||
count = 0;
|
||||
fnames.forEach(function (fname) {
|
||||
var content, timestamp, syntax, name;
|
||||
try {
|
||||
content = fs.readFileSync(fname, 'utf-8');
|
||||
|
||||
if (content[0] === '#' && content[1] === '!') {
|
||||
content = '//' + content.substr(2, content.length);
|
||||
}
|
||||
|
||||
timestamp = Date.now();
|
||||
syntax = esprima.parse(content, { tolerant: true });
|
||||
|
||||
if (options.format === 'junit') {
|
||||
|
||||
name = fname;
|
||||
if (name.lastIndexOf('/') >= 0) {
|
||||
name = name.slice(name.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
console.log('<testsuite name="' + fname + '" errors="0" ' +
|
||||
' failures="' + syntax.errors.length + '" ' +
|
||||
' tests="' + syntax.errors.length + '" ' +
|
||||
' time="' + Math.round((Date.now() - timestamp) / 1000) +
|
||||
'">');
|
||||
|
||||
syntax.errors.forEach(function (error) {
|
||||
var msg = error.message;
|
||||
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||
console.log(' <testcase name="Line ' + error.lineNumber + ': ' + msg + '" ' +
|
||||
' time="0">');
|
||||
console.log(' <error type="SyntaxError" message="' + error.message + '">' +
|
||||
error.message + '(' + name + ':' + error.lineNumber + ')' +
|
||||
'</error>');
|
||||
console.log(' </testcase>');
|
||||
});
|
||||
|
||||
console.log('</testsuite>');
|
||||
|
||||
} else if (options.format === 'plain') {
|
||||
|
||||
syntax.errors.forEach(function (error) {
|
||||
var msg = error.message;
|
||||
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
|
||||
msg = fname + ':' + error.lineNumber + ': ' + msg;
|
||||
console.log(msg);
|
||||
++count;
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
++count;
|
||||
if (options.format === 'junit') {
|
||||
console.log('<testsuite name="' + fname + '" errors="1" failures="0" tests="1" ' +
|
||||
' time="' + Math.round((Date.now() - timestamp) / 1000) + '">');
|
||||
console.log(' <testcase name="' + e.message + '" ' + ' time="0">');
|
||||
console.log(' <error type="ParseError" message="' + e.message + '">' +
|
||||
e.message + '(' + fname + ((e.lineNumber) ? ':' + e.lineNumber : '') +
|
||||
')</error>');
|
||||
console.log(' </testcase>');
|
||||
console.log('</testsuite>');
|
||||
} else {
|
||||
console.log('Error: ' + e.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (options.format === 'junit') {
|
||||
console.log('</testsuites>');
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (count === 0 && typeof phantom === 'object') {
|
||||
process.exit(0);
|
||||
}
|
||||
3772
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/esprima.js
generated
vendored
Normal file
3772
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/esprima.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
107
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/package.json
generated
vendored
Normal file
107
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/package.json
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"_from": "esprima@^1.2.2",
|
||||
"_id": "esprima@1.2.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-CZNQL+r2aBODJXVvMPmlH+7sEek=",
|
||||
"_location": "/escodegen/esprima",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "esprima@^1.2.2",
|
||||
"name": "esprima",
|
||||
"escapedName": "esprima",
|
||||
"rawSpec": "^1.2.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/escodegen"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.5.tgz",
|
||||
"_shasum": "0993502feaf668138325756f30f9a51feeec11e9",
|
||||
"_spec": "esprima@^1.2.2",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/escodegen",
|
||||
"author": {
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com"
|
||||
},
|
||||
"bin": {
|
||||
"esparse": "./bin/esparse.js",
|
||||
"esvalidate": "./bin/esvalidate.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://issues.esprima.org"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
|
||||
"devDependencies": {
|
||||
"complexity-report": "~0.6.1",
|
||||
"eslint": "~0.4.3",
|
||||
"istanbul": "~0.2.6",
|
||||
"jscs": "~1.2.4",
|
||||
"jslint": "~0.1.9",
|
||||
"json-diff": "~0.3.1",
|
||||
"optimist": "~0.6.0",
|
||||
"regenerate": "~0.5.4",
|
||||
"unicode-6.3.0": "~0.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"test/run.js",
|
||||
"test/runner.js",
|
||||
"test/test.js",
|
||||
"test/compat.js",
|
||||
"test/reflect.js",
|
||||
"esprima.js"
|
||||
],
|
||||
"homepage": "http://esprima.org",
|
||||
"keywords": [
|
||||
"ast",
|
||||
"ecmascript",
|
||||
"javascript",
|
||||
"parser",
|
||||
"syntax"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/ariya/esprima/raw/master/LICENSE.BSD"
|
||||
}
|
||||
],
|
||||
"main": "esprima.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Ariya Hidayat",
|
||||
"email": "ariya.hidayat@gmail.com",
|
||||
"url": "http://ariya.ofilabs.com"
|
||||
}
|
||||
],
|
||||
"name": "esprima",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/ariya/esprima.git"
|
||||
},
|
||||
"scripts": {
|
||||
"analyze-complexity": "node tools/list-complexity.js",
|
||||
"analyze-coverage": "node node_modules/istanbul/lib/cli.js cover test/runner.js",
|
||||
"benchmark": "node test/benchmarks.js",
|
||||
"benchmark-quick": "node test/benchmarks.js quick",
|
||||
"check-complexity": "node node_modules/complexity-report/src/cli.js --maxcc 14 --silent -l -w esprima.js",
|
||||
"check-coverage": "node node_modules/istanbul/lib/cli.js check-coverage --statement 100 --branch 100 --function 100",
|
||||
"check-version": "node tools/check-version.js",
|
||||
"complexity": "npm run-script analyze-complexity && npm run-script check-complexity",
|
||||
"coverage": "npm run-script analyze-coverage && npm run-script check-coverage",
|
||||
"eslint": "node node_modules/eslint/bin/eslint.js esprima.js",
|
||||
"generate-regex": "node tools/generate-identifier-regex.js",
|
||||
"jscs": "node node_modules/jscs/bin/jscs esprima.js",
|
||||
"jslint": "echo Skipping JSLint",
|
||||
"lint": "npm run-script check-version && npm run-script eslint && npm run-script jscs && npm run-script jslint",
|
||||
"test": "npm run-script lint && node test/run.js && npm run-script coverage && npm run-script complexity"
|
||||
},
|
||||
"version": "1.2.5"
|
||||
}
|
||||
241
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/compat.js
generated
vendored
Normal file
241
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/compat.js
generated
vendored
Normal 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 : */
|
||||
422
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/reflect.js
generated
vendored
Normal file
422
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/reflect.js
generated
vendored
Normal file
@ -0,0 +1,422 @@
|
||||
// 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.
|
||||
// * Tweaked some expected tree to remove generator field.
|
||||
// * 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: false,
|
||||
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: false,
|
||||
expression: false
|
||||
}) }
|
||||
|
||||
function unExpr(op, arg) { return Pattern({ type: "UnaryExpression", operator: op, argument: arg, prefix: true }) }
|
||||
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 }) }
|
||||
|
||||
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));
|
||||
67
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/run.js
generated
vendored
Normal file
67
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/run.js
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
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',
|
||||
'parselibs'
|
||||
];
|
||||
|
||||
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();
|
||||
}());
|
||||
495
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/runner.js
generated
vendored
Normal file
495
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/runner.js
generated
vendored
Normal file
@ -0,0 +1,495 @@
|
||||
/*
|
||||
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 sortedObject(o) {
|
||||
if (o === null) {
|
||||
return o;
|
||||
}
|
||||
if (o instanceof Array) {
|
||||
return o.map(sortedObject);
|
||||
}
|
||||
if (typeof o !== 'object') {
|
||||
return o;
|
||||
}
|
||||
if (o instanceof RegExp) {
|
||||
return o;
|
||||
}
|
||||
var keys = Object.keys(o);
|
||||
var result = {
|
||||
range: undefined,
|
||||
loc: undefined
|
||||
};
|
||||
keys.forEach(function (key) {
|
||||
if (o.hasOwnProperty(key)){
|
||||
result[key] = sortedObject(o[key]);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function hasAttachedComment(syntax) {
|
||||
var key;
|
||||
for (key in syntax) {
|
||||
if (key === 'leadingComments' || key === 'trailingComments') {
|
||||
return true;
|
||||
}
|
||||
if (typeof syntax[key] === 'object' && syntax[key] !== null) {
|
||||
if (hasAttachedComment(syntax[key])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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 (options.comment) {
|
||||
options.attachComment = hasAttachedComment(syntax);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
syntax = sortedObject(syntax);
|
||||
expected = JSON.stringify(syntax, null, 4);
|
||||
try {
|
||||
// Some variations of the options.
|
||||
tree = esprima.parse(code, { tolerant: options.tolerant });
|
||||
tree = esprima.parse(code, { tolerant: options.tolerant, range: true });
|
||||
tree = esprima.parse(code, { tolerant: options.tolerant, loc: true });
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
tree = sortedObject(tree);
|
||||
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;
|
||||
syntax = sortedObject(syntax);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
tree = sortedObject(tree);
|
||||
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'));
|
||||
|
||||
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);
|
||||
}());
|
||||
}
|
||||
25593
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/test.js
generated
vendored
Normal file
25593
static/js/ketcher2/node_modules/escodegen/node_modules/esprima/test/test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user