Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

2
static/js/ketcher2/node_modules/tap/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,2 @@
Please see [the tap website](http://www.node-tap.org/changelog/) for
the curated changelog.

15
static/js/ketcher2/node_modules/tap/LICENSE generated vendored Normal file
View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

156
static/js/ketcher2/node_modules/tap/README.md generated vendored Normal file
View File

@ -0,0 +1,156 @@
# node-tap
A <abbr title="Test Anything Protocol">TAP</abbr> test framework for
Node.js.
[![Build Status](https://travis-ci.org/tapjs/node-tap.svg?branch=master)](https://travis-ci.org/tapjs/node-tap) [![Build Status](https://ci.appveyor.com/api/projects/status/913p1ypf21gf4leu?svg=true)](https://ci.appveyor.com/project/isaacs/node-tap) [![Coverage Status](https://coveralls.io/repos/tapjs/node-tap/badge.svg?branch=master&service=github)](https://coveralls.io/github/tapjs/node-tap?branch=master)
_Just wanna see some code? [Get started!](http://www.node-tap.org/basics/)_
It includes a command line test runner for consuming TAP-generating
test scripts, and a JavaScript framework for writing such scripts.
* [Getting started guide](http://www.node-tap.org/basics/)
* Built-in [test coverage](http://www.node-tap.org/coverage/)
* Many [reporter formats](http://www.node-tap.org/reporting/)
* Extensive [API](http://www.node-tap.org/api/) featuring:
* Great [promise support](http://www.node-tap.org/promises/)
* Comprehensive [assert library](http://www.node-tap.org/asserts/)
* Other [advanced stuff](http://www.node-tap.org/advanced/)
* Mocha-like [BDD DSL](http://www.node-tap.org/mochalike/)
* [Parallel Testing](http://www.node-tap.org/parallel/)
* [Command-line interface](http://www.node-tap.org/cli/) for running
tests (whether they use node-tap or not)
See [the changelog](http://www.node-tap.org/changelog/) for recent updates, or just get
started with [the basics](http://www.node-tap.org/basics/).
All this is too much to manage in a single README file, so head over
to [the website](http://www.node-tap.org/) to learn more.
## Why TAP?
Why should you use this thing!? **LET ME TELL YOU!**
Just kidding.
Most frameworks spend a lot of their documentation telling you why
they're the greatest. I'm not going to do that.
### <i lang="it">tutti i gusti, sono gusti</i>
Software testing is a software and user experience design challenge
that balances on the intersection of many conflicting demands.
Node-tap is based on [my](http://izs.me) opinions about how a test
framework should work, and what it should let you do. I do _not_ have
any opinion about whether or not you share those opinions. If you do
share them, you will probably enjoy this test library.
1. **Test files should be "normal" programs that can be run
directly.**
That means that it can't require a special runner that
puts magic functions into a global space. `node test.js` is a
perfectly ok way to run a test, and it ought to function
exactly the same as when it's run by the fancy runner with
reporting and such. JavaScript tests should be JavaScript
programs; not english-language poems with weird punctuation.
2. **Test output should be connected to the structure of the
test file that is easy to determine.**
That means not unnecessarily deferring test functions
until `nextTick`, because that would shift the order of
`console.log` output. Synchronous tests should be synchronous.
3. **Test files should be run in separate processes.**
That means that it can't use `require()` to load test files. Doing
`node ./test.js` must be the exact same sort of environment for the
test as doing `test-runner ./test.js`. Doing `node test/1.js; node
test/2.js` should be equivalent (from the test's point of view) to
doing `test-runner test/*.js`. This prevents tests from becoming
implicitly dependent on one anothers' globals.
4. **Assertions should not normally throw (but throws MUST be handled
nicely).**
I frequently write programs that have many hundreds of
assertions based on some list of test cases. If the first failure
throws, then I don't know if I've failed 100 tests or 1, without
wrapping everything in a try-catch. Furthermore, I usually want to
see some kind of output or reporting to verify that each one
actually ran.
Basically, it should be your decision whether you want to throw or
not. The test framework shouldn't force that on you, and should
make either case easy.
5. **Test reporting should be separate from the test process, included
in the framework, and enabled by default for humans.**
The [raw test output](http://www.node-tap.org/tap-format/) should
be machine-parseable and human-intelligible, and a separate process
should consume test output and turn it into a [pretty summarized
report](http://www.node-tap.org/reporting/). This means that test
data can be stored and parsed later, dug into for additional
details, and so on. Also: nyan cat.
6. **Writing tests should be easy, maybe even fun.**
The lower the barrier to entry for writing new tests, the more
tests get written. That means that there should be a relatively
small vocabulary of actions that I need to remember as a test
author. There is no benefit to having a distinction between a
"suite" and a "subtest". Fancy DSLs are pretty, but more to
remember.
That being said, if the you returns a Promise, or use a DSL that
throws a decorated error, then the test framework should Just Work
in a way that helps a human being understand the situation.
7. **Tests should output enough data to diagnose a failure, and no
more or less.**
Stack traces pointing at JS internals or the guts of the test
framework itself are not helpful. A test framework is a serious UX
challenge, and should be treated with care.
8. **Test coverage should be included.**
Running tests with coverage changes the way that you think about
your programs, and provides much deeper insight. Node-tap bundles
[nyc](https://istanbul.js.org/) for this.
It's not enabled by default only because it _does_ necessarily
change the nature of the environment a little bit. But I strongly
encourage [enabling coverage](http://www.node-tap.org/coverage/).
9. **Tests should be output in a predictable order.**
Even if they are run in parallel, the test _output_ should be
consistent.
As of version 10, tap supports [parallel
tests](http://www.node-tap.org/parallel/), which
can make your tests run significantly faster if they are I/O bound
or if you have multiple cores on your machine. However, even when
run in parallel, the output is still serialized.
10. **Tests should not require more building than your code.**
Babel and Webpack are lovely and fine. But if your code doesn't
require compilation, then I think your tests shouldn't either.
Tap is extremely
[promise-aware](http://www.node-tap.org/promises/), but works on
any version of Node.js back to v0.10.
Software testing should help you build software. It should be a
security blanket and a quality ratchet, giving you the support to
undertake massive refactoring and fix bugs without worrying. It
shouldn't be a purification rite or a hazing ritual.
There are many opinions left off of this list! Reasonable people can
disagree. But if you find yourself nodding along, [maybe tap is for
you](http://www.node-tap.org/basics/).

14
static/js/ketcher2/node_modules/tap/bin/mochatap.js generated vendored Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env node
var tap = require('../lib/tap.js')
var args = process.argv.slice(2)
if (args.length === 1) {
var path = require('path')
var file = path.resolve(args[0])
tap.mochaGlobals()
require(file)
} else {
for (var i = 0; i < args.length; i++) {
tap.spawn(process.execPath, [__filename, args[i]])
}
}

809
static/js/ketcher2/node_modules/tap/bin/run.js generated vendored Executable file
View File

@ -0,0 +1,809 @@
#!/usr/bin/env node
var node = process.execPath
var fs = require('fs')
var spawn = require('child_process').spawn
var fg = require('foreground-child')
var opener = require('opener')
var colorSupport = require('color-support')
var nycBin = require.resolve('nyc/bin/nyc.js')
var glob = require('glob')
var isexe = require('isexe')
var osHomedir = require('os-homedir')
var yaml = require('js-yaml')
var path = require('path')
var exists = require('fs-exists-cached').sync
var os = require('os');
var coverageServiceTest = process.env.COVERAGE_SERVICE_TEST === 'true'
// NYC will not wrap a module in node_modules.
// So, we need to tell the child proc when it's been added.
if (process.env._TAP_COVERAGE_ === '1')
global.__coverage__ = global.__coverage__ || {}
// console.error(process.argv.join(' '))
// console.error('CST=%j', process.env.COVERAGE_SERVICE_TEST)
// console.error('CRT=%j', process.env.COVERALLS_REPO_TOKEN)
if (coverageServiceTest)
console.log('COVERAGE_SERVICE_TEST')
// Add new coverage services here.
// it'll check for the environ named and pipe appropriately.
//
// Currently only Coveralls is supported, but the infrastructure
// is left in place in case some noble soul fixes the codecov
// module in the future. See https://github.com/tapjs/node-tap/issues/270
var coverageServices = [
{
env: 'COVERALLS_REPO_TOKEN',
bin: require.resolve('coveralls/bin/coveralls.js'),
name: 'Coveralls'
}
]
main()
function main () {
var args = process.argv.slice(2)
if (!args.length && process.stdin.isTTY) {
console.error(usage())
process.exit(1)
}
// set default args
var defaults = constructDefaultArgs()
// parse dotfile
var rcFile = process.env.TAP_RCFILE || (osHomedir() + '/.taprc')
var rcOptions = parseRcFile(rcFile)
// supplement defaults with parsed rc options
if (rcOptions)
Object.keys(rcOptions).forEach(function (k) {
defaults[k] = rcOptions[k]
})
defaults.rcFile = rcFile
// parse args
var options = parseArgs(args, defaults)
if (!options)
return
process.stdout.on('error', function (er) {
if (er.code === 'EPIPE')
process.exit()
else
throw er
})
options.files = globFiles(options.files)
if ((options.coverageReport || options.checkCoverage) &&
options.files.length === 0)
return runCoverageReport(options)
if (options.files.length === 0) {
console.error('Reading TAP data from stdin (use "-" argument to suppress)')
options.files.push('-')
}
if (options.files.length === 1 && options.files[0] === '-') {
if (options.coverage)
console.error('Coverage disabled because stdin cannot be instrumented')
stdinOnly(options)
return
}
// By definition, the next block cannot be covered, because
// they are only relevant when coverage is turned off.
/* istanbul ignore if */
if (options.coverage && !global.__coverage__)
return respawnWithCoverage(options)
setupTapEnv(options)
runTests(options)
}
function constructDefaultArgs () {
var defaultTimeout = 30
if (global.__coverage__)
defaultTimeout = 240
var defaultArgs = {
nodeArgs: [],
nycArgs: [],
testArgs: [],
timeout: +process.env.TAP_TIMEOUT || defaultTimeout,
color: !!colorSupport.level,
reporter: null,
files: [],
grep: [],
grepInvert: false,
bail: false,
saveFile: null,
pipeToService: false,
coverageReport: null,
browser: true,
coverage: undefined,
checkCoverage: false,
branches: 0,
functions: 0,
lines: 0,
statements: 0,
jobs: 1,
outputFile: null
}
if (process.env.TAP_COLORS !== undefined)
defaultArgs.color = !!(+process.env.TAP_COLORS)
return defaultArgs
}
function parseArgs (args, defaults) {
var options = defaults || {}
var singleFlags = {
b: 'bail',
B: 'no-bail',
i: 'invert',
I: 'no-invert',
c: 'color',
C: 'no-color',
T: 'no-timeout',
J: 'jobs-auto',
O: 'only',
h: 'help',
'?': 'help',
v: 'version'
}
var singleOpts = {
j: 'jobs',
g: 'grep',
R: 'reporter',
t: 'timeout',
s: 'save',
o: 'output-file'
}
// If we're running under Travis-CI with a Coveralls.io token,
// then it's a safe bet that we ought to output coverage.
for (var i = 0; i < coverageServices.length && !options.pipeToService; i++) {
if (process.env[coverageServices[i].env])
options.pipeToService = true
}
var defaultCoverage = options.pipeToService
var dumpConfig = false
for (i = 0; i < args.length; i++) {
var arg = args[i]
if (arg.charAt(0) !== '-' || arg === '-') {
options.files.push(arg)
continue
}
// short-flags
if (arg.charAt(1) !== '-' && arg !== '-gc') {
var expand = []
for (var f = 1; f < arg.length; f++) {
var fc = arg.charAt(f)
var sf = singleFlags[fc]
var so = singleOpts[fc]
if (sf)
expand.push('--' + sf)
else if (so) {
var soval = arg.slice(f + 1)
if (soval.charAt(0) !== '=') {
soval = '=' + soval
}
expand.push('--' + so + soval)
f = arg.length
} else if (arg !== '-' + fc)
expand.push('-' + fc)
}
if (expand.length) {
args.splice.apply(args, [i, 1].concat(expand))
i--
continue
}
}
var key = arg
var val = null
if (key.match(/^--/) && arg.indexOf('=') !== -1) {
var kv = arg.split('=')
key = kv.shift()
val = kv.join('=')
}
switch (key) {
case '--help':
console.log(usage())
return null
case '--dump-config':
dumpConfig = true
continue
case '--nyc-help':
nycHelp()
return null
case '--nyc-version':
nycVersion()
return null
case '--version':
console.log(require('../package.json').version)
return null
case '--jobs':
val = val || args[++i]
options.jobs = +val
continue
case '--jobs-auto':
val = os.cpus().length;
options.jobs = +val
continue
case '--coverage-report':
options.coverageReport = val || args[++i]
if (options.coverageReport === 'html')
options.coverageReport = 'lcov'
defaultCoverage = true
continue
case '--no-browser':
options.browser = false
continue
case '--no-coverage-report':
options.coverageReport = false
continue
case '--no-cov': case '--no-coverage':
options.coverage = false
continue
case '--cov': case '--coverage':
options.coverage = true
continue
case '--save':
val = val || args[++i]
options.saveFile = val
continue
case '--reporter':
val = val || args[++i]
options.reporter = val
continue
case '--gc': case '-gc': case '--expose-gc':
options.nodeArgs.push('--expose-gc')
continue
case '--strict':
options.nodeArgs.push('--use_strict')
continue
case '--debug':
options.nodeArgs.push('--debug')
continue
case '--debug-brk':
options.nodeArgs.push('--debug-brk')
continue
case '--harmony':
options.nodeArgs.push('--harmony')
continue
case '--node-arg':
val = val || args[++i]
if (val !== undefined)
options.nodeArgs.push(val)
continue
case '--check-coverage':
defaultCoverage = true
options.checkCoverage = true
continue
case '--test-arg':
val = val || args[++i]
if (val !== undefined)
options.testArgs.push(val)
continue
case '--nyc-arg':
val = val || args[++i]
if (val !== undefined)
options.nycArgs.push(val)
continue
case '--100':
defaultCoverage = true
options.checkCoverage = true
options.branches = 100
options.functions = 100
options.lines = 100
options.statements = 100
continue
case '--branches':
case '--functions':
case '--lines':
case '--statements':
defaultCoverage = true
val = val || args[++i]
options.checkCoverage = true
options[key.slice(2)] = val
continue
case '--color':
options.color = true
continue
case '--no-color':
options.color = false
continue
case '--output-file':
val = val || args[++i]
if (val !== undefined)
options.outputFile = val
continue
case '--no-timeout':
options.timeout = 0
continue
case '--timeout':
val = val || args[++i]
options.timeout = +val
continue
case '--invert':
options.grepInvert = true
continue
case '--no-invert':
options.grepInvert = false
continue
case '--grep':
val = val || args[++i]
if (val !== undefined)
options.grep.push(strToRegExp(val))
continue
case '--bail':
options.bail = true
continue
case '--no-bail':
options.bail = false
continue
case '--only':
options.only = true
continue
case '--':
options.files = options.files.concat(args.slice(i + 1))
i = args.length
continue
default:
throw new Error('Unknown argument: ' + arg)
}
}
if (options.coverage === undefined)
options.coverage = defaultCoverage
if (process.env.TAP === '1')
options.reporter = 'tap'
// default to tap for non-tty envs
if (!options.reporter)
options.reporter = options.color ? 'classic' : 'tap'
if (dumpConfig)
return console.log(JSON.stringify(options, null, 2))
return options
}
/* istanbul ignore next */
function respawnWithCoverage (options) {
// console.error('respawn with coverage')
// Re-spawn with coverage
var args = [nycBin].concat(
'--silent',
'--cache=true',
options.nycArgs,
'--',
process.execArgv,
process.argv.slice(1)
)
process.env._TAP_COVERAGE_ = '1'
var child = fg(node, args)
child.removeAllListeners('close')
child.on('close', function (code, signal) {
runCoverageReport(options, code, signal)
})
}
function pipeToCoverageServices (options, child) {
// console.error('pipe to services')
var piped = false
for (var i = 0; i < coverageServices.length; i++) {
// console.error('pipe to service?', coverageServices[i].env)
if (process.env[coverageServices[i].env]) {
pipeToCoverageService(coverageServices[i], options, child)
piped = true
}
}
/* istanbul ignore if */
if (!piped)
throw new Error('unknown service, internal error')
}
function pipeToCoverageService (service, options, child) {
// console.error('pipe to service yes', service.env)
var bin = service.bin
if (coverageServiceTest) {
// console.error('use fakey test bin')
// test scaffolding.
// don't actually send stuff to the service
bin = require.resolve('../test/fixtures/cat.js')
console.log('%s:%s', service.name, process.env[service.env])
}
var ca = spawn(node, [bin], {
stdio: [ 'pipe', 1, 2 ]
})
child.stdout.pipe(ca.stdin)
ca.on('close', function (code, signal) {
if (signal)
process.kill(process.pid, signal)
else if (code)
console.log('Error piping coverage to ' + service.name)
else
console.log('Successfully piped to ' + service.name)
})
}
function runCoverageReport (options, code, signal) {
if (options.checkCoverage)
runCoverageCheck(options, code, signal)
else
runCoverageReportOnly(options, code, signal)
}
function runCoverageReportOnly (options, code, signal) {
if (options.coverageReport === false)
return close(code, signal)
if (!options.coverageReport) {
if (options.pipeToService || coverageServiceTest)
options.coverageReport = 'text-lcov'
else
options.coverageReport = 'text'
}
var args = [nycBin, 'report', '--reporter', options.coverageReport]
// console.error('run coverage report', args)
var child
// automatically hook into coveralls
if (options.coverageReport === 'text-lcov' && options.pipeToService) {
// console.error('pipeToService')
child = spawn(node, args, { stdio: [ 0, 'pipe', 2 ] })
pipeToCoverageServices(options, child)
} else {
// otherwise just run the reporter
child = fg(node, args)
if (options.coverageReport === 'lcov' && options.browser)
child.on('exit', function () {
opener('coverage/lcov-report/index.html')
})
}
if (code || signal) {
child.removeAllListeners('close')
child.on('close', close)
}
function close (c, s) {
if (signal || s) {
setTimeout(function () {}, 200)
return process.kill(process.pid, signal || s)
}
if (code || c)
return process.exit(code || c)
}
}
function coverageCheckArgs (options) {
var args = []
if (options.branches)
args.push('--branches', options.branches)
if (options.functions)
args.push('--functions', options.functions)
if (options.lines)
args.push('--lines', options.lines)
if (options.statements)
args.push('--statements', options.statements)
return args
}
function runCoverageCheck (options, code, signal) {
var args = [nycBin, 'check-coverage'].concat(coverageCheckArgs(options))
var child = fg(node, args)
child.removeAllListeners('close')
child.on('close', function (c, s) {
runCoverageReportOnly(options, code || c, signal || s)
})
}
function usage () {
return fs.readFileSync(__dirname + '/usage.txt', 'utf8')
.split('@@REPORTERS@@')
.join(getReporters())
}
function nycHelp () {
fg(node, [nycBin, '--help'])
}
function nycVersion () {
console.log(require('nyc/package.json').version)
}
function getReporters () {
var types = require('tap-mocha-reporter').types
types = types.reduce(function (str, t) {
var ll = str.split('\n').pop().length + t.length
if (ll < 40)
return str + ' ' + t
else
return str + '\n' + t
}, '').trim()
var ind = ' '
return ind + types.split('\n').join('\n' + ind)
}
function setupTapEnv (options) {
process.env.TAP_TIMEOUT = options.timeout
if (options.color)
process.env.TAP_COLORS = 1
else
process.env.TAP_COLORS = 0
if (options.bail)
process.env.TAP_BAIL = '1'
if (options.grepInvert)
process.env.TAP_GREP_INVERT = '1'
if (options.grep.length)
process.env.TAP_GREP = options.grep.map(function (pattern) {
return pattern.toString()
}).join('\n')
if (options.only)
process.env.TAP_ONLY = '1'
}
function globFiles (files) {
return files.reduce(function (acc, f) {
if (f === '-') {
acc.push(f)
return acc
}
// glob claims patterns MUST not include any '\'s
if (!/\\/.test(f))
f = glob.sync(f) || f
return acc.concat(f)
}, [])
}
function makeReporter (options) {
var TMR = require('tap-mocha-reporter')
return new TMR(options.reporter)
}
function stdinOnly (options) {
// if we didn't specify any files, then just passthrough
// to the reporter, so we don't get '/dev/stdin' in the suite list.
// We have to pause() before piping to switch streams2 into old-mode
process.stdin.pause()
var reporter = makeReporter(options)
process.stdin.pipe(reporter)
process.stdin.resume()
}
function readSaveFile (options) {
if (options.saveFile)
try {
return fs.readFileSync(options.saveFile, 'utf8').trim().split('\n')
} catch (er) {}
return null
}
function saveFails (options, tap) {
if (!options.saveFile)
return
var fails = []
var successes = []
tap.on('result', function (res) {
// we will continue to re-run todo tests, even though they're
// not technically "failures".
if (!res.ok && !res.extra.skip)
fails.push(res.extra.file)
else
successes.push(res.extra.file)
})
tap.on('bailout', function (reason) {
// add any pending test files to the fails list.
fails.push.apply(fails, options.files.filter(function (file) {
return successes.indexOf(file) === -1
}))
save()
})
tap.on('end', save)
function save () {
fails = fails.reduce(function (set, f) {
if (set.indexOf(f) === -1)
set.push(f)
return set
}, [])
if (!fails.length)
try {
fs.unlinkSync(options.saveFile)
} catch (er) {}
else
try {
fs.writeFileSync(options.saveFile, fails.join('\n') + '\n')
} catch (er) {}
}
}
function filterFiles (files, saved, parallelOk) {
return files.filter(function (file) {
if (path.basename(file) === 'tap-parallel-ok')
parallelOk[path.resolve(path.dirname(file))] = true
else if (path.basename(file) === 'tap-parallel-not-ok')
parallelOk[path.resolve(path.dirname(file))] = false
else
return saved === null || saved.indexOf(file) !== -1
})
}
function isParallelOk (parallelOk, file) {
var dir = path.resolve(path.dirname(file))
if (dir in parallelOk)
return parallelOk[dir]
if (exists(dir + '/tap-parallel-ok'))
return parallelOk[dir] = true
if (exists(dir + '/tap-parallel-not-ok'))
return parallelOk[dir] = false
if (dir.length >= process.cwd().length)
return isParallelOk(parallelOk, dir)
}
function runAllFiles (options, saved, tap) {
var doStdin = false
var parallelOk = Object.create(null)
options.files = filterFiles(options.files, saved, parallelOk)
for (var i = 0; i < options.files.length; i++) {
var opt = {}
var file = options.files[i]
// Pick up stdin after all the other files are handled.
if (file === '-') {
doStdin = true
continue
}
var st = fs.statSync(options.files[i])
if (options.timeout)
opt.timeout = options.timeout * 1000
opt.file = file
if (options.jobs > 1)
opt.buffered = isParallelOk(parallelOk, file) !== false
if (file.match(/\.js$/)) {
var args = options.nodeArgs.concat(file).concat(options.testArgs)
tap.spawn(node, args, opt, file)
} else if (st.isDirectory()) {
var dir = filterFiles(fs.readdirSync(file).map(function (f) {
return file + '/' + f
}), saved, parallelOk)
options.files.push.apply(options.files, dir)
} else if (isexe.sync(options.files[i]))
tap.spawn(options.files[i], options.testArgs, opt, file)
}
if (doStdin)
tap.stdin()
}
function runTests (options) {
var saved = readSaveFile(options)
// At this point, we know we need to use the tap root,
// because there are 1 or more files to spawn.
var tap = require('../lib/tap.js')
tap.runOnly = false
// greps are passed to children, but not the runner itself
tap.grep = []
tap.jobs = options.jobs
tap.patchProcess()
// if not -Rtap, then output what the user wants.
// otherwise just dump to stdout
tap.pipe(options.reporter === 'tap' ? process.stdout: makeReporter(options))
// need to replay the first version line, because the previous
// line will have flushed it out to stdout or the reporter already.
if (options.outputFile !== null)
tap.pipe(fs.createWriteStream(options.outputFile)).write('TAP version 13\n')
saveFails(options, tap)
runAllFiles(options, saved, tap)
tap.end()
}
function parseRcFile (path) {
try {
var contents = fs.readFileSync(path, 'utf8')
return yaml.safeLoad(contents) || {}
} catch (er) {
// if no dotfile exists, or invalid yaml, fail gracefully
return {}
}
}
function strToRegExp (g) {
var p = g.match(/^\/(.*)\/([a-z]*)$/)
g = p ? p[1] : g
var flags = p ? p[2] : ''
return new RegExp(g, flags)
}

263
static/js/ketcher2/node_modules/tap/bin/usage.txt generated vendored Normal file
View File

@ -0,0 +1,263 @@
Usage:
tap [options] <files>
Executes all the files and interprets their output as TAP
formatted test result data.
To parse TAP data from stdin, specify "-" as a filename.
Short options are parsed gnu-style, so for example '-bCRspec' would be
equivalent to '--bail --no-color --reporter=spec'
If the --check-coverage or --coverage-report options are provided, but
no test files are specified, then a coverage report or coverage check
will be run on the data from the last test run.
Coverage is never enabled for stdin.
Options:
-j<n> --jobs=<n> Run up to <n> test files in parallel
Note that this causes tests to be run in
"buffered" mode, so line-by-line results
cannot be reported, and older TAP
parsers may get upset.
-J --jobs-auto Run test files in parallel (auto calculated)
Note that this causes tests to be run in
"buffered" mode, so line-by-line results
cannot be reported, and older TAP
parsers may get upset.
-g<pattern> Only run subtests tests matching the specified
--grep=<pattern> pattern.
Patterns are matched against top-level
subtests in each file. To filter tests
at subsequent levels, specify this
option multiple times.
To specify regular expression flags,
format pattern like a JavaScript RegExp
literal. For example: '/xyz/i' for
case-insensitive matching.
-i --invert Invert the matches to --grep patterns.
(Like grep -v)
-c --color Use colors (Default for TTY)
-C --no-color Do not use colors (Default for non-TTY)
-b --bail Bail out on first failure
-B --no-bail Do not bail out on first failure (Default)
-O --only Only run tests with {only: true} option
-R<type> --reporter=<type> Use the specified reporter. Defaults to
'classic' when colors are in use, or 'tap'
when colors are disabled.
Available reporters:
@@REPORTERS@@
-o<file> Send the raw TAP output to the specified
--output-file=<file> file. Reporter output will still be
printed to stdout, but the file will
contain the raw TAP for later reply or
analysis.
-s<file> --save=<file> If <file> exists, then it should be a line-
delimited list of test files to run. If
<file> is not present, then all command-line
positional arguments are run.
After the set of test files are run, any
failed test files are written back to the
save file.
This way, repeated runs with -s<file> will
re-run failures until all the failures are
passing, and then once again run all tests.
It's a good idea to .gitignore the file
used for this purpose, as it will churn a
lot.
--coverage --cov Capture coverage information using 'nyc'
If a COVERALLS_REPO_TOKEN environment
variable is set, then coverage is
captured by default and sent to the
coveralls.io service.
--no-coverage --no-cov Do not capture coverage information.
Note that if nyc is already loaded, then
the coverage info will still be captured.
--coverage-report=<type> Output coverage information using the
specified istanbul/nyc reporter type.
Default is 'text' when running on the
command line, or 'text-lcov' when piping
to coveralls.
If 'html' is used, then the report will
be opened in a web browser after running.
This can be run on its own at any time
after a test run that included coverage.
--no-coverage-report Do not output a coverage report.
--no-browser Do not open a web browser after
generating an html coverage report.
-t<n> --timeout=<n> Time out test files after <n> seconds.
Defaults to 30, or the value of the
TAP_TIMEOUT environment variable.
Setting to 0 allows tests to run
forever.
-T --no-timeout Do not time out tests.
Equivalent to --timeout=0
-h --help print this thing you're looking at
-v --version show the version of this program
--node-arg=<arg> Pass an argument to Node binary in all
child processes. Run 'node --help' to
see a list of all relevant arguments.
This can be specified multiple times to
pass multiple args to Node.
-gc --expose-gc Expose the gc() function to Node tests
--debug Run JavaScript tests with node --debug
--debug-brk Run JavaScript tests with node --debug-brk
--harmony Enable all Harmony flags in JavaScript tests
--strict Run JS tests in 'use strict' mode
--test-arg=<arg> Pass an argument to test files spawned
by the tap command line executable.
This can be specified multiple times to
pass multiple args to test scripts.
--nyc-arg=<arg> Pass an argument to nyc when running
child processes with coverage enabled.
This can be specified multiple times to
pass multiple args to nyc.
--check-coverage Check whether coverage is within
thresholds provided. Setting this
explicitly will default --coverage to
true.
This can be run on its own any time
after a test run that included coverage.
--branches what % of branches must be covered?
Setting this will default both
--check-coverage and --coverage to true.
[default: 0]
--functions what % of functions must be covered?
Setting this explicitly will default both
--check-coverage and --coverage to true.
[default: 0]
--lines what % of lines must be covered?
Setting this explicitly will default both
--check-coverage and --coverage to true.
[default: 90]
--statements what % of statements must be covered?
Setting this explicitly will default both
--check-coverage and --coverage to true.
[default: 0]
--100 Full coverage, 100%.
Sets branches, statements, functions,
and lines to 100.
--nyc-help Print nyc usage banner. Useful for
viewing options for --nyc-arg.
--nyc-version Print version of nyc used by tap.
--dump-config Dump the config options in JSON format.
-- Stop parsing flags, and treat any additional
command line arguments as filenames.
Environment Variables:
TAP_RCFILE A yaml formatted file which can set any
of the above options. Defaults to
$HOME/.taprc
TAP_TIMEOUT Default value for --timeout option.
TAP_COLORS Set to '1' to force color output, or '0'
to prevent color output.
TAP_BAIL Bail out on the first test failure.
Used internally when '--bailout' is set.
TAP Set to '1' to force standard TAP output,
and suppress any reporters. Used when
running child tests so that their output
is parseable by the test harness.
TAP_DIAG Set to '1' to show diagnostics by
default for passing tests. Set to '0'
to NOT show diagnostics by default for
failing tests. If not one of these two
values, then diagnostics are printed by
default for failing tests, and not for
passing tests.
TAP_BUFFER Set to '1' to run subtests in buffered
mode by default.
TAP_DEV_LONGSTACK Set to '1' to include node-tap internals
in stack traces. By default, these are
included only when the current working
directory is the tap project itself.
Note that node internals are always
excluded.
TAP_DEV_SHORTSTACK Set to '1' to exclude node-tap internals
in stack traces, even if the current
working directory is the tap project
itself.
_TAP_COVERAGE_ Reserved for internal use.
TAP_DEBUG Set to '1' to turn on debug mode.
NODE_DEBUG Include 'tap' to turn on debug mode.
TAP_GREP A '\n'-delimited list of grep patterns
to apply to root level test objects.
(This is an implementation detail for how
the '--grep' option works.)
TAP_GREP_INVERT Set to '1' to invert the meaning of the
patterns in TAP_GREP. (Implementation
detail for how the '--invert' flag
works.)
Config Files:
You can create a yaml file with any of the options above. By default,
the file at ~/.taprc will be loaded, but the TAP_RCFILE environment
variable can modify this.
Run 'tap --dump-config' for a listing of what can be set in that file.
Each of the keys corresponds to one of the options above.

389
static/js/ketcher2/node_modules/tap/lib/asserts.js generated vendored Normal file
View File

@ -0,0 +1,389 @@
var synonyms = require('./synonyms.js')
var tsame = require('tsame') // same thing, strict or not
var tmatch = require('tmatch') // ok with partial estimates
var extraFromError = require('./extra-from-error.js')
var stack = require('./stack.js')
// Load Buffer the old way for browserify's sake
var Buffer = require('buffer').Buffer // eslint-disable-line
// this is actually the "working half" of the Test class.
// each method figures out if it's a pass or fail, and decorates
// the extra bit, and then calls either pass() or fail() or some
// other assert method.
//
// typically, a plugin would do this on a specific instance, eg on
// the root test harness instance. but we do this here to add some
// useful prototype methods.
exports.decorate = decorate
function decorate (t) {
t.addAssert('ok', 1, function (obj, message, extra) {
message = message || 'expect truthy value'
if (obj) {
return this.pass(message, extra)
}
return this.fail(message, extra)
})
t.addAssert('notOk', 1, function (obj, message, extra) {
message = message || 'expect falsey value'
return this.ok(!obj, message, extra)
})
t.addAssert('error', 1, function (er, message, extra) {
if (!er) {
return this.pass(message || 'should not error', extra)
}
if (!(er instanceof Error)) {
extra.found = er
return this.fail(message || 'non-Error error encountered', extra)
}
message = message || er.message
extra.found = er
return this.fail(message, extra)
})
t.addAssert('equal', 2, function (f, w, m, e) {
m = m || 'should be equal'
if (f === w) {
return this.pass(m, e)
}
e.found = f
e.wanted = w
e.compare = '==='
if (typeof f === 'object' &&
typeof w === 'object' &&
f &&
w &&
tsame(f, w)) {
e.note = 'Objects never === one another'
}
return this.fail(m, e)
})
t.addAssert('not', 2, function (f, w, m, e) {
m = m || 'should not be equal'
if (f !== w) {
return this.pass(m, e)
}
e.found = f
e.doNotWant = w
e.compare = '!=='
return this.fail(m, e)
})
t.addAssert('same', 2, function (f, w, m, e) {
m = m || 'should be equivalent'
e.found = f
e.wanted = w
return this.ok(tsame(f, w), m, e)
})
t.addAssert('notSame', 2, function (f, w, m, e) {
m = m || 'should not be equivalent'
e.found = f
e.doNotWant = w
return this.notOk(tsame(f, w), m, e)
})
t.addAssert('strictSame', 2, function (f, w, m, e) {
m = m || 'should be equivalent strictly'
e.found = f
e.wanted = w
return this.ok(tsame.strict(f, w), m, e)
})
t.addAssert('strictNotSame', 2, function (f, w, m, e) {
m = m || 'should be equivalent strictly'
e.found = f
e.doNotWant = w
return this.notOk(tsame.strict(f, w), m, e)
})
t.addAssert('match', 2, function (f, w, m, e) {
m = m || 'should match pattern provided'
e.found = f
e.pattern = w
return this.ok(tmatch(f, w), m, e)
})
t.addAssert('notMatch', 2, function (f, w, m, e) {
m = m || 'should not match pattern provided'
e.found = f
e.pattern = w
return this.ok(!tmatch(f, w), m, e)
})
t.addAssert('type', 2, function (obj, klass, m, e) {
var name = klass
if (typeof name === 'function') {
name = name.name || '(anonymous constructor)'
}
m = m || 'type is ' + name
// simplest case, it literally is the same thing
if (obj === klass) {
return this.pass(m, e)
}
var type = typeof obj
if (!obj && type === 'object') {
type = 'null'
}
if (type === 'function' &&
typeof klass === 'function' &&
klass !== Object) {
// treat as object, but not Object
// t.type(() => {}, Function)
type = 'object'
}
if (type === 'object' && klass !== 'object') {
if (typeof klass === 'function') {
e.found = Object.getPrototypeOf(obj).constructor.name
e.wanted = name
return this.ok(obj instanceof klass, m, e)
}
// check prototype chain for name
// at this point, we already know klass is not a function
// if the klass specified is an obj in the proto chain, pass
// if the name specified is the name of a ctor in the chain, pass
var p = obj
do {
var ctor = p.constructor && p.constructor.name
if (p === klass || ctor === name) {
return this.pass(m, e)
}
p = Object.getPrototypeOf(p)
} while (p)
}
return this.equal(type, name, m, e)
})
t.addAssert('throws', 4, function (fn_, wanted_, m_, e_, m, e__) {
var fn, wanted, e
for (var i = 0; i < arguments.length - 1; i++) {
var arg = arguments[i]
if (typeof arg === 'function') {
if (arg === Error || arg.prototype instanceof Error) {
wanted = arg
} else if (!fn) {
fn = arg
}
} else if (typeof arg === 'string' && arg) {
m = arg
} else if (typeof arg === 'object') {
if (!wanted) {
wanted = arg
} else {
e = arg
}
}
}
// Copy local properties of the 'extra' object, like 'skip' etc
Object.keys(e__).forEach(function (i) {
e[i] = e__[i]
})
if (!m) {
m = fn && fn.name || 'expected to throw'
}
if (wanted) {
if (wanted instanceof Error) {
var w = {
message: wanted.message
}
if (wanted.name) {
w.name = wanted.name
}
// intentionally copying non-local properties, since this
// is an Error object, and those are funky.
for (i in wanted) {
w[i] = wanted[i]
}
wanted = w
m += ': ' + (wanted.name || 'Error') + ' ' + wanted.message
e = e || {}
if (e !== wanted) {
e.wanted = wanted
}
}
}
if (typeof fn !== 'function') {
e = e || {}
e.todo = true
return this.pass(m, e)
}
try {
fn()
return this.fail(m, e)
} catch (er) {
// 'name' is a getter.
if (er.name) {
er.name = er.name + ''
}
if (wanted) {
if (Object.prototype.toString.call(wanted) === '[object RegExp]') {
return this.match(er.message, wanted, m, e)
}
return this.has(er, wanted, m, e)
} else {
return this.pass(m, e)
}
}
})
t.addAssert('doesNotThrow', 1, function (fn, m, e) {
if (typeof fn === 'string') {
var x = fn
fn = m
m = x
}
if (!m) {
m = fn && fn.name || 'expected to not throw'
}
if (typeof fn !== 'function') {
e.todo = true
return this.pass(m, e)
}
try {
fn()
return this.pass(m, e)
} catch (er) {
var extra = extraFromError(er, e)
extra.message = er.message
return this.fail(m, extra)
}
})
// like throws, but rejects a returned promise instead
// also, can pass in a promise instead of a function
t.addAssert('rejects', 4, function (fn_, wanted_, m_, e_, m, e__) {
var fn, wanted, e, promise
for (var i = 0; i < arguments.length - 1; i++) {
var arg = arguments[i]
if (typeof arg === 'function') {
if (arg === Error || arg.prototype instanceof Error) {
wanted = arg
} else if (!fn) {
fn = arg
}
} else if (typeof arg === 'string' && arg) {
m = arg
} else if (arg && typeof arg.then === 'function' && !promise) {
promise = arg
} else if (typeof arg === 'object') {
if (!wanted) {
wanted = arg
} else {
e = arg
}
}
}
// Copy local properties of the 'extra' object, like 'skip' etc
Object.keys(e__).forEach(function (i) {
e[i] = e__[i]
})
if (!m) {
m = fn && fn.name || 'expect rejected Promise'
}
if (wanted) {
if (wanted instanceof Error) {
var w = {
message: wanted.message
}
if (wanted.name) {
w.name = wanted.name
}
// intentionally copying non-local properties, since this
// is an Error object, and those are funky.
for (i in wanted) {
w[i] = wanted[i]
}
wanted = w
m += ': ' + (wanted.name || 'Error') + ' ' + wanted.message
e = e || {}
if (e !== wanted) {
e.wanted = wanted
}
}
}
if (!promise && typeof fn !== 'function') {
e = e || {}
e.todo = true
return this.pass(m, e)
}
if (!promise)
promise = fn()
if (!promise || typeof promise.then !== 'function')
return this.fail(m, e)
// have to do as a subtest, because promises are async
e.at = stack.at(this.currentAssert)
this.test(m, { buffered: true }, function (t) {
return promise.then(function (value) {
e.found = value
t.fail(m, e)
}, function (er) {
// 'name' is a getter.
if (er.name) {
er.name = er.name + ''
}
if (wanted) {
if (Object.prototype.toString.call(wanted) === '[object RegExp]') {
return t.match(er.message, wanted, m, e)
}
return t.has(er, wanted, m, e)
} else {
return t.pass(m, e)
}
})
})
})
// synonyms are helpful.
Object.keys(synonyms).forEach(function (c) {
if (t[c]) {
synonyms[c].forEach(function (s) {
Object.defineProperty(t, s, {
value: t[c],
enumerable: false,
configurable: true,
writable: true
})
})
}
})
}

254
static/js/ketcher2/node_modules/tap/lib/base.js generated vendored Normal file
View File

@ -0,0 +1,254 @@
module.exports = Base
var Readable = require('stream').Readable
/* istanbul ignore if */
if (!Readable || process.version.match(/^v0\.10/)) {
Readable = require('readable-stream').Readable
}
var extraFromError = require('./extra-from-error.js')
var assert = require('assert')
var cleanYamlObject = require('./clean-yaml-object.js')
var domain = require('domain')
var util = require('util')
util.inherits(Base, Readable)
var Parser = require('tap-parser')
var ownOr = require('own-or')
var ownOrEnv = require('own-or-env')
function Base (options) {
this.start = 0
this.hrtime = null
this.time = null
this.readyToProcess = false
this.options = options
this.grep = ownOr(options, 'grep', [])
this.grepInvert = ownOr(options, 'grepInvert', false)
this.parent = ownOr(options, 'parent', null)
this.bail = ownOrEnv(options, 'bail', 'TAP_BAIL', true)
this.name = ownOr(options, 'name', '')
if (!this.name)
this.name = ''
else
this.name = this.name.replace(/[\n\r\s\t]/g, ' ')
this.indent = ownOr(options, 'indent', '')
this.silent = !!options.silent
this.buffered = !!options.buffered || !!options.silent
this.finished = false
this.strict = ownOrEnv(options, 'strict', 'TAP_STRICT', true)
this.omitVersion = !!options.omitVersion
this.preserveWhitespace = ownOr(options, 'preserveWhitespace', true)
this.jobs = +ownOrEnv(options, 'jobs', 'TAP_JOBS') || 0
this.skip = ownOr(options, 'skip', false)
this.todo = ownOr(options, 'todo', false)
this.runOnly = ownOr(options, 'runOnly', false)
this.setupParser(options)
this.finished = false
this.output = ''
this.results = null
this.bailedOut = false
if (this.skip || this.todo)
this.main = Base.prototype.main
Readable.apply(this, options)
domain.create().add(this)
this.domain.on('error', this.threw.bind(this))
if (typeof options.debug === 'boolean')
this.debug = options.debug ? debug : nodebug
}
Base.prototype.passing = function () {
return this.parser.ok
}
Base.prototype.setTimeout = function (n) {
if (!this.hrtime)
this.hrtime = process.hrtime()
if (!n) {
clearTimeout(this.timer)
this.timer = null
} else {
this.start = Date.now()
this.timer = setTimeout(this.timeout.bind(this), n)
if (this.timer.unref)
this.timer.unref()
}
}
Base.prototype.threw = function (er, extra, proxy) {
if (this.name && !proxy)
er.test = this.name
var message = er.message
if (!extra)
extra = extraFromError(er, extra, this.options)
if (this.results || this.ended) {
this.results.ok = false
if (this.parent)
this.parent.threw(er, extra, true)
else if (!er.stack)
console.error(er)
else {
er.message = message
delete extra.stack
delete extra.at
console.error('%s: %s', er.name || 'Error', message)
console.error(er.stack.split(/\n/).slice(1).join('\n'))
console.error(extra)
}
} else
this.parser.ok = false
return extra
}
Base.prototype.timeout = function (options) {
this.setTimeout(false)
var er = new Error('timeout!')
options = options || {}
options.expired = options.expired || this.name
this.threw(new Error('timeout!'), options)
}
Base.prototype.main = function (cb) {
cb()
}
Base.prototype.online = function (line) {
this.debug('LINE %j', line)
return this.push(this.indent + line)
}
Base.prototype.push = function (c, e) {
assert.equal(typeof c, 'string')
assert.equal(c.substr(-1), '\n')
if (this.buffered) {
this.output += c
return true
}
// We *always* want data coming out immediately. Test runners have a
// very special relationship with zalgo. It's more important to ensure
// that any console.log() lines that appear in the midst of tests are
// not taken out of context
if (this._readableState) {
this._readableState.sync = false
}
// this.debug(this._readableState)
return Readable.prototype.push.call(this, c, e)
}
Base.prototype.onbail = function (reason) {
this.bailedOut = reason || true
this.emit('bailout', reason)
}
Base.prototype.oncomplete = function (results) {
if (this.hrtime) {
this.hrtime = process.hrtime(this.hrtime)
this.time = Math.round(this.hrtime[0] * 1e6 + this.hrtime[1] / 1e3) / 1e3
}
this.debug('ONCOMPLETE %j %j', this.name, results)
if (this.results)
Object.keys(this.results).forEach(function (k) {
results[k] = this.results[k]
}, this)
this.results = results
this.emit('complete', results)
var failures = results.failures.filter(function (f) {
delete f.diag
delete f.ok
return f.tapError
})
if (failures.length)
this.options.failures = failures
this.onbeforeend()
this.emit('end')
this.ondone()
}
Base.prototype.onbeforeend = function () {}
Base.prototype.ondone = function () {}
Base.prototype.setupParser = function (options) {
this.parser = new Parser({
bail: this.bail,
strict: this.strict,
omitVersion: this.omitVersion,
preserveWhitespace: this.preserveWhitespace
})
assert(this.parser.preserveWhitespace)
this.parser.on('line', this.online.bind(this))
this.parser.once('bailout', this.onbail.bind(this))
this.parser.on('complete', this.oncomplete.bind(this))
}
Base.prototype._read = function (n) {
// this.emit('readable')
// this.debug('_read %j', this.name, arguments)
}
Base.prototype.inspect = function () {
return this.constructor.name + ' ' + util.inspect({
name: this.name,
jobs: this.jobs,
buffered: this.buffered,
occupied: this.occupied,
pool: this.pool,
queue: this.queue,
subtests: this.subtests,
output: this.output,
skip: this.skip,
todo: this.todo,
only: this.only,
results: this.results,
options: [
'autoend',
'command',
'args',
'stdio',
'env',
'cwd',
'exitCode',
'signal',
'expired',
'timeout',
'at',
'skip',
'todo',
'only'
].reduce(function (set, k) {
if (this.options[k] !== undefined)
set[k] = this.options[k]
return set
}.bind(this), {})
})
}
Base.prototype.debug = (/\btap\b/i.test(process.env.NODE_DEBUG || ''))
? debug : nodebug
function nodebug () {}
/* istanbul ignore next */
function debug () {
var prefix = 'TAP ' + process.pid + ' ' + this.name + ': '
var msg = util.format.apply(util, arguments).trim()
msg = prefix + msg.split('\n').join('\n' + prefix)
console.error(msg)
}

View File

@ -0,0 +1,72 @@
var cleanYamlObject = require('clean-yaml-object')
var path = require('path')
var Module = require('module')
var fs = require('fs')
var binpath = path.resolve(__dirname, '../bin')
var stack = require('./stack.js')
var Domain = require('domain').Domain
function hasOwn (obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key)
}
module.exports = cleanTapYamlObject
function cleanTapYamlObject (object) {
if (hasOwn(object, 'stack') && !hasOwn(object, 'at'))
object.at = stack.parseLine(object.stack.split('\n')[0])
var file = object.at && object.at.file && path.resolve(object.at.file)
if (file && (file.indexOf(__dirname) === 0 || file.indexOf(binpath) === 0))
delete object.at
if (object.at && object.at.file && object.at.line && !object.source) {
var content
file = path.resolve(object.at.file)
try {
content = Module.wrap(fs.readFileSync(file))
} catch (er) {}
if (content) {
content = (content.split('\n')[object.at.line - 1] || '').trim()
if (content)
object.source = content + '\n'
}
}
return cleanYamlObject(object, yamlFilter)
}
function yamlFilter (propertyName, isRoot, source, target) {
if (source instanceof Domain)
return false
if (!isRoot)
return true
if (propertyName === 'stack') {
if (source.stack)
target.stack = source.stack
return false
}
return !(propertyName === 'todo' ||
propertyName === 'time' ||
/^_?tapChild/.test(propertyName) ||
/^tapStream/.test(propertyName) ||
/^tapMochaTest/.test(propertyName) ||
propertyName === 'cb' ||
propertyName === 'name' ||
propertyName === 'indent' ||
propertyName === 'skip' ||
propertyName === 'bail' ||
propertyName === 'grep' ||
propertyName === 'grepInvert' ||
propertyName === 'only' ||
propertyName === 'diagnostic' ||
propertyName === 'buffered' ||
propertyName === 'parent' ||
propertyName === 'domainEmitter' ||
propertyName === 'domainThrew' ||
propertyName === 'domain' ||
(propertyName === 'at' && !source.at))
}

11
static/js/ketcher2/node_modules/tap/lib/diags.js generated vendored Normal file
View File

@ -0,0 +1,11 @@
module.exports = diags
var objToYaml = require('./obj-to-yaml.js')
function diags (extra) {
var y = objToYaml(extra)
if (y)
y = '\n' + y
return y
}

View File

@ -0,0 +1,47 @@
var stack = require('./stack.js')
module.exports = function (er, extra, options) {
extra = Object.keys(options || {}).reduce(function (set, k) {
if (!(k in set) && !/^tapChild/.test(k))
set[k] = options[k]
return set
}, extra || {})
if (!er || typeof er !== 'object') {
extra.error = er
return extra
}
var message = er.message
var addName = true
if (!message && er.stack) {
message = er.stack.split('\n')[0]
addName = false
}
er.message = ''
var st = er.stack
if (st) {
st = st.split('\n')
// parse out the 'at' bit from the first line.
extra.at = stack.parseLine(st[1])
extra.stack = stack.clean(st)
}
er.message = message
if (er.name && er.name !== 'Error')
extra.type = er.name
Object.keys(er).forEach(function (k) {
if (k === 'message' ||
k === 'domainEmitter' ||
k === 'domainThrown' ||
k === 'domain' ||
k === 'domainBound')
return
extra[k] = er[k]
})
return extra
}

147
static/js/ketcher2/node_modules/tap/lib/mocha.js generated vendored Normal file
View File

@ -0,0 +1,147 @@
exports.it = exports.specify = it
exports.context = exports.describe = describe
exports.before = before
exports.after = after
exports.beforeEach = beforeEach
exports.afterEach = afterEach
exports.global = function () {
Object.keys(exports).forEach(function (g) {
global[g] = exports[g]
})
}
var t = require('./tap.js')
t.jobs = 1
var tapStack = [ t ]
var level = 0
var suiteStack = []
function describe (name, fn) {
new Suite(name, fn)
}
function Suite (name, fn) {
this.parent = suiteStack[ suiteStack.length - 1 ]
if (typeof name === 'function')
fn = name, name = null
if (fn && fn.name && !name)
name = fn.name
this.todo = !fn
this.fn = fn
this.name = name
this.after = []
this.test = null
this.run()
}
Suite.prototype.run = function () {
var t = tapStack[ tapStack.length - 1 ]
t.test(this.name, { todo: this.todo }, function (tt) {
this.test = tt
tapStack.push(tt)
suiteStack.push(this)
var ret = this.fn()
this.runAfter()
suiteStack.pop()
return ret
}.bind(this))
}
Suite.prototype.runAfter = function () {
this.after.forEach(function (namefn) {
var name = namefn[0]
var fn = namefn[1]
before(name, fn)
})
do {
var t = tapStack.pop()
} while (t && t !== this.test)
if (this.test && !this.test.results)
t.end()
}
function before (name, fn) {
if (typeof name === 'function')
fn = name, name = null
if (fn && fn.name && !name)
name = fn.name
var todo = !fn
var suite = suiteStack[ suiteStack.length - 1 ]
var t = tapStack[ tapStack.length - 1 ]
if (!name)
name = ''
t.test(name, { todo: todo, silent: true }, function (tt) {
var ret = fn.call(suite, done(tt))
if (!ret && fn.length === 0)
tt.end()
else
return ret
})
function done (tt) { return function (er) {
if (er)
tt.threw(er)
else
tt.end()
}}
}
function it (name, fn) {
if (typeof name === 'function')
fn = name, name = null
if (fn && fn.name && !name)
name = fn.name
var todo = !fn
var suite = suiteStack[ suiteStack.length - 1 ]
var t = tapStack[ tapStack.length - 1 ]
if (!name)
name = ''
t.test(name, { todo: todo, tapMochaTest: true }, function (tt) {
var ret = fn.call(tt, done(tt))
if (ret && ret.then)
return ret
else if (fn.length === 0)
tt.end()
})
function done (tt) { return function (er) {
if (er)
tt.threw(er)
else
tt.end()
}}
}
function after (name, fn) {
var suite = suiteStack[ suiteStack.length - 1 ]
if (!suite)
throw new Error('cannot call "after" outside of describe()')
if (fn)
suite.after.push([name, fn])
else
suite.after.push([name])
}
function moment (when, fn) {
var t = tapStack[ tapStack.length - 1 ]
t[when](function (cb) {
if (!this.options.tapMochaTest)
return cb()
var suite = suiteStack[ suiteStack.length - 1 ]
var ret = fn.call(this, cb)
if (ret && ret.then)
return ret
else if (fn.length === 0)
return cb()
})
}
function beforeEach (fn) {
moment('beforeEach', fn)
}
function afterEach (fn) {
moment('afterEach', fn)
}

17
static/js/ketcher2/node_modules/tap/lib/obj-to-yaml.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
module.exports = objToYaml
var cleanYamlObject = require('./clean-yaml-object.js')
var yaml = require('js-yaml')
function objToYaml (obj) {
obj = cleanYamlObject(obj)
var y = ''
if (obj && typeof obj === 'object' && Object.keys(obj).length) {
y = yaml.safeDump(obj).split('\n').map(function (l) {
return l.trim() ? ' ' + l : l.trim()
}).join('\n')
y = ' ---\n' + y + ' ...\n'
}
return y
}

View File

@ -0,0 +1,64 @@
function typeOf (arg) {
var t = typeof arg
switch (t) {
case 'object':
return arg ? 'object' : 'null'
default:
return t
}
}
module.exports = function (name_, extra_, cb_, defaultName) {
var name
var extra
var cb
// this only works if it's literally the 4th argument. it's mostly
// used internally.
defaultName = defaultName || '(unnamed test)'
for (var i = 0; i < 3 && i < arguments.length; i++) {
var arg = arguments[i]
var type = typeOf(arg)
if (name === undefined && (type === 'string' || type === 'number'))
name = '' + arg
else if (type === 'object') {
extra = arg
if (name === undefined)
name = null
} else if (type === 'function') {
if (extra === undefined)
extra = {}
if (name === undefined)
name = null
cb = arg
} else if (arg === false) {
// it's handy while developing to put a ! in front of a
// function to temporarily make a test TODO
continue
} else if (type !== 'undefined')
throw new TypeError('unknown argument passed to parseTestArgs: ' + type)
}
if (!extra)
extra = {}
if (!cb)
extra.todo = true
if (!name && extra.name)
name = extra.name
if (!name && cb && cb.name)
name = cb.name
name = name || defaultName
extra.name = name
extra.cb = cb || todoCb
return extra
}
/* istanbul ignore next */
function todoCb () {
throw new Error('callback called for TODO test')
}

48
static/js/ketcher2/node_modules/tap/lib/point.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
module.exports = TestPoint
var path = require('path')
var binpath = path.resolve(__dirname, '../bin')
var util = require('util')
var diags = require('./diags.js')
function TestPoint (ok, message, extra) {
if (typeof ok !== 'boolean')
throw new TypeError('ok must be boolean')
if (!(this instanceof TestPoint))
return new TestPoint(ok, message, extra)
this.ok = ok ? 'ok ' : 'not ok '
this.message = tpMessage(message, extra)
}
function tpMessage (message, extra) {
message = message + ''
if (message)
message = ' - ' + message
message = message.replace(/[\n\r]/g, ' ').replace(/\t/g, ' ')
extra = extra || {}
if (extra.skip) {
message += ' # SKIP'
if (typeof extra.skip === 'string')
message += ' ' + extra.skip
} else if (extra.todo) {
message += ' # TODO'
if (typeof extra.todo === 'string')
message += ' ' + extra.todo
} else if (extra.time)
message += ' # time=' + extra.time + 'ms'
var diagYaml = extra.diagnostic ? diags(extra) : ''
message += diagYaml
if (extra.tapChildBuffer || extra.tapChildBuffer === '') {
if (!diagYaml)
message += ' '
message += '{\n' + extra.tapChildBuffer.trimRight() + '\n}\n'
}
message += '\n'
return message
}

140
static/js/ketcher2/node_modules/tap/lib/spawn.js generated vendored Normal file
View File

@ -0,0 +1,140 @@
var Base = require('./base.js')
var assert = require('assert')
var util = require('util')
util.inherits(Spawn, Base)
var ownOr = require('own-or')
var path = require('path')
var cleanYamlObject = require('./clean-yaml-object.js')
module.exports = Spawn
var cp = require('child_process')
var spawn = cp.spawn
function Spawn (options) {
options = options || {}
if (!(this instanceof Spawn))
return new Spawn(options)
Base.call(this, options)
this.command = options.command
if (!this.command)
throw new TypeError('no command provided')
this.args = options.args
// stdout must be a pipe
if (options.stdio) {
if (typeof options.stdio === 'string')
this.stdio = [ options.stdio, 'pipe', options.stdio ]
else
this.stdio = options.stdio.slice(0)
} else
this.stdio = [ 0, 'pipe', 2 ]
this.stdio[1] = 'pipe'
var env = options.env || process.env
this.env = Object.keys(env).reduce(function (e, k) {
e[k] = env[k]
return e
}, {})
this.env.TAP = '1'
if (this.bail)
this.env.TAP_BAIL = '1'
this.cwd = ownOr(options, 'cwd', process.cwd())
options.cwd = this.cwd
if (!this.name) {
if (this.command === process.execPath) {
this.name = path.basename(process.execPath) + ' ' +
this.args.map(function (a) {
if (a.indexOf(this.cwd) === 0) {
return './' +
a.substr(this.cwd.length + 1).replace(/\\/g, '/')
} else {
return a
}
}, this).join(' ')
} else {
this.name = this.command + ' ' + this.args.join(' ')
}
}
this.proc = null
}
Spawn.prototype.endAll = function () {
if (this.proc)
this.proc.kill('SIGKILL')
this.parser.abort('test unfinished')
this.cb()
}
Spawn.prototype.main = function (cb) {
this.cb = cb
this.setTimeout(this.options.timeout)
var options = Object.keys(this.options).reduce(function (o, k) {
o[k] = this.options[k]
return o
}.bind(this), {
cwd: this.cwd,
env: this.env,
stdio: this.stdio
})
try {
var proc = this.proc = spawn(this.command, this.args, options)
proc.stdout.pipe(this.parser)
proc.on('close', this.onprocclose.bind(this))
proc.on('error', this.threw.bind(this))
} catch (er) {
this.threw(er)
}
}
Spawn.prototype.threw = function (er, extra, proxy) {
extra = Base.prototype.threw.call(this, er, extra, proxy)
extra = cleanYamlObject(extra)
// unhook entirely
this.parser.abort(er.message, extra)
if (this.proc) {
this.proc.stdout.removeAllListeners('data')
this.proc.stdout.removeAllListeners('end')
this.proc.removeAllListeners('close')
this.proc.kill('SIGKILL')
}
this.cb()
}
Spawn.prototype.onprocclose = function (code, signal) {
this.debug('SPAWN close %j %s', code, signal)
this.options.exitCode = code
if (signal)
this.options.signal = signal
this.results = this.results || {}
// spawn closing with no tests is treated as a skip.
if (this.results.plan && this.results.plan.skipAll && !code && !signal)
this.options.skip = this.results.plan.skipReason || true
if (code || signal) {
this.results.ok = false
this.parser.ok = false
}
return this.cb()
}
Spawn.prototype.timeout = function (extra) {
if (this.proc)
this.proc.kill('SIGTERM')
var t = setTimeout(function () {
if (!this.options.signal && this.options.exitCode === undefined) {
Base.prototype.timeout.call(this, extra)
this.proc.kill('SIGKILL')
}
}.bind(this), 1000)
if (t.unref)
t.unref()
}

28
static/js/ketcher2/node_modules/tap/lib/stack.js generated vendored Normal file
View File

@ -0,0 +1,28 @@
var sourceMapSupport = require('source-map-support')
var StackUtils = require('stack-utils')
var path = require('path')
var tapDir = path.resolve(__dirname, '..')
// don't skip when developing on tap itself
var skip = process.cwd() !== tapDir ||
+process.env.TAP_DEV_SHORTSTACK === 1 &&
+process.env.TAP_DEV_LONGSTACK !== 1
? [
/node_modules[\/\\]tap[\/\\]/,
new RegExp(resc(tapDir) + '\\b', 'i'),
new RegExp(resc(require.resolve('function-loop'))),
new RegExp(resc(path.dirname(require.resolve('bluebird/package.json'))))
]
: []
sourceMapSupport.install({environment:'node'})
// Ignore tap if it's a dependency, or anything
// in this lib folder.
module.exports = new StackUtils({
internals: StackUtils.nodeInternals().concat(skip),
wrapCallSite: sourceMapSupport.wrapCallSite
})
function resc(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
}

36
static/js/ketcher2/node_modules/tap/lib/stdin.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
var Base = require('./base.js')
var util = require('util')
var ownOr = require('own-or')
var domain = require('domain')
util.inherits(Stdin, Base)
module.exports = Stdin
function Stdin (options) {
options = options || {}
if (!(this instanceof Stdin))
return new Stdin(options)
options.name = ownOr(options, 'name', '/dev/stdin')
Base.call(this, options)
// This has to be here for node 0.10's wonky streams
this.stream = ownOr(options, 'tapStream', process.stdin)
this.stream.pause()
}
Stdin.prototype.main = function (cb) {
this.domain.add(this.stream)
this.setTimeout(this.options.timeout)
this.stream.pipe(this.parser)
this.stream.resume()
this.once('end', cb)
}
Stdin.prototype.threw = function (er, extra, proxy) {
extra = Base.prototype.threw.call(this, er, extra, proxy)
this.options = extra
this.parser.abort(er.message, extra)
this.parser.end()
}

88
static/js/ketcher2/node_modules/tap/lib/synonyms.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
// A list of all the synonyms of assert methods.
// In addition to these, multi-word camelCase are also synonymized to
// all lowercase and snake_case
module.exports = multiword({
ok: ['true', 'assert'],
notOk: ['false', 'assertNot'],
error: ['ifError', 'ifErr'],
throws: ['throw'],
doesNotThrow: ['notThrow'],
// exactly the same. ===
equal: [
'equals', 'isEqual', 'is', 'strictEqual', 'strictEquals', 'strictIs',
'isStrict', 'isStrictly'
],
// not equal. !==
not: [
'inequal', 'notEqual', 'notEquals', 'notStrictEqual', 'notStrictEquals',
'isNotEqual', 'isNot', 'doesNotEqual', 'isInequal'
],
// deep equivalence. == for scalars
same: [
'equivalent', 'looseEqual', 'looseEquals', 'deepEqual',
'deepEquals', 'isLoose', 'looseIs', 'isEquivalent'
],
// deep inequivalence. != for scalars
notSame: [
'inequivalent', 'looseInequal', 'notDeep', 'deepInequal',
'notLoose', 'looseNot', 'notEquivalent', 'isNotDeepEqual',
'isNotDeeply', 'notDeepEqual', 'isInequivalent',
'isNotEquivalent'
],
// deep equivalence, === for scalars
strictSame: [
'strictEquivalent', 'strictDeepEqual', 'sameStrict', 'deepIs',
'isDeeply', 'isDeep', 'strictDeepEquals'
],
// deep inequivalence, !== for scalars
strictNotSame: [
'strictInequivalent', 'strictDeepInequal', 'notSameStrict', 'deepNot',
'notDeeply', 'strictDeepInequals', 'notStrictSame'
],
// found has the fields in wanted, string matches regexp
match: [
'has', 'hasFields', 'matches', 'similar', 'like', 'isLike',
'includes', 'include', 'isSimilar', 'contains'
],
notMatch: [
'dissimilar', 'unsimilar', 'notSimilar', 'unlike', 'isUnlike',
'notLike', 'isNotLike', 'doesNotHave', 'isNotSimilar', 'isDissimilar'
],
type: [
'isa', 'isA'
]
})
function multiword (obj) {
Object.keys(obj).forEach(function (i) {
var list = obj[i]
var res = [ multiword_(i) ].concat(list.map(multiword_))
res = res.reduce(function (set, i) {
set.push.apply(set, i)
return set
}, [])
obj[i] = res
})
return obj
}
function multiword_ (str) {
var res = [ str ]
if (str.match(/[A-Z]/)) {
res.push(str.toLowerCase())
res.push(str.replace(/[A-Z]/g, function ($0) {
return '_' + $0.toLowerCase()
}))
}
return res
}

216
static/js/ketcher2/node_modules/tap/lib/tap.js generated vendored Normal file
View File

@ -0,0 +1,216 @@
var Test = require('./test.js')
var Stdin = require('./stdin.js')
var Spawn = require('./spawn.js')
var util = require('util')
var objToYaml = require('./obj-to-yaml.js')
var yaml = require('js-yaml')
util.inherits(TAP, Test)
function TAP (options) {
Test.call(this, options)
this.runOnly = process.env.TAP_ONLY === '1'
this.start = Date.now()
}
var didPipe = false
TAP.prototype.pipe = function () {
didPipe = true
this.setTimeout(this.options.timeout)
this.pipe = Test.prototype.pipe
this.push = Test.prototype.push
var ret = this.pipe.apply(this, arguments)
this.process()
return ret
}
function monkeypatchEpipe () {
process.stdout.emit = function (emit) {
return function (ev, er) {
if (ev === 'error' && er.code === 'EPIPE')
return this.emit = emit
return emit.apply(this, arguments)
}
}(process.stdout.emit)
}
function monkeypatchExit () {
// ensure that we always get run, even if a user does
// process.on('exit', process.exit)
process.reallyExit = function (original) {
return function reallyExit (code) {
code = onExitEvent(code)
return original.call(this, code)
}
}(process.reallyExit)
process.exit = function (original) {
return function exit (code) {
code = onExitEvent(code)
return original.call(this, code)
}
}(process.exit)
process.on('exit', onExitEvent)
}
var didOnExitEvent = false
function onExitEvent (code) {
if (didOnExitEvent)
return process.exitCode || code
didOnExitEvent = true
if (!tap.results)
tap.endAll()
if (tap.results && !tap.results.ok && code === 0) {
process.exitCode = 1
if (process.version.match(/^v0\.(10|[0-9])\./))
process.exit(code)
}
return process.exitCode || code || 0
}
TAP.prototype.push = function push () {
// this resets push and pipe to standard values
this.pipe(process.stdout)
this.patchProcess()
return this.push.apply(this, arguments)
}
TAP.prototype.patchProcess = function () {
monkeypatchEpipe()
monkeypatchExit()
process.on('uncaughtException', this.threw)
process.on('unhandledRejection', function (er) {
this.threw(er)
}.bind(this))
}
TAP.prototype.onbail = function () {
Test.prototype.onbail.apply(this, arguments)
this.endAll()
process.exit(1)
}
TAP.prototype.onbeforeend = function () {
if (didPipe && this.time && !this.bailedOut)
this.emit('data', '# time=' + this.time + 'ms\n')
}
TAP.prototype.ondone = function () {
try {
this.emit('teardown')
} catch (er) {
this.threw(er)
}
}
// Root test runner doesn't have the 'teardown' event, because it
// isn't hooked into any parent Test as a harness.
TAP.prototype.teardown = TAP.prototype.tearDown = function (fn) {
this.autoend()
return Test.prototype.teardown.apply(this, arguments)
}
var opt = { name: 'TAP' }
if (process.env.TAP_DEBUG === '1' ||
/\btap\b/.test(process.env.NODE_DEBUG || ''))
opt.debug = true
if (process.env.TAP_GREP) {
opt.grep = process.env.TAP_GREP.split('\n').map(function (g) {
var p = g.match(/^\/(.*)\/([a-z]*)$/)
g = p ? p[1] : g
var flags = p ? p[2] : ''
return new RegExp(g, flags)
})
}
if (process.env.TAP_GREP_INVERT === '1') {
opt.grepInvert = true
}
if (process.env.TAP_ONLY === '1') {
opt.only = true
}
var tap = new TAP(opt)
module.exports = tap
tap.mocha = require('./mocha.js')
tap.mochaGlobals = tap.mocha.global
tap.Test = Test
tap.Spawn = Spawn
tap.Stdin = Stdin
tap.synonyms = require('./synonyms.js')
// SIGTERM means being forcibly killed, almost always by timeout
var onExit = require('signal-exit')
var didTimeoutKill = false
onExit(function (code, signal) {
if (signal !== 'SIGTERM' || !didPipe || didTimeoutKill)
return
var handles = process._getActiveHandles().filter(function (h) {
return h !== process.stdout &&
h !== process.stdin &&
h !== process.stderr
})
var requests = process._getActiveRequests()
// Ignore this because it's really hard to test cover in a way
// that isn't inconsistent and unpredictable.
/* istanbul ignore next */
var extra = {
at: null,
signal: signal
}
if (requests.length) {
extra.requests = requests.map(function (r) {
var ret = { type: r.constructor.name }
if (r.context) {
ret.context = r.context
}
return ret
})
}
if (handles.length) {
extra.handles = handles.map(function (h) {
var ret = { type: h.constructor.name }
if (h.msecs) {
ret.msecs = h.msecs
}
if (h._events) {
ret.events = Object.keys(h._events)
}
if (h._sockname) {
ret.sockname = h._sockname
}
if (h._connectionKey) {
ret.connectionKey = h._connectionKey
}
return ret
})
}
// this is impossible to cover, because it happens after nyc has
// already done its stuff.
/* istanbul ignore else */
if (!tap.results && tap.timeout)
tap.timeout(extra)
else {
console.error('possible timeout: SIGTERM received after tap end')
if (extra.handles || extra.requests) {
delete extra.signal
if (!extra.at) {
delete extra.at
}
var yaml = require('js-yaml')
console.error(objToYaml(extra))
}
didTimeoutKill = true
process.kill(process.pid, 'SIGTERM')
}
})

789
static/js/ketcher2/node_modules/tap/lib/test.js generated vendored Normal file
View File

@ -0,0 +1,789 @@
// We need TWO queues (work and subtest) and one jobs pool
//
// The pool stores buffered subtests being run in parallel.
//
// When new subtests are created, they get put in the work queue and also
// in the subtests queue if they are buffered and jobs>0. When we put a
// test in the subtest queue, we also process it.
//
// Processing the subtest queue means moving tests into the jobs pool until
// the jobs pool length is at this.jobs
//
// Any output functions get put in the work queue if its length > 0 (ie,
// no cutting the line)
//
// Processing the work queue means walking until we run out of things, or
// encounter an unfinished test. When we encounter ANY kind of test, we
// block until its output is completed, dumping it all into the parser.
var Base = require('./base.js')
var Spawn = require('./spawn.js')
var Stdin = require('./stdin.js')
var Deferred = require('trivial-deferred')
var Pool = require('yapool')
var TestPoint = require('./point.js')
var parseTestArgs = require('./parse-test-args.js')
var loop = require('function-loop')
var extraFromError = require('./extra-from-error.js')
var stack = require('./stack.js')
var assert = require('assert')
var util = require('util')
util.inherits(Test, Base)
var ownOr = require('own-or')
var ownOrEnv = require('own-or-env')
var tapAsserts = require('./asserts.js')
var Promise = require('bluebird')
var bindObj = require('bind-obj-methods')
// A sigil object for implicit end() calls that should not
// trigger an error if the user then calls t.end()
var IMPLICIT = {}
// Sigil to put in the queue to signal the end of all things
var EOF = { EOF: true }
function hasOwn (obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key)
}
module.exports = Test
function Test (options) {
options = options || {}
if (!(this instanceof Test))
return new Test(options)
Base.call(this, options)
this.pushedEnd = false
this.jobs = ownOr(options, 'jobs', 1)
this.subtests = []
this.pool = new Pool()
this.queue = ['TAP version 13\n']
this.noparallel = false
this.cb = this.domain.bind(options.cb)
this.occupied = false
this.currentAssert = null
this.count = 0
this.n = 0
this.ended = false
this.explicitEnded = false
this.multiEndThrew = false
this.currentAssert = null
this.assertAt = null
this.assertStack = null
this.planEnd = -1
this.onBeforeEach = []
this.onAfterEach = []
this.ranAfterEach = false
// bind all methods to this object, so we can pass t.end as a callback
// and do `var test = require('tap').test` like people do.
var bound = Object.create(null)
bindObj(this, this, bound)
bindObj(this, Object.getPrototypeOf(this), bound)
bindObj(this, Test.prototype, bound)
}
Test.prototype.current = function () {
throw new Error('Test.current() as been removed and is no more')
}
Test.prototype.spawn = function spawn (cmd, args, options, name) {
if (typeof args === 'string') {
args = [ args ]
}
args = args || []
if (typeof options === 'string') {
name = options
options = {}
}
options = options || {}
options.name = ownOr(options, 'name', name)
options.command = cmd
options.args = args
return this.sub(Spawn, options, spawn)
}
Test.prototype.sub = function (Class, extra, caller) {
extra = extra || {}
if (!extra.skip && this.grep.length) {
var match = this.grep[0].test(extra.name)
if (this.grepInvert) {
match = !match
}
if (!match) {
var p = 'filter' + (this.grepInvert ? ' out' : '') + ': '
extra.skip = p + this.grep[0]
}
}
if (extra.only && !this.runOnly) {
this.comment('%j has `only` set but all tests run', extra.name)
}
if (this.runOnly && !extra.only) {
extra.skip = 'filter: only'
}
if (extra.todo || extra.skip) {
this.pass(extra.name, extra)
return Promise.resolve(this)
}
if (!extra.grep) {
extra.grep = this.grep.slice(1)
extra.grepInvert = this.grepInvert
}
extra.indent = ' '
if (this.jobs > 1 && process.env.TAP_BUFFER === undefined)
extra.buffered = ownOr(extra, 'buffered', true)
else
extra.buffered = ownOrEnv(extra, 'buffered', 'TAP_BUFFER', true)
extra.bail = ownOr(extra, 'bail', this.bail)
extra.parent = this
extra.stack = stack.captureString(80, caller)
var t = new Class(extra)
this.queue.push(t)
this.subtests.push(t)
var d = new Deferred()
t.deferred = d
this.process()
return d.promise
}
Test.prototype.only = function test (name, extra, cb) {
extra = parseTestArgs(name, extra, cb)
extra.only = true
return this.sub(Test, extra, test)
}
Test.prototype.test = function test (name, extra, cb) {
extra = parseTestArgs(name, extra, cb)
return this.sub(Test, extra, test)
}
Test.prototype.stdin = function stdin (name, extra) {
extra = parseTestArgs(name, extra, function () {}, '/dev/stdin')
return this.sub(Stdin, extra || {}, stdin)
}
Test.prototype.bailout = function (message) {
if (this.parent && (this.results || this.ended))
this.parent.bailout(message)
else {
this.process()
message = message ? ' ' + ('' + message).trim() : ''
message = message.replace(/[\r\n]/g, ' ')
this.parser.write('Bail out!' + message + '\n')
}
this.end(IMPLICIT)
this.process()
}
Test.prototype.comment = function () {
var message = util.format.apply(util, arguments)
message = '# ' + message.split(/\r?\n/).join('\n# ') + '\n'
if (this.results)
this.push(message)
else
this.queue.push(message)
this.process()
}
Test.prototype.timeout = function (options) {
options = options || {}
options.expired = options.expired || this.name
if (this.occupied)
this.occupied.timeout(options)
else
Base.prototype.timeout.call(this, options)
this.end(IMPLICIT)
}
Test.prototype.main = function (cb) {
this.setTimeout(this.options.timeout)
this.debug('MAIN pre', this)
var self = this
try {
var ret = this.cb(this)
} catch (er) {
this.threw(er)
}
if (ret && ret.then) {
this.promise = ret
ret.tapAbortPromise = done
ret.then(end, done)
} else
done()
function end () {
self.debug(' > implicit end for promise')
self.end(IMPLICIT)
done()
}
function done (er) {
if (er)
self.threw(er)
if (self.results || self.bailedOut)
cb()
else
self.ondone = cb
}
this.debug('MAIN post', this)
}
Test.prototype.process = function () {
if (this.processing)
return this.debug(' < already processing')
this.debug('\nPROCESSING(%s)', this.name, this.queue.length)
this.processing = true
var p
while (!this.occupied && (p = this.queue.shift())) {
this.debug('PROCESS(%s)', this.name, p)
if (p instanceof Base) {
this.processSubtest(p)
} else if (p === EOF) {
this.debug(' > EOF', this.name)
// I AM BECOME EOF, DESTROYER OF STREAMS
this.parser.end()
} else if (p instanceof TestPoint) {
this.debug(' > TESTPOINT')
this.parser.write(p.ok + (++this.n) + p.message)
} else if (typeof p === 'string') {
this.debug(' > STRING')
this.parser.write(p)
} else if (Array.isArray(p)) {
this.debug(' > METHOD')
var m = p.shift()
this[m].apply(this, p)
} else {
throw new Error('weird thing got in the queue')
}
}
while (!this.noparallel &&
this.pool.length < this.jobs &&
(p = this.subtests.shift())) {
if (!p.buffered) {
this.noparallel = true
break
}
this.debug('start subtest', p)
this.pool.add(p)
if (this.bailedOut)
this.onbufferedend(p)
else
this.runBeforeEach(p,
p.main.bind(p,
this.onbufferedend.bind(this, p)))
}
this.debug('done processing', this.queue, this.occupied)
this.processing = false
// just in case any tests ended, and we have sync stuff still
// waiting around in the queue to be processed
if (!this.occupied && this.queue.length)
this.process()
this.maybeAutoend()
}
Test.prototype.processSubtest = function (p) {
this.debug(' > subtest')
this.occupied = p
if (!p.buffered) {
if (this.bailedOut)
return this.onindentedend(p)
this.debug(' > subtest indented')
p.pipe(this.parser, { end: false })
this.runBeforeEach(p,
this.writeSubComment.bind(this, p,
p.main.bind(p,
this.onindentedend.bind(this, p))))
} else if (p.readyToProcess) {
this.debug(' > subtest buffered, finished')
// finished! do the thing!
this.occupied = null
if (!p.passing() || !p.silent) {
this.queue.unshift(['emitSubTeardown', p])
this.printResult(p.passing(), p.name, p.options, true)
}
} else {
this.occupied = p
this.debug(' > subtest buffered, unfinished', p)
// unfinished buffered test.
// nothing to do yet, just leave it there.
this.queue.unshift(p)
}
}
Test.prototype.emitSubTeardown = function (p) {
try {
p.emit('teardown')
} catch (er) {
delete p.options.time
p.threw(er)
}
}
Test.prototype.writeSubComment = function (p, cb) {
var comment = '# Subtest'
if (p.name)
comment += ': ' + p.name
comment += '\n'
this.parser.write(comment)
cb()
}
Test.prototype.onbufferedend = function (p, er) {
delete p.ondone
p.results = p.results || {}
p.readyToProcess = true
var to = p.options.timeout
if (to && p.passing())
var dur = Date.now() - p.start
if (dur && dur > to)
p.timeout()
else
p.setTimeout(false)
this.debug('%s.onbufferedend', this.name, p.name, p.results.bailout)
this.pool.remove(p)
p.options.tapChildBuffer = p.output || ''
p.options.stack = ''
if (p.time)
p.options.time = p.time
if (this.occupied === p)
this.occupied = null
if (er)
this.threw(er)
p.deferred.resolve(this)
this.process()
}
Test.prototype.onindentedend = function (p, er) {
delete p.ondone
this.debug('onindentedend', p)
this.noparallel = false
var sti = this.subtests.indexOf(p)
if (sti !== -1)
this.subtests.splice(sti, 1)
p.readyToProcess = true
p.results = p.results || {}
if (p.time)
p.options.time = p.time
var to = p.options.timeout
if (to && p.passing())
var dur = Date.now() - p.start
if (dur && dur > to)
p.timeout()
else
p.setTimeout(false)
this.debug('onindentedend %s(%s)', this.name, p.name, er || 'ok')
assert(this.occupied === p)
this.occupied = null
this.debug('OIE(%s) b>shift into queue', this.name, this.queue)
p.options.stack = ''
this.queue.unshift(['emitSubTeardown', p])
this.printResult(p.passing(), p.name, p.options, true)
this.debug('OIE(%s) shifted into queue', this.name, this.queue)
if (er)
this.threw(er)
p.deferred.resolve(this)
this.process()
}
Test.prototype.addAssert = function (name, length, fn) {
if (!name)
throw new TypeError('name is required for addAssert')
if (!(typeof length === 'number' && length >= 0))
throw new TypeError('number of args required')
if (typeof fn !== 'function')
throw new TypeError('function required for addAssert')
if (Test.prototype[name] || this[name])
throw new TypeError('attempt to re-define `' + name + '` assert')
this[name] = function ASSERT () {
if (!this.currentAssert) {
this.currentAssert = ASSERT
}
var args = new Array(length + 2)
for (var i = 0; i < length; i++) {
args[i] = arguments[i]
}
if (typeof arguments[length] === 'object') {
args[length] = ''
args[length + 1] = arguments[length]
} else {
args[length] = arguments[length] || ''
args[length + 1] = arguments[length + 1] || {}
}
return fn.apply(this, args)
}
}
Test.prototype.fail = function fail (message, extra) {
if (!this.currentAssert) {
this.currentAssert = fail
}
if (message && typeof message === 'object') {
extra = message
message = ''
} else {
if (!message) {
message = ''
}
if (!extra) {
extra = {}
}
}
this.printResult(false, message, extra)
var ret = true
if (!extra.todo && !extra.skip)
ret = false
return ret
}
Test.prototype.pass = function pass (message, extra) {
if (!this.currentAssert) {
this.currentAssert = pass
}
this.printResult(true, message || '(unnamed test)', extra)
return true
}
Test.prototype.printResult = function pR (ok, message, extra, front) {
var n = this.count + 1
if (this.planEnd !== -1 && n > this.planEnd) {
if (!this.passing())
return
var failMessage = this.explicitEnded
? 'test after end() was called'
: 'test count exceeds plan'
var er = new Error(failMessage)
Error.captureStackTrace(er, this.currentAssert || pR)
er.test = this.name
er.plan = this.planEnd
this.threw(er)
return
}
extra = extra || {}
if (this.assertAt) {
extra.at = this.assertAt
this.assertAt = null
}
if (this.assertStack) {
extra.stack = this.assertStack
this.assertStack = null
}
if (hasOwn(extra, 'stack') && !hasOwn(extra, 'at'))
extra.at = stack.parseLine(extra.stack.split('\n')[0])
var fn = this.currentAssert || pR
this.currentAssert = null
if (!ok && !extra.skip && !hasOwn(extra, 'at')) {
assert.equal(typeof fn, 'function')
extra.at = stack.at(fn)
if (!extra.todo)
extra.stack = stack.captureString(80, fn)
}
var diagnostic
if (!ok)
diagnostic = true
if (extra.skip)
diagnostic = false
if (process.env.TAP_DIAG === '0')
diagnostic = false
if (typeof extra.diagnostic === 'boolean')
diagnostic = extra.diagnostic
if (diagnostic)
extra.diagnostic = true
this.count = n
var res = { ok: ok, message: message, extra: extra }
var output = new TestPoint(ok, message, extra)
// when we jump the queue, skip an extra line
if (front)
output.message = output.message.trimRight() + '\n\n'
if (front) {
this.emit('result', res)
this.parser.write(output.ok + (++this.n) + output.message)
} else
this.queue.push(['emit', 'result', res], output)
if (this.planEnd === this.count)
this.end(IMPLICIT)
this.process()
}
Test.prototype.pragma = function (set) {
var p = ''
Object.keys(set).forEach(function (i) {
p += 'pragma ' + (set[i] ? '+' : '-') + i + '\n'
})
this.queue.push(p)
this.process()
}
Test.prototype.plan = function (n, comment) {
if (this.bailedOut)
return
if (this.planEnd !== -1) {
throw new Error('Cannot set plan more than once')
}
if (typeof n !== 'number' || n < 0) {
throw new TypeError('plan must be a number')
}
// Cannot get any tests after a trailing plan, or a plan of 0
var ending = false
if (this.count !== 0 || n === 0) {
ending = true
}
if (n === 0)
this.skip = comment || true
this.planEnd = n
comment = comment ? ' # ' + comment.trim() : ''
this.queue.push('1..' + n + comment + '\n')
if (ending)
this.end(IMPLICIT)
else
this.process()
}
Test.prototype.done = Test.prototype.end = function (implicit) {
this.debug('END implicit=%j', implicit === IMPLICIT)
if (this.ended && implicit === IMPLICIT)
return
// beyond here we have to be actually done with things, or else
// the semantic checks on counts and such will be off.
if (!queueEmpty(this) || this.occupied) {
if (!this.pushedEnd)
this.queue.push(['end', implicit])
this.pushedEnd = true
return this.process()
}
if (!this.ranAfterEach && this.parent) {
this.ranAfterEach = true
this.parent.runAfterEach(this, end.bind(this, implicit))
} else
end.call(this, implicit)
}
function end (implicit) {
this.ended = true
if (implicit !== IMPLICIT && !this.multiEndThrew) {
if (this.explicitEnded) {
this.multiEndThrew = true
var er = new Error('test end() method called more than once')
Error.captureStackTrace(er, this.currentAssert || end)
er.test = this.name
this.threw(er)
return
}
this.explicitEnded = true
}
if (this.planEnd === -1) {
this.debug('END(%s) implicit plan', this.name, this.count)
this.plan(this.count)
}
this.queue.push(EOF)
this.process()
}
Test.prototype.threw = function (er, extra, proxy) {
this.debug('THREW', er.message, extra, proxy)
// event emitters 'error' events need to re-throw so that they
// can jump out of the flow like a normal throw. They'll just
// end up back here once that happens, though, unless there's a
// try/catch somewhere in the call stack.
if (er.domainEmitter) {
delete er.domainEmitter
throw er
}
if (this.name && !proxy)
er.test = this.name
if (!proxy)
extra = extraFromError(er, extra, this.options)
Base.prototype.threw.call(this, er, extra, proxy)
if (!this.results) {
this.fail(extra.message || er.message, extra)
if (!proxy)
this.end(IMPLICIT)
}
this.process()
}
Test.prototype.runBeforeEach = function (who, cb) {
var self = this
if (this.parent)
this.parent.runBeforeEach(who, function () {
loop(who, self.onBeforeEach, cb, who.threw)
})
else
loop(who, self.onBeforeEach, cb, who.threw)
}
Test.prototype.runAfterEach = function (who, cb) {
var self = this
loop(who, self.onAfterEach, function () {
if (self.parent)
self.parent.runAfterEach(who, cb)
else
cb()
}, who.threw)
}
Test.prototype.beforeEach = function (fn) {
this.onBeforeEach.push(fn)
}
Test.prototype.afterEach = function (fn) {
this.onAfterEach.push(fn)
}
Test.prototype.teardown = Test.prototype.tearDown = function (fn) {
this.on('teardown', fn)
}
Test.prototype.shouldAutoend = function () {
var should = (
this.options.autoend &&
!this.ended &&
!this.occupied &&
queueEmpty(this) &&
!this.pool.length &&
!this.subtests.length &&
this.planEnd === -1
)
return should
}
Test.prototype.autoend = function () {
this.options.autoend = true
this.maybeAutoend()
}
Test.prototype.maybeAutoend = function () {
if (this.autoendTimer)
clearTimeout(this.autoendTimer)
if (this.shouldAutoend()) {
var self = this
self.autoendTimer = setTimeout(function () {
if (self.shouldAutoend()) {
self.autoendTimer = setTimeout(function () {
if (self.shouldAutoend()) {
self.end(IMPLICIT)
}
})
}
})
}
}
function endAllQueue (queue) {
queue.forEach(function (p, i) {
if ((p instanceof Base) && !p.readyToProcess)
queue[i] = new TestPoint(false,
'child test left in queue ' + p.constructor.name + ': ' +
p.name, p.options)
})
queue.push(['end', IMPLICIT])
}
function queueEmpty (t) {
return t.queue.length === 0 ||
t.queue.length === 1 && t.queue[0] === 'TAP version 13\n'
}
Test.prototype.endAll = function (sub) {
this.processing = true
if (this.occupied) {
var p = this.occupied
if (p.endAll)
p.endAll(true)
else {
p.parser.abort('test unfinished')
}
} else if (sub) {
this.process()
if (queueEmpty(this)) {
var options = Object.keys(this.options).reduce(function (o, k) {
o[k] = this.options[k]
return o
}.bind(this), {})
this.options.at = null
this.options.stack = ''
options.test = this.name
this.fail('test unfinished', options)
}
}
if (this.promise && this.promise.tapAbortPromise)
this.promise.tapAbortPromise()
if (this.occupied) {
this.queue.unshift(this.occupied)
this.occupied = null
}
endAllQueue(this.queue)
this.processing = false
this.process()
this.parser.end()
}
// Add all the asserts
tapAsserts.decorate(Test.prototype)

112
static/js/ketcher2/node_modules/tap/package.json generated vendored Normal file
View File

@ -0,0 +1,112 @@
{
"_from": "tap@10.7.0",
"_id": "tap@10.7.0",
"_inBundle": false,
"_integrity": "sha512-rIKS3HvtA+/6weSQW8zgA8bKHt//Srucp6P1pugHUVZ+SexZcPw6N3n8LCAoH2okp/js+honhxwBl7bomZ9+7w==",
"_location": "/tap",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "tap@10.7.0",
"name": "tap",
"escapedName": "tap",
"rawSpec": "10.7.0",
"saveSpec": null,
"fetchSpec": "10.7.0"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/tap/-/tap-10.7.0.tgz",
"_shasum": "ecde1ebd2b86981f741ae089f1448c9f294ac548",
"_spec": "tap@10.7.0",
"_where": "/home/manfred/enviPath/ketcher2/ketcher",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me"
},
"bin": {
"tap": "bin/run.js"
},
"bugs": {
"url": "https://github.com/tapjs/node-tap/issues"
},
"bundleDependencies": false,
"config": {
"nyc": {
"exclude": [
"node_modules/**",
"test/**"
]
}
},
"dependencies": {
"bind-obj-methods": "^1.0.0",
"bluebird": "^3.3.1",
"clean-yaml-object": "^0.1.0",
"color-support": "^1.1.0",
"coveralls": "^2.11.2",
"foreground-child": "^1.3.3",
"fs-exists-cached": "^1.0.0",
"function-loop": "^1.0.1",
"glob": "^7.0.0",
"isexe": "^2.0.0",
"js-yaml": "^3.3.1",
"nyc": "^11.0.2-candidate.0",
"opener": "^1.4.1",
"os-homedir": "^1.0.2",
"own-or": "^1.0.0",
"own-or-env": "^1.0.0",
"readable-stream": "^2.3.2",
"signal-exit": "^3.0.0",
"source-map-support": "^0.4.3",
"stack-utils": "^1.0.0",
"tap-mocha-reporter": "^3.0.6",
"tap-parser": "^5.3.1",
"tmatch": "^3.1.0",
"trivial-deferred": "^1.0.1",
"tsame": "^1.1.2",
"yapool": "^1.0.0"
},
"deprecated": false,
"description": "A Test-Anything-Protocol library",
"devDependencies": {
"mkdirp": "^0.5.1",
"rimraf": "^2.5.4",
"standard": "^7.1.2",
"which": "^1.1.1"
},
"engines": {
"node": ">=0.8"
},
"files": [
"bin/*",
"lib/*"
],
"homepage": "http://node-tap.org/",
"keywords": [
"assert",
"test",
"tap"
],
"license": "ISC",
"main": "lib/tap.js",
"name": "tap",
"repository": {
"type": "git",
"url": "git+https://github.com/tapjs/node-tap.git"
},
"scripts": {
"postpublish": "git push origin --all; git push origin --tags",
"posttest": "standard lib test",
"postversion": "npm publish",
"preversion": "npm test",
"regen-fixtures": "node scripts/generate-test-test.js test/test/*.js",
"smoke": "node bin/run.js --node-arg=test/test.js test/test/*.js -j2",
"t": "node bin/run.js test/*.* -sfails.txt",
"test": "node bin/run.js test/*.* --coverage -t3600 -sfails"
},
"version": "10.7.0"
}