☕️ Classic, reliable, trusted test framework for Node.js and the browser
first pass on site
Tj Holowaychuk934762954b69
diff --git a/History.md b/History.mddeleted file mode 100644index 91d11de3..00000000--- a/History.md+++ /dev/null@@ -1,32 +0,0 @@--0.0.1-alpha5 / 2011-11-17-==================-- * Added `doc` reporter. Closes #33- * Added suite merging. Closes #28- * Added TextMate bundle and `make tm`. Closes #20--0.0.1-alpha4 / 2011-11-15-==================-- * Fixed getWindowSize() for 0.4.x--0.0.1-alpha3 / 2011-11-15-==================-- * Added `-s, --slow <ms>` to specify "slow" test threshold- * Added `mocha-debug(1)`- * Added `mocha.opts` support. Closes #31- * Added: default [files] to _test/*.js_- * Added protection against multiple calls to `done()`. Closes #35- * Changed: bright yellow for slow Dot reporter tests--0.0.1-alpha1 / 2011-11-08-==================-- * Missed this one :)--0.0.1-alpha1 / 2011-11-08-==================-- * Initial releasediff --git a/Makefile b/Makefileindex 5b0eb18f..51fbe983 100644--- a/Makefile+++ b/Makefile@@ -1,49 +1,10 @@-REPORTER = dot-TM_DEST = ~/Library/Application\ Support/TextMate/Bundles-TM_BUNDLE = JavaScript\ mocha.tmbundle-SRC = $(shell find lib -name "*.js" -type f)--mocha.js: $(SRC)- @node support/compile $^- @cat support/tail.js >> mocha.js+index.html: head.html foot.html index.md+ @markdown < index.md \+ | cat head.html - foot.html \+ > $@clean:- rm -f mocha.js--test: test-unit--test-all: test-bdd test-tdd test-exports test-unit test-grep--test-unit:- @./bin/mocha \- --reporter $(REPORTER)--test-bdd:- @./bin/mocha \- --reporter $(REPORTER) \- --ui bdd \- test/interfaces/bdd--test-tdd:- @./bin/mocha \- --reporter $(REPORTER) \- --ui tdd \- test/interfaces/tdd--test-exports:- @./bin/mocha \- --reporter $(REPORTER) \- --ui exports \- test/interfaces/exports--test-grep:- @./bin/mocha \- --reporter $(REPORTER) \- --grep fast \- test/misc/grep--tm:- cp -fr editors/$(TM_BUNDLE) $(TM_DEST)/$(TM_BUNDLE)+ rm -f index.html-.PHONY: test test-all test-bdd test-tdd test-exports test-unit test-grep tm clean\ No newline at end of file+.PHONY: clean\ No newline at end of filediff --git a/Readme.md b/Readme.mddeleted file mode 100644index a8e9cae7..00000000--- a/Readme.md+++ /dev/null@@ -1,393 +0,0 @@--# mocha-- Mocha is a _simple_, _fun_, _extensible_ JavaScript test framework rich with features, running on [node](http://nodejs.org) and the browser. Mocha tests run serially, allowing reporting flexibility, and mapping uncaught exceptions to the correct test cases; This also makes Mocha an ideal choice when mocking and stubbing is involved.-- Mocha allows you to use any assertion library you want, if it throws an error, it will work. This means you can utilize libraries such as [should](http://github.com/visionmedia/should.js), node's regular `assert` module, or others.-- Testing asynchronous code with Mocha could not be simpler, when your tests are sync simple omit the callback, when they are async add a callback and invoke it when your test is complete.---## Features-- - proper exit status for CI support etc- - ideal for asynchronous APIs- - auto-detects and disables coloring for non-ttys- - maps uncaught exceptions to the correct test case- - async test timeout support- - growl notification support- - reports test durations- - highlights slow tests- - global variable leak detection- - configurable test-case timeout- - optionally run tests that match a regexp- - auto-exit to prevent "hanging" due to an active event loop- - easily meta-generate suites & test-cases- - mocha.opts file support- - `mocha-debug(1)` for node debugger support- - detects multiple calls to `done()`- - TextMate bundle- - use any assertion library you want ([should](http://github.com/visionmedia/should.js), `assert`, etc)- - extensible reporting- - `dot`: a dot matrix- - `doc`: a documentation generator (html) based on your tests- - `landing`: a unicode landing strip ✈- - `tap`: test-anything-protocol (TAP) producer- - `progress`: a progress bar- - `spec`: hierarchical specification- - `list`: similar to `spec` as a flat-list- - `json-stream`: streaming JSON delimited by a LF- - `json`: a single JSON chunk on exit- - extensible test DSLs- - BDD- - TDD- - exports--## Usage--```--Usage: mocha [options] [files]--Options:-- -h, --help output usage information- -V, --version output the version number- -r, --require <name> require the given module- -R, --reporter <name> specify the reporter to use- -u, --ui <name> specify user-interface (bdd|tdd|exports)- -g, --grep <pattern> only run tests matching <pattern>- -t, --timeout <ms> set test-case timeout in milliseconds [2000]- -s, --slow <ms> "slow" test threshold in milliseconds [75]- -G, --growl enable growl support--Reporters:-- dot - dot matrix- doc - html documentation- json - single json object- progress - progress bar- list - spec-style listing- tap - test-anything-protocol- landing - unicode landing strip- json-stream - newline delimited json events--Interfaces:-- bdd - describe() / it()- tdd - suite() / test()- exports - module.exports--```--## Interfaces-- Mocha "interfaces" providing BDD, TDD, and expresso export-style flavoured APIs on top of the internals.--### BDD--```js-describe('Array', function(){- before(function(){- // ...- });-- describe('#indexOf()', function(){- it('should return -1 when not present', function(){- [1,2,3].indexOf(4).should.equal(-1);- });-- it('should return the index when present', function(){- [1,2,3].indexOf(3).should.equal(2);- [1,2,3].indexOf(2).should.equal(1);- [1,2,3].indexOf(1).should.equal(0);- });- });-});-```--### TDD--```js-suite('Array', function(){- setup(function(){- // ...- });-- suite('#indexOf()', function(){- test('should return -1 when not present', function(){- assert.equal(-1, [1,2,3].indexOf(4));- });-- test('should return the index when present', function(){- assert.equal(2, [1,2,3].indexOf(3));- assert.equal(1, [1,2,3].indexOf(2));- assert.equal(0, [1,2,3].indexOf(1));- });- });-});-```--### Exports--```js-module.exports = {- 'Array': {- '#indexOf()': {- 'should return -1 when not present': function(){- [1,2,3].indexOf(4).should.equal(-1);- },-- 'should return the index when present': function(){- [1,2,3].indexOf(3).should.equal(2);- [1,2,3].indexOf(2).should.equal(1);- [1,2,3].indexOf(1).should.equal(0);- }- }- }-};-```--## Reporters-- Mocha reporters adjust to the terminal window,- and always disable ansi-escape colouring when- the stdio streams are not associated with a tty.--### Dot Matrix-- The Dot Matrix reporter is simply a series of dots- that represent test cases, failures highlight in red.-- -- --## TAP-- The TAP reporter emits lines for a [Test-Anything-Protocol](http://en.wikipedia.org/wiki/Test_Anything_Protocol) consumer.-- --## Landing Strip-- The Landing Strip reporter is a gimmicky test reporter simulating- a plane landing :) unicode ftw-- --## List-- The "List" reporter outputs a simple specifications list as- test cases pass or fail, outputting the failure details at- the bottom of the output.-- -- --## JSON-- The JSON reporter outputs a single large JSON object when- the tests have completed (failures or not).--## JSON Stream-- The JSON Stream reporter outputs newline-delimited JSON "events" as they occur, beginning with a "start" event, followed by test passes or failures, and then the final "end" event.--```json-["start",{"total":12}]-["pass",{"title":"should return -1 when not present","fullTitle":"Array #indexOf() should return -1 when not present","duration":0}]-["pass",{"title":"should return the index when present","fullTitle":"Array #indexOf() should return the index when present","duration":0}]-["fail",{"title":"should return -1 when not present","fullTitle":"Array #indexOf() should return -1 when not present"}]-["end",{"start":"2011-08-29T03:21:02.050Z","suites":13,"passes":11,"tests":12,"failures":1,"end":"2011-08-29T03:21:02.052Z","duration":2}]-````--## Doc-- The "doc" reporter outputs a hierarchical HTML body representation- of your tests, wrap it with a header, footer, some styling and you- have some fantastic documentation!-- For example suppose you have the following JavaScript:--```js-describe('Array', function(){- describe('#indexOf()', function(){- it('should return -1 when the value is not present', function(){- [1,2,3].indexOf(5).should.equal(-1);- [1,2,3].indexOf(0).should.equal(-1);- })- })-})-```-- The command `mocha --reporter doc array` would yield:--```html-<section class="suite">- <h1>Array</h1>- <dl>- <section class="suite">- <h1>#indexOf()</h1>- <dl>- <dt>should return -1 when the value is not present</dt>- <dd><pre><code>[1,2,3].indexOf(5).should.equal(-1);-[1,2,3].indexOf(0).should.equal(-1);</code></pre></dd>- </dl>- </section>- </dl>-</section>-```--## Async tests-- Testing async code with mocha is simple, invoke the `done()` callback- when complete, if called multiple times (due to a race-condition etc)- will cause mocha to fail, this is invaluable for testing async code.--```js-describe('something async', function(){- it('should finish after 300ms', function(done){- setTimeout(done, 300);- })-})-```-- The `done()` callback also accepts an error, so it's easy to write- tests that adhere to node's callback convention of `(err, result)`:-- ```js- describe('User.save()', function(){- it('should save without failing', function(done){- var user = new User('tj');- user.save(done);- })- })- ```--## Best practices--### test/*-- By default `mocha(1)` will use the pattern `./test/*.js`, so- it's usually a good place to put your tests.--### mocha.opts-- Mocha will attempt to load `./test/mocha.opts`, these are concatenated with `process.argv`, though command-line args will take precedence. For example suppose you have the following _mocha.opts_ file:--```---require should---reporter dot---ui bdd-```-- This will default the reporter to `dot`, require the `should` library,- and use `bdd` as the interface. With this you may then invoke `mocha(1)`- with additional arguments, here enabling growl support and changing- the reporter to `spec`:--```-$ mocha --reporter list --growl-```--### Suite merging-- Suites with common names are "merged" in order- to produce unified reporting, especially when- meta-generating tests.--```js-describe('merge', function(){- describe('stuff', function(){- describe('one', function(){- it('should do something', function(){-- })- })- })-})--describe('merge', function(){- describe('stuff', function(){- describe('two', function(){- it('should do something', function(){-- })- })- })-})--describe('merge stuff', function(){- describe('three', function(){- it('should do something', function(){-- })- })-})-```--will produce the following:-- --### Makefiles-- Be kind and don't make developers hunt around in your docs to figure- out how to run the tests, add a `make test` target to your _Makefile_:--```-test:- ./node_modules/.bin/mocha \- --reporter list--.PHONY: test-```--## TextMate Bundle-- The Mocha TextMate bundle includes snippets to- make writing tests quicker and more enjoyable.- To install the bundle run:-- $ make tm--## Running tests-- Run mocha tests:-- $ make test-- Run all tests, including interfaces:-- $ make test-all-- Alter the reporter:-- $ make test REPORTER=list--## License--(The MIT License)--Copyright (c) 2011 TJ Holowaychuk <[email protected]>--Permission is hereby granted, free of charge, to any person obtaining-a copy of this software and associated documentation files (the-'Software'), to deal in the Software without restriction, including-without limitation the rights to use, copy, modify, merge, publish,-distribute, sublicense, and/or sell copies of the Software, and to-permit persons to whom the Software is furnished to do so, subject to-the following conditions:--The above copyright notice and this permission notice shall be-included in all copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\ No newline at end of filediff --git a/bin/mocha b/bin/mochadeleted file mode 100755index c162ad84..00000000--- a/bin/mocha+++ /dev/null@@ -1,179 +0,0 @@-#!/usr/bin/env node--/**- * Module dependencies.- */--var program = require('commander')- , exec = require('child_process').exec- , path = require('path')- , mocha = require('../')- , reporters = mocha.reporters- , interfaces = mocha.interfaces- , Runner = mocha.Runner- , Suite = mocha.Suite- , vm = require('vm')- , fs = require('fs')- , join = path.join- , cwd = process.cwd();--/**- * Files.- */--var files = [];--// options--program- .version(mocha.version)- .usage('[options] [files]')- .option('-r, --require <name>', 'require the given module')- .option('-R, --reporter <name>', 'specify the reporter to use', 'dot')- .option('-u, --ui <name>', 'specify user-interface (bdd|tdd|exports)', 'bdd')- .option('-g, --grep <pattern>', 'only run tests matching <pattern>')- .option('-t, --timeout <ms>', 'set test-case timeout in milliseconds [2000]', parseInt)- .option('-s, --slow <ms>', '"slow" test threshold in milliseconds [75]', parseInt)- .option('-G, --growl', 'enable growl support')--// report help--program.on('--help', function(){- console.log(' Reporters:');- console.log('');- console.log(' dot - dot matrix');- console.log(' doc - html documentation');- console.log(' json - single json object');- console.log(' progress - progress bar');- console.log(' list - spec-style listing');- console.log(' tap - test-anything-protocol');- console.log(' landing - unicode landing strip');- console.log(' json-stream - newline delimited json events');- console.log('');-- console.log(' Interfaces:');- console.log('');- console.log(' bdd - describe() / it()');- console.log(' tdd - suite() / test()');- console.log(' exports - module.exports');- console.log('');-});--// -r, --require--program.on('require', function(mod){- require(mod);-});--// mocha.opts support--try {- var opts = fs.readFileSync('test/mocha.opts', 'utf8');- opts = opts.split(/\s+/).slice(0, -1);- process.argv = process.argv- .slice(0, 2)- .concat(opts.concat(process.argv.slice(2)));-} catch (err) {- // ignore-}--// parse args--program.parse(process.argv);--// infinite stack traces--Error.stackTraceLimit = Infinity; // TODO: config--// reporter--var suite = new Suite('')- , Base = require('../lib/reporters/base')- , Reporter = require('../lib/reporters/' + program.reporter)- , ui = interfaces[program.ui](suite);--// --slow <ms>--if (program.slow) Base.slow = program.slow;--// --timeout--if (program.timeout) suite.timeout(program.timeout);--// files--var files = program.args;--// default files to test/*.js--if (!files.length) {- files = fs.readdirSync('test').filter(function(path){- return path.match(/\.js$/);- }).map(function(path){- return join('test', path);- });-}--// require test files before running-// the root suite--var pending = files.length;-files.forEach(function(file){- file = join(cwd, file);- suite.emit('pre-require', global, file);- suite.emit('require', require(file), file);- suite.emit('post-require', global, file);- --pending || run(suite);-});--// run the given suite--function run(suite) {- suite.emit('run');- var runner = new Runner(suite);- var reporter = new Reporter(runner);- if (program.grep) runner.grep(new RegExp(program.grep));- if (program.growl) growl(runner, reporter)- runner.run();-}--// enable growl notifications--function growl(runner, reporter) {- runner.on('end', function(){- var stats = reporter.stats;- if (stats.failures) {- var msg = stats.failures + ' of ' + stats.tests + ' tests failed';- notify(msg, { title: 'Failed' });- } else {- notify(stats.passes + ' tests passed in ' + stats.duration + 'ms', {- title: 'Passed'- });- }- });-}--// growl notification--function notify(msg, options) {- var image- , args = ['growlnotify', '-m', '"' + msg + '"']- , options = options || {}- , fn = fn || function(){};-- if (image = options.image) {- var flag, ext = path.extname(image).substr(1)- flag = flag || ext == 'icns' && 'iconpath'- flag = flag || /^[A-Z]/.test(image) && 'appIcon'- flag = flag || /^png|gif|jpe?g$/.test(ext) && 'image'- flag = flag || ext && (image = ext) && 'icon'- flag = flag || 'icon'- args.push('--' + flag, image)- }-- if (options.sticky) args.push('--sticky');- if (options.priority) args.push('--priority', options.priority);- if (options.name) args.push('--name', options.name);- if (options.title) args.push(options.title);- exec(args.join(' '), fn);-}\ No newline at end of filediff --git a/bin/mocha-debug b/bin/mocha-debugdeleted file mode 100755index 0968bcf8..00000000--- a/bin/mocha-debug+++ /dev/null@@ -1,3 +0,0 @@-#!/usr/bin/env node debug--require('./mocha');\ No newline at end of filediff --git a/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet b/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippetdeleted file mode 100644index e76cae13..00000000--- a/editors/JavaScript mocha.tmbundle/Snippets/bdd - after each.tmSnippet+++ /dev/null@@ -1,16 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>content</key>- <string>afterEach(function(){- $0-})</string>- <key>name</key>- <string>bdd - after each</string>- <key>tabTrigger</key>- <string>ae</string>- <key>uuid</key>- <string>7B4DA8F4-2064-468B-B252-054148419B4B</string>-</dict>-</plist>diff --git a/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet b/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippetdeleted file mode 100644index f1a67aa1..00000000--- a/editors/JavaScript mocha.tmbundle/Snippets/bdd - after.tmSnippet+++ /dev/null@@ -1,16 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>content</key>- <string>after(function(){- $0-})</string>- <key>name</key>- <string>bdd - after</string>- <key>tabTrigger</key>- <string>a</string>- <key>uuid</key>- <string>A49A87F9-399E-4D74-A489-C535BB06D487</string>-</dict>-</plist>diff --git a/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet b/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippetdeleted file mode 100644index f8442fa5..00000000--- a/editors/JavaScript mocha.tmbundle/Snippets/bdd - before each.tmSnippet+++ /dev/null@@ -1,16 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>content</key>- <string>beforeEach(function(){- $0-})</string>- <key>name</key>- <string>bdd - before each</string>- <key>tabTrigger</key>- <string>be</string>- <key>uuid</key>- <string>7AB064E3-EFBB-4FA7-98CA-9E87C10CC04E</string>-</dict>-</plist>diff --git a/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet b/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippetdeleted file mode 100644index 5c7e40fb..00000000--- a/editors/JavaScript mocha.tmbundle/Snippets/bdd - before.tmSnippet+++ /dev/null@@ -1,16 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>content</key>- <string>before(function(){- $0-})</string>- <key>name</key>- <string>bdd - before</string>- <key>tabTrigger</key>- <string>b</string>- <key>uuid</key>- <string>DF6F1F42-F80A-4A24-AF78-376F19070C4C</string>-</dict>-</plist>diff --git a/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet b/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippetdeleted file mode 100644index 8cd3fb17..00000000--- a/editors/JavaScript mocha.tmbundle/Snippets/bdd - it.tmSnippet+++ /dev/null@@ -1,16 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>content</key>- <string>it('should $1', function(){- $0-})</string>- <key>name</key>- <string>bdd - it</string>- <key>tabTrigger</key>- <string>it</string>- <key>uuid</key>- <string>591AE071-95E4-4E1E-B0F3-A7DAF41595EE</string>-</dict>-</plist>diff --git a/editors/JavaScript mocha.tmbundle/Snippets/untitled.tmSnippet b/editors/JavaScript mocha.tmbundle/Snippets/untitled.tmSnippetdeleted file mode 100644index 46fd7206..00000000--- a/editors/JavaScript mocha.tmbundle/Snippets/untitled.tmSnippet+++ /dev/null@@ -1,16 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>content</key>- <string>describe('$1', function(){- $0-})</string>- <key>name</key>- <string>bdd - describe</string>- <key>tabTrigger</key>- <string>des</string>- <key>uuid</key>- <string>4AA1FB50-9BB9-400E-A140-D61C39BDFDF5</string>-</dict>-</plist>diff --git a/editors/JavaScript mocha.tmbundle/info.plist b/editors/JavaScript mocha.tmbundle/info.plistdeleted file mode 100644index 16f6587a..00000000--- a/editors/JavaScript mocha.tmbundle/info.plist+++ /dev/null@@ -1,19 +0,0 @@-<?xml version="1.0" encoding="UTF-8"?>-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">-<plist version="1.0">-<dict>- <key>name</key>- <string>JavaScript mocha</string>- <key>ordering</key>- <array>- <string>4AA1FB50-9BB9-400E-A140-D61C39BDFDF5</string>- <string>591AE071-95E4-4E1E-B0F3-A7DAF41595EE</string>- <string>DF6F1F42-F80A-4A24-AF78-376F19070C4C</string>- <string>A49A87F9-399E-4D74-A489-C535BB06D487</string>- <string>7AB064E3-EFBB-4FA7-98CA-9E87C10CC04E</string>- <string>7B4DA8F4-2064-468B-B252-054148419B4B</string>- </array>- <key>uuid</key>- <string>094ACE33-0C0E-422A-B3F7-5B919F5B1239</string>-</dict>-</plist>diff --git a/foot.html b/foot.htmlnew file mode 100644index 00000000..1fd5f4f2--- /dev/null+++ b/foot.html@@ -0,0 +1,2 @@+ </body>+</html>\ No newline at end of filediff --git a/head.html b/head.htmlnew file mode 100644index 00000000..7f7f2fce--- /dev/null+++ b/head.html@@ -0,0 +1,15 @@+<!DOCTYPE html>+<html>+ <head>+ <title>Mocha - the fun, simple, flexible JavaScript test framework</title>+ <link rel="stylesheet" href="style.css" />+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <script>+ onload = function(){+ document.body.setAttribute('class', 'onload');+ };+ </script>+ </head>+ <body>+ <h1><a href="http://github.com/visionmedia/mocha">Mocha</a></h1>+ <p id="tag"><em>simple</em>, <em>flexible</em>, <em>fun</em></p>diff --git a/images/concrete_wall_3.png b/images/concrete_wall_3.pngnew file mode 100644index 00000000..5d04a21cBinary files /dev/null and b/images/concrete_wall_3.png differdiff --git a/images/handmadepaper.png b/images/handmadepaper.pngnew file mode 100644index 00000000..27c305faBinary files /dev/null and b/images/handmadepaper.png differdiff --git a/images/soft_wallpaper.png b/images/soft_wallpaper.pngnew file mode 100644index 00000000..0fc74d97Binary files /dev/null and b/images/soft_wallpaper.png differdiff --git a/images/whitey.png b/images/whitey.pngnew file mode 100644index 00000000..365c61afBinary files /dev/null and b/images/whitey.png differdiff --git a/index.html b/index.htmlnew file mode 100644index 00000000..a8dfd48a--- /dev/null+++ b/index.html@@ -0,0 +1,377 @@+<!DOCTYPE html>+<html>+ <head>+ <title>Mocha - the fun, simple, flexible JavaScript test framework</title>+ <link rel="stylesheet" href="style.css" />+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <script>+ onload = function(){+ document.body.setAttribute('class', 'onload');+ };+ </script>+ </head>+ <body>+ <h1><a href="http://github.com/visionmedia/mocha">Mocha</a></h1>+ <p id="tag"><em>simple</em>, <em>flexible</em>, <em>fun</em></p>+<p>Mocha is a feature-rich JavaScript test framework running on <a href="http://nodejs.org">node</a> and the browser, aiming to make async testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.</p>++<h2>Features</h2>++<ul>+<li>proper exit status for CI support etc</li>+<li>ideal for asynchronous APIs</li>+<li>auto-detects and disables coloring for non-ttys</li>+<li>maps uncaught exceptions to the correct test case</li>+<li>async test timeout support</li>+<li>growl notification support</li>+<li>reports test durations</li>+<li>highlights slow tests</li>+<li>global variable leak detection</li>+<li>configurable test-case timeout</li>+<li>optionally run tests that match a regexp</li>+<li>auto-exit to prevent “hanging” with an active loop</li>+<li>easily meta-generate suites & test-cases</li>+<li>mocha.opts file support</li>+<li><code>mocha-debug(1)</code> for node debugger support</li>+<li>detects multiple calls to <code>done()</code></li>+<li>use any assertion library you want</li>+<li>extensible reporting, bundled with 9+ reporters</li>+<li>extensible test DSLs or “interfaces”</li>+<li>before, after, before each, after each hooks</li>+<li>TextMate bundle</li>+</ul>+++<h2>Installation</h2>++<p> Install with <a href="http://npmjs.org">npm</a>:</p>++<pre><code>$ npm install -g mocha+</code></pre>++<h2>Assertions</h2>++<p>Mocha allows you to use any assertion library you want, if it throws an error, it will work! This means you can utilize libraries such as <a href="http://github.com/visionmedia/should.js">should.js</a>, node’s regular <code>assert</code> module, or others.</p>++<h2>Synchronous code</h2>++<p> When testing synchronous code, omit the callback and Mocha will automatically continue on to the next test.</p>++<pre><code>describe('Array', function(){+ describe('#indexOf()', function(){+ it('should return -1 when the value is not present', function(){+ [1,2,3].indexOf(5).should.equal(-1);+ [1,2,3].indexOf(0).should.equal(-1);+ })+ })+})+</code></pre>++<h2>Asynchronous code</h2>++<p>Testing asynchronous code with Mocha could not be simpler! Simply invoke the callback when your test is complete:</p>++<pre><code>describe('User', function(){+ describe('#save()', function(){+ it('should save without error', function(done){+ var user = new User('Luna');+ user.save(function(err){+ if (err) throw err;+ done();+ });+ })+ })+})+</code></pre>++<p> To make things even easier, the <code>done()</code> callback accepts an error, so we may use this directly:</p>++<pre><code>describe('User', function(){+ describe('#save()', function(){+ it('should save without error', function(done){+ var user = new User('Luna');+ user.save(done);+ })+ })+})+</code></pre>++<h2>Pending tests</h2>++<p> Pending test-cases are simply those without a callback:</p>++<pre><code>describe('Array', function(){+ describe('#indexOf()', function(){+ it('should return -1 when the value is not present')+ })+})+</code></pre>++<h2>mocha(1)</h2>++<pre><code>Usage: mocha [options] [files]++Options:++ -h, --help output usage information+ -V, --version output the version number+ -r, --require <name> require the given module+ -R, --reporter <name> specify the reporter to use+ -u, --ui <name> specify user-interface (bdd|tdd|exports)+ -g, --grep <pattern> only run tests matching <pattern>+ -t, --timeout <ms> set test-case timeout in milliseconds [2000]+ -s, --slow <ms> "slow" test threshold in milliseconds [75]+ -G, --growl enable growl support+</code></pre>++<h2>mocha-debug(1)</h2>++<p> <code>mocha-debug(1)</code> is identical to <code>mocha(1)</code>, however it enables node’s debugger so you may step through tests with the <strong>debugger</strong> statement.</p>++<h2>Interfaces</h2>++<p> Mocha “interface” system allows developers to choose their style of DSL. Shipping with <strong>BDD</strong>, <strong>TDD</strong>, and <strong>export</strong> flavoured interfaces.</p>++<h3>BDD</h3>++<p> The “<strong>BDD</strong>” interface provides <code>describe()</code>, <code>it()</code>, <code>before()</code>, <code>after()</code>, <code>beforeEach()</code>, and <code>afterEach()</code>:</p>++<pre><code>describe('Array', function(){+ before(function(){+ // ...+ });++ describe('#indexOf()', function(){+ it('should return -1 when not present', function(){+ [1,2,3].indexOf(4).should.equal(-1);+ });+ });+});+</code></pre>++<h3>TDD</h3>++<p> The “<strong>TDD</strong>” interface provides <code>suite()</code>, <code>test()</code>, <code>setup()</code>, and <code>teardown()</code>.</p>++<pre><code>suite('Array', function(){+ setup(function(){+ // ...+ });++ suite('#indexOf()', function(){+ test('should return -1 when not present', function(){+ assert.equal(-1, [1,2,3].indexOf(4));+ });+ });+});+</code></pre>++<h3>Exports</h3>++<p> The “<strong>exports</strong>” interface is much like Mocha’s predecessor <a href="http://github.com/visionmedia/expresso">expresso</a>. The keys <code>before</code>, <code>after</code>, <code>beforeEach</code>, and <code>afterEach</code> are special-cased, object values+ are suites, and function values are test-cases.</p>++<pre><code>module.exports = {+ before: function(){+ // ...+ },++ 'Array': {+ '#indexOf()': {+ 'should return -1 when not present': function(){+ [1,2,3].indexOf(4).should.equal(-1);+ }+ }+ }+};+</code></pre>++<h2>Reporters</h2>++<p> Mocha reporters adjust to the terminal window,+ and always disable ansi-escape colouring when+ the stdio streams are not associated with a tty.</p>++<h3>Dot Matrix</h3>++<p> The Dot Matrix reporter is simply a series of dots+ that represent test cases, failures highlight in red.</p>++<p> <img src="http://f.cl.ly/items/3b3b471Z1p2U3D1P2Y1n/Screenshot.png" alt="dot matrix reporter" /></p>++<p> <img src="http://f.cl.ly/items/1P11330L033r423g1y1n/Screenshot.png" alt="dot matrix failure" /></p>++<h2>TAP</h2>++<p> The TAP reporter emits lines for a <a href="http://en.wikipedia.org/wiki/Test_Anything_Protocol">Test-Anything-Protocol</a> consumer.</p>++<p> <img src="http://f.cl.ly/items/2O0X3h0d1Q430O1t1T3p/Screenshot.png" alt="test anything protocol" /></p>++<h2>Landing Strip</h2>++<p> The Landing Strip reporter is a gimmicky test reporter simulating+ a plane landing :) unicode ftw</p>++<p> <img src="http://f.cl.ly/items/0z1k400K1N1Y2G3u2u0i/Screenshot.png" alt="landing strip plane reporter" /></p>++<h2>List</h2>++<p> The “List” reporter outputs a simple specifications list as+ test cases pass or fail, outputting the failure details at+ the bottom of the output.</p>++<p> <img src="http://f.cl.ly/items/0Y0x1B3l3K0n3t3h3l0p/Screenshot.png" alt="list reporter" /></p>++<p> <img src="http://f.cl.ly/items/2Z0E150v20042G2d1J0i/Screenshot.png" alt="failures" /></p>++<h2>JSON</h2>++<p> The JSON reporter outputs a single large JSON object when+ the tests have completed (failures or not).</p>++<h2>JSON Stream</h2>++<p> The JSON Stream reporter outputs newline-delimited JSON “events” as they occur, beginning with a “start” event, followed by test passes or failures, and then the final “end” event.</p>++<pre><code>["start",{"total":12}]+["pass",{"title":"should return -1 when not present","fullTitle":"Array #indexOf() should return -1 when not present","duration":0}]+["pass",{"title":"should return the index when present","fullTitle":"Array #indexOf() should return the index when present","duration":0}]+["fail",{"title":"should return -1 when not present","fullTitle":"Array #indexOf() should return -1 when not present"}]+["end",{"start":"2011-08-29T03:21:02.050Z","suites":13,"passes":11,"tests":12,"failures":1,"end":"2011-08-29T03:21:02.052Z","duration":2}]+</code></pre>++<h2>Doc</h2>++<p> The “doc” reporter outputs a hierarchical HTML body representation+ of your tests, wrap it with a header, footer, some styling and you+ have some fantastic documentation!</p>++<p> For example suppose you have the following JavaScript:</p>++<pre><code>describe('Array', function(){+ describe('#indexOf()', function(){+ it('should return -1 when the value is not present', function(){+ [1,2,3].indexOf(5).should.equal(-1);+ [1,2,3].indexOf(0).should.equal(-1);+ })+ })+})+</code></pre>++<p> The command <code>mocha --reporter doc array</code> would yield:</p>++<pre><code><section class="suite">+ <h1>Array</h1>+ <dl>+ <section class="suite">+ <h1>#indexOf()</h1>+ <dl>+ <dt>should return -1 when the value is not present</dt>+ <dd><pre><code>[1,2,3].indexOf(5).should.equal(-1);+[1,2,3].indexOf(0).should.equal(-1);</code></pre></dd>+ </dl>+ </section>+ </dl>+</section>+</code></pre>++<h3>mocha.opts</h3>++<p> Mocha will attempt to load <code>./test/mocha.opts</code>, these are concatenated with <code>process.argv</code>, though command-line args will take precedence. For example suppose you have the following <em>mocha.opts</em> file:</p>++<pre><code>--require should+--reporter dot+--ui bdd+</code></pre>++<p> This will default the reporter to <code>dot</code>, require the <code>should</code> library,+ and use <code>bdd</code> as the interface. With this you may then invoke <code>mocha(1)</code>+ with additional arguments, here enabling growl support and changing+ the reporter to <code>spec</code>:</p>++<pre><code>$ mocha --reporter list --growl+</code></pre>++<h3>Suite merging</h3>++<p> Suites with common names are “merged” in order+ to produce unified reporting, especially when+ meta-generating tests.</p>++<pre><code>describe('merge', function(){+ describe('stuff', function(){+ describe('one', function(){+ it('should do something', function(){})+ })+ })+})++describe('merge', function(){+ describe('stuff', function(){+ describe('two', function(){+ it('should do something', function(){})+ })+ })+})++describe('merge stuff', function(){+ describe('three', function(){+ it('should do something', function(){})+ })+})+</code></pre>++<p>will produce the following:</p>++<p> <img src="http://f.cl.ly/items/380R3S1t1t0b0O2K250V/Screenshot.png" alt="mocha suite merging" /></p>++<h2>Best practices</h2>++<h3>test/*</h3>++<p> By default <code>mocha(1)</code> will use the pattern <code>./test/*.js</code>, so+ it’s usually a good place to put your tests.</p>++<h3>Makefiles</h3>++<p> Be kind and don’t make developers hunt around in your docs to figure+ out how to run the tests, add a <code>make test</code> target to your <em>Makefile</em>:</p>++<pre><code> test:+ ./node_modules/.bin/mocha \+ --reporter list++ .PHONY: test+</code></pre>++<h2>Editors</h2>++<p> The following editor-related packages are available:</p>++<h3>TextMate bundle</h3>++<p> The Mocha TextMate bundle includes snippets to+ make writing tests quicker and more enjoyable.+ To install the bundle run:</p>++<pre><code> $ make tm+</code></pre>++<h2>Running mocha’s tests</h2>++<p> Run the tests:</p>++<pre><code> $ make test+</code></pre>++<p> Run all tests, including interfaces:</p>++<pre><code> $ make test-all+</code></pre>++<p> Alter the reporter:</p>++<pre><code> $ make test REPORTER=list+</code></pre>+ </body>+</html>\ No newline at end of filediff --git a/index.md b/index.mdnew file mode 100644index 00000000..c0d2bb92--- /dev/null+++ b/index.md@@ -0,0 +1,338 @@++Mocha is a feature-rich JavaScript test framework running on [node](http://nodejs.org) and the browser, aiming to make async testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.++## Features++ - proper exit status for CI support etc+ - ideal for asynchronous APIs+ - auto-detects and disables coloring for non-ttys+ - maps uncaught exceptions to the correct test case+ - async test timeout support+ - growl notification support+ - reports test durations+ - highlights slow tests+ - global variable leak detection+ - configurable test-case timeout+ - optionally run tests that match a regexp+ - auto-exit to prevent "hanging" with an active loop+ - easily meta-generate suites & test-cases+ - mocha.opts file support+ - `mocha-debug(1)` for node debugger support+ - detects multiple calls to `done()`+ - use any assertion library you want+ - extensible reporting, bundled with 9+ reporters+ - extensible test DSLs or "interfaces"+ - before, after, before each, after each hooks+ - TextMate bundle++## Installation++ Install with [npm](http://npmjs.org):++ $ npm install -g mocha++## Assertions++Mocha allows you to use any assertion library you want, if it throws an error, it will work! This means you can utilize libraries such as [should.js](http://github.com/visionmedia/should.js), node's regular `assert` module, or others.++## Synchronous code++ When testing synchronous code, omit the callback and Mocha will automatically continue on to the next test.++ describe('Array', function(){+ describe('#indexOf()', function(){+ it('should return -1 when the value is not present', function(){+ [1,2,3].indexOf(5).should.equal(-1);+ [1,2,3].indexOf(0).should.equal(-1);+ })+ })+ })++## Asynchronous code++Testing asynchronous code with Mocha could not be simpler! Simply invoke the callback when your test is complete:++ describe('User', function(){+ describe('#save()', function(){+ it('should save without error', function(done){+ var user = new User('Luna');+ user.save(function(err){+ if (err) throw err;+ done();+ });+ })+ })+ })++ To make things even easier, the `done()` callback accepts an error, so we may use this directly:++ describe('User', function(){+ describe('#save()', function(){+ it('should save without error', function(done){+ var user = new User('Luna');+ user.save(done);+ })+ })+ })++## Pending tests++ Pending test-cases are simply those without a callback:++ describe('Array', function(){+ describe('#indexOf()', function(){+ it('should return -1 when the value is not present')+ })+ })++## mocha(1)++ Usage: mocha [options] [files]++ Options:++ -h, --help output usage information+ -V, --version output the version number+ -r, --require <name> require the given module+ -R, --reporter <name> specify the reporter to use+ -u, --ui <name> specify user-interface (bdd|tdd|exports)+ -g, --grep <pattern> only run tests matching <pattern>+ -t, --timeout <ms> set test-case timeout in milliseconds [2000]+ -s, --slow <ms> "slow" test threshold in milliseconds [75]+ -G, --growl enable growl support++## mocha-debug(1)++ `mocha-debug(1)` is identical to `mocha(1)`, however it enables node's debugger so you may step through tests with the __debugger__ statement.++## Interfaces++ Mocha "interface" system allows developers to choose their style of DSL. Shipping with __BDD__, __TDD__, and __export__ flavoured interfaces.++### BDD++ The "__BDD__" interface provides `describe()`, `it()`, `before()`, `after()`, `beforeEach()`, and `afterEach()`:++ describe('Array', function(){+ before(function(){+ // ...+ });++ describe('#indexOf()', function(){+ it('should return -1 when not present', function(){+ [1,2,3].indexOf(4).should.equal(-1);+ });+ });+ });++### TDD++ The "__TDD__" interface provides `suite()`, `test()`, `setup()`, and `teardown()`.++ suite('Array', function(){+ setup(function(){+ // ...+ });++ suite('#indexOf()', function(){+ test('should return -1 when not present', function(){+ assert.equal(-1, [1,2,3].indexOf(4));+ });+ });+ });++### Exports++ The "__exports__" interface is much like Mocha's predecessor [expresso](http://github.com/visionmedia/expresso). The keys `before`, `after`, `beforeEach`, and `afterEach` are special-cased, object values+ are suites, and function values are test-cases.++ module.exports = {+ before: function(){+ // ...+ },++ 'Array': {+ '#indexOf()': {+ 'should return -1 when not present': function(){+ [1,2,3].indexOf(4).should.equal(-1);+ }+ }+ }+ };++## Reporters++ Mocha reporters adjust to the terminal window,+ and always disable ansi-escape colouring when+ the stdio streams are not associated with a tty.++### Dot Matrix++ The Dot Matrix reporter is simply a series of dots+ that represent test cases, failures highlight in red.++ ++ ++## TAP++ The TAP reporter emits lines for a [Test-Anything-Protocol](http://en.wikipedia.org/wiki/Test_Anything_Protocol) consumer.++ ++## Landing Strip++ The Landing Strip reporter is a gimmicky test reporter simulating+ a plane landing :) unicode ftw++ ++## List++ The "List" reporter outputs a simple specifications list as+ test cases pass or fail, outputting the failure details at+ the bottom of the output.++ ++ ++## JSON++ The JSON reporter outputs a single large JSON object when+ the tests have completed (failures or not).++## JSON Stream++ The JSON Stream reporter outputs newline-delimited JSON "events" as they occur, beginning with a "start" event, followed by test passes or failures, and then the final "end" event.++ ["start",{"total":12}]+ ["pass",{"title":"should return -1 when not present","fullTitle":"Array #indexOf() should return -1 when not present","duration":0}]+ ["pass",{"title":"should return the index when present","fullTitle":"Array #indexOf() should return the index when present","duration":0}]+ ["fail",{"title":"should return -1 when not present","fullTitle":"Array #indexOf() should return -1 when not present"}]+ ["end",{"start":"2011-08-29T03:21:02.050Z","suites":13,"passes":11,"tests":12,"failures":1,"end":"2011-08-29T03:21:02.052Z","duration":2}]++## Doc++ The "doc" reporter outputs a hierarchical HTML body representation+ of your tests, wrap it with a header, footer, some styling and you+ have some fantastic documentation!++ For example suppose you have the following JavaScript:++ describe('Array', function(){+ describe('#indexOf()', function(){+ it('should return -1 when the value is not present', function(){+ [1,2,3].indexOf(5).should.equal(-1);+ [1,2,3].indexOf(0).should.equal(-1);+ })+ })+ })++ The command `mocha --reporter doc array` would yield:++ <section class="suite">+ <h1>Array</h1>+ <dl>+ <section class="suite">+ <h1>#indexOf()</h1>+ <dl>+ <dt>should return -1 when the value is not present</dt>+ <dd><pre><code>[1,2,3].indexOf(5).should.equal(-1);+ [1,2,3].indexOf(0).should.equal(-1);</code></pre></dd>+ </dl>+ </section>+ </dl>+ </section>++### mocha.opts++ Mocha will attempt to load `./test/mocha.opts`, these are concatenated with `process.argv`, though command-line args will take precedence. For example suppose you have the following _mocha.opts_ file:++ --require should+ --reporter dot+ --ui bdd++ This will default the reporter to `dot`, require the `should` library,+ and use `bdd` as the interface. With this you may then invoke `mocha(1)`+ with additional arguments, here enabling growl support and changing+ the reporter to `spec`:++ $ mocha --reporter list --growl++### Suite merging++ Suites with common names are "merged" in order+ to produce unified reporting, especially when+ meta-generating tests.++ describe('merge', function(){+ describe('stuff', function(){+ describe('one', function(){+ it('should do something', function(){})+ })+ })+ })++ describe('merge', function(){+ describe('stuff', function(){+ describe('two', function(){+ it('should do something', function(){})+ })+ })+ })++ describe('merge stuff', function(){+ describe('three', function(){+ it('should do something', function(){})+ })+ })++will produce the following:++ ++## Best practices++### test/*++ By default `mocha(1)` will use the pattern `./test/*.js`, so+ it's usually a good place to put your tests.++### Makefiles++ Be kind and don't make developers hunt around in your docs to figure+ out how to run the tests, add a `make test` target to your _Makefile_:++ test:+ ./node_modules/.bin/mocha \+ --reporter list++ .PHONY: test++## Editors++ The following editor-related packages are available:++### TextMate bundle++ The Mocha TextMate bundle includes snippets to+ make writing tests quicker and more enjoyable.+ To install the bundle run:++ $ make tm++## Running mocha's tests++ Run the tests:++ $ make test++ Run all tests, including interfaces:++ $ make test-all++ Alter the reporter:++ $ make test REPORTER=listdiff --git a/lib/browser/events.js b/lib/browser/events.jsdeleted file mode 100644index dfcd4ee5..00000000--- a/lib/browser/events.js+++ /dev/null@@ -1,53 +0,0 @@--/**- * Expose `EventEmitter`.- */--exports.EventEmitter = EventEmitter;--/**- * Slice reference.- */--var slice = [].slice;--/**- * EventEmitter.- */--function EventEmitter() {- this.callbacks = {};-};--/**- * Listen on the given `event` with `fn`.- *- * @param {String} event- * @param {Function} fn- */--EventEmitter.prototype.on = function(event, fn){- (this.callbacks[event] = this.callbacks[event] || [])- .push(fn);- return this;-};--/**- * Emit `event` with the given args.- *- * @param {String} event- * @param {Mixed} ...- */--EventEmitter.prototype.emit = function(event){- var args = slice.call(arguments, 1)- , callbacks = this.callbacks[event];-- if (callbacks) {- for (var i = 0, len = callbacks.length; i < len; ++i) {- callbacks[i].apply(this, args)- }- }-- return this;-};diff --git a/lib/browser/tty.js b/lib/browser/tty.jsdeleted file mode 100644index 2d843740..00000000--- a/lib/browser/tty.js+++ /dev/null@@ -1,8 +0,0 @@--exports.isatty = function(){- return true;-};--exports.getWindowSize = function(){- return [window.innerHeight, window.innerWidth];-};\ No newline at end of filediff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.jsdeleted file mode 100644index 1a06567c..00000000--- a/lib/interfaces/bdd.js+++ /dev/null@@ -1,86 +0,0 @@--/**- * Module dependencies.- */--var Suite = require('../suite')- , Test = require('../test');--/**- * BDD-style interface:- *- * describe('Array', function(){- * describe('#indexOf()', function(){- * it('should return -1 when not present', function(){- *- * });- *- * it('should return the index when present', function(){- *- * });- * });- * });- *- */--module.exports = function(suite){- var suites = [suite];-- suite.on('pre-require', function(context){-- /**- * Execute before running tests.- */-- context.before = function(fn){- suites[0].beforeAll(fn);- };-- /**- * Execute after running tests.- */-- context.after = function(fn){- suites[0].afterAll(fn);- };-- /**- * Execute before each test case.- */-- context.beforeEach = function(fn){- suites[0].beforeEach(fn);- };-- /**- * Execute after each test case.- */-- context.afterEach = function(fn){- suites[0].afterEach(fn);- };-- /**- * Describe a "suite" with the given `title`- * and callback `fn` containing nested suites- * and/or tests.- */-- context.describe = function(title, fn){- var suite = Suite.create(suites[0], title);- suites.unshift(suite);- fn();- suites.shift();- };-- /**- * Describe a specification or test-case- * with the given `title` and callback `fn`- * acting as a thunk.- */-- context.it = function(title, fn){- suites[0].addTest(new Test(title, fn));- };- });-};diff --git a/lib/interfaces/exports.js b/lib/interfaces/exports.jsdeleted file mode 100644index b22607e0..00000000--- a/lib/interfaces/exports.js+++ /dev/null@@ -1,60 +0,0 @@--/**- * Module dependencies.- */--var Suite = require('../suite')- , Test = require('../test');--/**- * TDD-style interface:- *- * exports.Array = {- * '#indexOf()': {- * 'should return -1 when the value is not present': function(){- *- * },- *- * 'should return the correct index when the value is present': function(){- *- * }- * }- * };- *- */--module.exports = function(suite){- var suites = [suite];-- suite.on('require', visit);-- function visit(obj) {- var suite;- for (var key in obj) {- if ('function' == typeof obj[key]) {- var fn = obj[key];- switch (key) {- case 'before':- suites[0].beforeAll(fn);- break;- case 'after':- suites[0].afterAll(fn);- break;- case 'beforeEach':- suites[0].beforeEach(fn);- break;- case 'afterEach':- suites[0].afterEach(fn);- break;- default:- suites[0].addTest(new Test(key, fn));- }- } else {- var suite = Suite.create(suites[0], key);- suites.unshift(suite);- visit(obj[key]);- suites.shift();- }- }- }-};\ No newline at end of filediff --git a/lib/interfaces/index.js b/lib/interfaces/index.jsdeleted file mode 100644index 0dc76674..00000000--- a/lib/interfaces/index.js+++ /dev/null@@ -1,4 +0,0 @@--exports.bdd = require('./bdd');-exports.tdd = require('./tdd');-exports.exports = require('./exports');\ No newline at end of filediff --git a/lib/interfaces/tdd.js b/lib/interfaces/tdd.jsdeleted file mode 100644index e3ae6eb3..00000000--- a/lib/interfaces/tdd.js+++ /dev/null@@ -1,70 +0,0 @@--/**- * Module dependencies.- */--var Suite = require('../suite')- , Test = require('../test');--/**- * TDD-style interface:- *- * suite('Array', function(){- * suite('#indexOf()', function(){- * test('should return -1 when not present', function(){- *- * });- *- * test('should return the index when present', function(){- *- * });- * });- * });- *- */--module.exports = function(suite){- var suites = [suite];-- suite.on('pre-require', function(context){-- /**- * Execute before each test case.- */-- context.setup = function(fn){- suites[0].beforeEach(fn);- };-- /**- * Execute before each test case.- */-- context.tearDown = function(fn){- suites[0].afterEach(fn);- };-- /**- * Describe a "suite" with the given `title`- * and callback `fn` containing nested suites- * and/or tests.- */-- context.suite = function(title, fn){- var suite = Suite.create(suites[0], title);- suites.unshift(suite);- fn();- suites.shift();- };-- /**- * Describe a specification or test-case- * with the given `title` and callback `fn`- * acting as a thunk.- */-- context.test = function(title, fn){- suites[0].addTest(new Test(title, fn));- };- });-};diff --git a/lib/mocha.js b/lib/mocha.jsdeleted file mode 100644index 52630165..00000000--- a/lib/mocha.js+++ /dev/null@@ -1,18 +0,0 @@--/*!- * mocha- * Copyright(c) 2011 TJ Holowaychuk <[email protected]>- * MIT Licensed- */--/**- * Library version.- */--exports.version = '0.0.1-alpha5';--exports.interfaces = require('./interfaces');-exports.reporters = require('./reporters');-exports.Runner = require('./runner');-exports.Suite = require('./suite');-exports.Test = require('./test');\ No newline at end of filediff --git a/lib/reporters/base.js b/lib/reporters/base.jsdeleted file mode 100644index 007ecc5c..00000000--- a/lib/reporters/base.js+++ /dev/null@@ -1,218 +0,0 @@--/**- * Module dependencies.- */--var tty = require('tty');--/**- * Check if both stdio streams are associated with a tty.- */--var isatty = tty.isatty(1) && tty.isatty(2);--/**- * Expose `Base`.- */--exports = module.exports = Base;--/**- * Enable coloring by default.- */--exports.useColors = isatty;--/**- * Default color map.- */--exports.colors = {- 'pass': 90- , 'fail': 31- , 'pending': 36- , 'suite': '40'- , 'error title': 0- , 'error message': 31- , 'error stack': 90- , 'checkmark': 32- , 'fast': 90- , 'medium': 33- , 'slow': 31-};--/**- * Color `str` with the given `type`,- * allowing colors to be disabled,- * as well as user-defined color- * schemes.- *- * @param {String} type- * @param {String} str- * @return {String}- * @api private- */--var color = exports.color = function(type, str) {- if (!exports.useColors) return str;- return '\033[' + exports.colors[type] + 'm' + str + '\033[0m';-};--/**- * Expose term window size, with some- * defaults for when stderr is not a tty.- */--exports.window = {- width: isatty- ? process.stdout.getWindowSize- ? process.stdout.getWindowSize(1)[0]- : tty.getWindowSize()[1]- : 75-};--/**- * Expose some basic cursor interactions- * that are common among reporters.- */--exports.cursor = {- hide: function(){- process.stdout.write('\033[?25l');- },-- show: function(){- process.stdout.write('\033[?25h');- }-};--/**- * A test is considered slow if it- * exceeds the following value in milliseconds.- */--exports.slow = 75;--/**- * Outut the given `failures` as a list.- *- * @param {Array} failures- * @api public- */--exports.list = function(failures){- console.error();- failures.forEach(function(test, i){- // format- var fmt = color('error title', ' %s) %s: ')- + color('error message', '%s')- + color('error stack', '\n%s\n');-- // msg- var stack = test.err.stack- , index = stack.indexOf('at')- , msg = stack.slice(0, index);-- // indent stack trace without msg- stack = stack.slice(index)- .replace(/^/gm, ' ');-- console.error(fmt, i, test.fullTitle(), msg, stack);- });-};--/**- * Initialize a new `Base` reporter.- *- * All other reporters generally- * inherit from this reporter, providing- * stats such as test duration, number- * of tests passed / failed etc.- *- * @param {Runner} runner- * @api public- */--function Base(runner) {- var self = this- , stats = this.stats = { suites: 0, tests: 0, passes: 0, failures: 0 }- , failures = this.failures = [];-- if (!runner) return;-- runner.on('start', function(){- stats.start = new Date;- });-- runner.on('suite', function(suite){- stats.suites = stats.suites || 0;- stats.suites++;- });-- runner.on('test end', function(test){- stats.tests = stats.tests || 0;- stats.tests++;- });-- runner.on('pass', function(test){- stats.passes = stats.passes || 0;-- var medium = exports.slow / 2;- test.speed = test.duration > exports.slow- ? 'slow'- : test.duration > medium- ? 'medium'- : 'fast';-- stats.passes++;- });-- runner.on('fail', function(test, err){- stats.failures = stats.failures || 0;- stats.failures++;- test.err = err;- failures.push(test);- });-- runner.on('end', function(){- stats.end = new Date;- stats.duration = new Date - stats.start;- });-}--/**- * Output common epilogue used by many of- * the bundled reporters.- *- * @api public- */--Base.prototype.epilogue = function(){- var stats = this.stats;-- console.log();-- // failure- if (stats.failures) {- console.error(- ' \033[91m✖\033[31m %d of %d tests failed\033[90m:\033[0m'- , stats.failures, stats.tests);- Base.list(this.failures);- console.error();- process.nextTick(function(){- process.exit(stats.failures);- });- return;- }-- // pass- console.log(- ' \033[92m✔\033[32m %d tests completed\033[90m (%dms)\033[0m'- , stats.tests || 0- , stats.duration);-- console.log();- process.nextTick(function(){- process.exit(0);- });-};diff --git a/lib/reporters/doc.js b/lib/reporters/doc.jsdeleted file mode 100644index a65c5b2e..00000000--- a/lib/reporters/doc.js+++ /dev/null@@ -1,77 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base');--/**- * Expose `Doc`.- */--exports = module.exports = Doc;--/**- * Initialize a new `Doc` reporter.- *- * @param {Runner} runner- * @api public- */--function Doc(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , total = runner.total- , indents = 2;-- function indent() {- return Array(indents).join(' ');- }-- runner.on('suite', function(suite){- if (suite.root) return;- ++indents;- console.log('%s<section class="suite">', indent());- ++indents;- console.log('%s<h1>%s</h1>', indent(), suite.title);- console.log('%s<dl>', indent());- });-- runner.on('suite end', function(suite){- if (suite.root) return;- console.log('%s</dl>', indent());- --indents;- console.log('%s</section>', indent());- --indents;- });-- runner.on('pass', function(test){- console.log('%s<dt>%s</dt>', indent(), test.title);- var code = clean(test.fn.toString());- console.log('%s<dd><pre><code>%s</code></pre></dd>', indent(), code);- });-- runner.on('end', function(){- process.exit(stats.failures);- });-}--/**- * Strip the function definition from `str`,- * and re-indent for pre whitespace.- */--function clean(str) {- str = str- .replace(/^function *\(.*\) *{/, '')- .replace(/\s+\}$/, '');-- var spaces = str.match(/^\n?( *)/)[1].length- , re = new RegExp('^ {' + spaces + '}', 'gm');-- str = str.replace(re, '');-- return str;-}\ No newline at end of filediff --git a/lib/reporters/dot.js b/lib/reporters/dot.jsdeleted file mode 100644index f1adb38c..00000000--- a/lib/reporters/dot.js+++ /dev/null@@ -1,62 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `Dot`.- */--exports = module.exports = Dot;--/**- * Initialize a new `Dot` matrix test reporter.- *- * @param {Runner} runner- * @api public- */--function Dot(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , width = Base.window.width * .75 | 0- , n = 0;-- runner.on('start', function(){- process.stdout.write('\n ');- });-- runner.on('pending', function(test){- process.stdout.write(color('pending', '.'));- });-- runner.on('pass', function(test){- if (++n % width == 0) process.stdout.write('\n ');- if ('slow' == test.speed) {- process.stdout.write('\033[93m.\033[0m');- } else {- process.stdout.write(color(test.speed, '.'));- }- });-- runner.on('fail', function(test, err){- if (++n % width == 0) process.stdout.write('\n ');- process.stdout.write(color('fail', '.'));- });-- runner.on('end', function(){- console.log();- self.epilogue();- });-}--/**- * Inherit from `Base.prototype`.- */--Dot.prototype.__proto__ = Base.prototype;\ No newline at end of filediff --git a/lib/reporters/html.js b/lib/reporters/html.jsdeleted file mode 100644index 75a32110..00000000--- a/lib/reporters/html.js+++ /dev/null@@ -1,115 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base');--/**- * Expose `Doc`.- */--exports = module.exports = HTML;--/**- * Initialize a new `Doc` reporter.- *- * @param {Runner} runner- * @api public- */--function HTML(runner) {- Base.call(this, runner);-- // TODO: clean up-- var self = this- , stats = this.stats- , total = runner.total- , root = document.getElementById('mocha')- , stack = [root]- , stat = document.createElement('div');-- stat.innerHTML = '<ul id="stats">'- + '<li class="passes">passes: <em>0</em></li>'- + '<li class="failures">failures: <em>0</em></li>'- + '</ul>';-- if (!root) error('#mocha div missing, add it to your document');-- document.body.appendChild(root);- document.body.appendChild(stat);-- runner.on('suite', function(suite){- if (suite.root) return;-- // suite- var el = document.createElement('div');- el.setAttribute('class', 'suite');-- // title- var title = document.createElement('h1');- title.textContent = suite.title;- el.appendChild(title);-- // container- stack[0].appendChild(el);- stack.unshift(document.createElement('div'));- el.appendChild(stack[0]);- });-- runner.on('suite end', function(suite){- if (suite.root) return;- stack.shift();- });-- runner.on('test end', function(test){- console.log(stats);- // test- var el = document.createElement('div');- el.setAttribute('class', 'test ' + (test.passed ? 'pass' : 'fail'));-- // title- var title = document.createElement('h2');- title.textContent = test.title;- el.appendChild(title);-- // code- var pre = document.createElement('pre');- var code = document.createElement('code');- pre.appendChild(code);- code.textContent = clean(test.fn.toString());- el.appendChild(pre);-- stack[0].appendChild(el);- });-- runner.on('end', function(){- process.exit(stats.failures);- });-}--function error(msg) {- // TODO: nicer- throw new Error(msg);-}--/**- * Strip the function definition from `str`,- * and re-indent for pre whitespace.- */--function clean(str) {- str = str- .replace(/^function *\(.*\) *{/, '')- .replace(/\s+\}$/, '');-- var spaces = str.match(/^\n?( *)/)[1].length- , re = new RegExp('^ {' + spaces + '}', 'gm');-- str = str- .replace(re, '')- .replace(/^\s+/, '');-- return str;-}\ No newline at end of filediff --git a/lib/reporters/index.js b/lib/reporters/index.jsdeleted file mode 100644index 2120c280..00000000--- a/lib/reporters/index.js+++ /dev/null@@ -1,11 +0,0 @@--exports.Base = require('./base');-exports.Dot = require('./dot');-exports.Doc = require('./doc');-exports.TAP = require('./tap');-exports.JSON = require('./json');-exports.HTML = require('./html');-exports.List = require('./list');-exports.Progress = require('./progress');-exports.Landing = require('./landing');-exports.JSONStream = require('./json-stream');diff --git a/lib/reporters/json-stream.js b/lib/reporters/json-stream.jsdeleted file mode 100644index f6956791..00000000--- a/lib/reporters/json-stream.js+++ /dev/null@@ -1,63 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `List`.- */--exports = module.exports = List;--/**- * Initialize a new `List` test reporter.- *- * @param {Runner} runner- * @api public- */--function List(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , total = runner.total;-- runner.on('start', function(){- console.log(JSON.stringify(['start', { total: total }]));- });-- runner.on('pass', function(test){- console.log(JSON.stringify(['pass', clean(test)]));- });-- runner.on('fail', function(test, err){- console.log(JSON.stringify(['fail', clean(test)]));- });-- runner.on('end', function(){- process.stdout.write(JSON.stringify(['end', self.stats]), function(){- process.exit(0);- });- });-}--/**- * Return a plain-object representation of `test`- * free of cyclic properties etc.- *- * @param {Object} test- * @return {Object}- * @api private- */--function clean(test) {- return {- title: test.title- , fullTitle: test.fullTitle()- , duration: test.duration- }-}\ No newline at end of filediff --git a/lib/reporters/json.js b/lib/reporters/json.jsdeleted file mode 100644index d6edce98..00000000--- a/lib/reporters/json.js+++ /dev/null@@ -1,72 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `JSON`.- */--exports = module.exports = JSONReporter;--/**- * Initialize a new `JSON` reporter.- *- * @param {Runner} runner- * @api public- */--function JSONReporter(runner) {- var self = this;- Base.call(this, runner);-- var tests = []- , failures = []- , passes = [];-- runner.on('test end', function(test){- tests.push(test);- });-- runner.on('pass', function(test){- passes.push(test);- });-- runner.on('fail', function(test){- failures.push(test);- });-- runner.on('end', function(){- var obj = {- stats: self.stats- , tests: tests.map(clean)- , failures: failures.map(clean)- , passes: passes.map(clean)- };-- process.stdout.write(JSON.stringify(obj), function(){- process.exit(0);- });- });-}--/**- * Return a plain-object representation of `test`- * free of cyclic properties etc.- *- * @param {Object} test- * @return {Object}- * @api private- */--function clean(test) {- return {- title: test.title- , fullTitle: test.fullTitle()- , duration: test.duration- }-}\ No newline at end of filediff --git a/lib/reporters/landing.js b/lib/reporters/landing.jsdeleted file mode 100644index ceab6d8d..00000000--- a/lib/reporters/landing.js+++ /dev/null@@ -1,97 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `Landing`.- */--exports = module.exports = Landing;--/**- * Airplane color.- */--Base.colors.plane = 0;--/**- * Airplane crash color.- */--Base.colors['plane crash'] = 31;--/**- * Runway color.- */--Base.colors.runway = 90;--/**- * Initialize a new `Landing` reporter.- *- * @param {Runner} runner- * @api public- */--function Landing(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , width = Base.window.width * .75 | 0- , total = runner.total- , stream = process.stdout- , plane = color('plane', '✈')- , crashed = -1- , n = 0;-- function runway() {- var buf = Array(width).join('-');- return ' ' + color('runway', buf);- }-- runner.on('start', function(){- stream.write('\n ');- cursor.hide();- });-- runner.on('test end', function(test){- // check if the plane crashed- var col = -1 == crashed- ? width * ++n / total | 0- : crashed;-- // show the crash- if (test.failed) {- plane = color('plane crash', '✈');- crashed = col;- }-- // render landing strip- stream.write('\033[4F\n\n');- stream.write(runway());- stream.write('\n ');- stream.write(color('runway', Array(col).join('⋅')));- stream.write(plane)- stream.write(color('runway', Array(width - col).join('⋅') + '\n'));- stream.write(runway());- stream.write('\033[0m');- });-- runner.on('end', function(){- cursor.show();- console.log();- self.epilogue();- });-}--/**- * Inherit from `Base.prototype`.- */--Landing.prototype.__proto__ = Base.prototype;\ No newline at end of filediff --git a/lib/reporters/list.js b/lib/reporters/list.jsdeleted file mode 100644index 60acc4fd..00000000--- a/lib/reporters/list.js+++ /dev/null@@ -1,61 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `List`.- */--exports = module.exports = List;--/**- * Initialize a new `List` test reporter.- *- * @param {Runner} runner- * @api public- */--function List(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , n = 0;-- runner.on('start', function(){- console.log();- });-- runner.on('test', function(test){- process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));- });-- runner.on('pending', function(test){- var fmt = color('checkmark', ' -')- + color('pending', ' %s');- console.log(fmt, test.fullTitle());- });-- runner.on('pass', function(test){- var fmt = color('checkmark', ' ✓')- + color('pass', ' %s: ')- + color(test.speed, '%dms');- console.log('\r' + fmt, test.fullTitle(), test.duration);- });-- runner.on('fail', function(test, err){- console.log('\r' + color('fail', ' %d) %s'), n++, test.fullTitle());- });-- runner.on('end', self.epilogue.bind(self));-}--/**- * Inherit from `Base.prototype`.- */--List.prototype.__proto__ = Base.prototype;\ No newline at end of filediff --git a/lib/reporters/progress.js b/lib/reporters/progress.jsdeleted file mode 100644index 423c9825..00000000--- a/lib/reporters/progress.js+++ /dev/null@@ -1,84 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `Progress`.- */--exports = module.exports = Progress;--/**- * General progress bar color.- */--Base.colors.progress = 90;--/**- * Initialize a new `Progress` bar test reporter.- *- * @param {Runner} runner- * @param {Object} options- * @api public- */--function Progress(runner, options) {- Base.call(this, runner);-- var self = this- , options = options || {}- , stats = this.stats- , width = Base.window.width * .50 | 0- , total = runner.total- , complete = 0- , max = Math.max;-- // default chars- options.open = options.open || '[';- options.complete = options.complete || '▬';- options.incomplete = options.incomplete || '⋅';- options.close = options.close || ']';- options.verbose = false;-- // tests started- runner.on('start', function(){- console.log();- cursor.hide();- });-- // tests complete- runner.on('test end', function(){- var incomplete = total - complete- , percent = complete++ / total- , n = width * percent | 0- , i = width - n;-- process.stdout.write('\r\033[J');- process.stdout.write(color('progress', ' ' + options.open));- process.stdout.write(Array(n).join(options.complete));- process.stdout.write(Array(i).join(options.incomplete));- process.stdout.write(color('progress', options.close));- if (options.verbose) {- process.stdout.write(color('progress', ' ' + complete + ' of ' + total));- }- });-- // tests are complete, output some stats- // and the failures if any- runner.on('end', function(){- cursor.show();- console.log();- self.epilogue();- });-}--/**- * Inherit from `Base.prototype`.- */--Progress.prototype.__proto__ = Base.prototype;\ No newline at end of filediff --git a/lib/reporters/spec.js b/lib/reporters/spec.jsdeleted file mode 100644index 8efc3936..00000000--- a/lib/reporters/spec.js+++ /dev/null@@ -1,83 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `Spec`.- */--exports = module.exports = Spec;--/**- * Initialize a new `Spec` test reporter.- *- * @param {Runner} runner- * @api public- */--function Spec(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , indents = 0- , n = 0;-- function indent() {- return Array(indents).join(' ')- }-- runner.on('start', function(){- console.log();- });-- runner.on('suite', function(suite){- ++indents;- console.log(color('suite', '%s%s'), indent(), suite.title);- });-- runner.on('suite end', function(suite){- --indents;- if (1 == indents) console.log();- });-- runner.on('test', function(test){- process.stdout.write(indent() + color('pass', test.title + ': '));- });-- runner.on('pending', function(test){- var fmt = indent() + color('pending', ' - %s');- console.log(fmt, test.title);- });-- runner.on('pass', function(test){- if ('fast' == test.speed) {- var fmt = indent()- + color('checkmark', ' ✓')- + color('pass', ' %s ');- console.log('\r' + fmt, test.title);- } else {- var fmt = indent()- + color('checkmark', ' ✓')- + color('pass', ' %s ')- + color(test.speed, '(%dms)');- console.log('\r' + fmt, test.title, test.duration);- }- });-- runner.on('fail', function(test, err){- console.log('\r' + indent() + color('fail', ' %d) %s'), n++, test.title);- });-- runner.on('end', self.epilogue.bind(self));-}--/**- * Inherit from `Base.prototype`.- */--Spec.prototype.__proto__ = Base.prototype;\ No newline at end of filediff --git a/lib/reporters/tap.js b/lib/reporters/tap.jsdeleted file mode 100644index ef584972..00000000--- a/lib/reporters/tap.js+++ /dev/null@@ -1,50 +0,0 @@--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `TAP`.- */--exports = module.exports = TAP;--/**- * Initialize a new `TAP` reporter.- *- * @param {Runner} runner- * @api public- */--function TAP(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , total = runner.total- , n = 1;-- runner.on('start', function(){- console.log(' %d..%d', 1, total);- });-- runner.on('test end', function(){- ++n;- });-- runner.on('pass', function(test){- console.log(' ok %d %s', n, test.fullTitle());- });-- runner.on('fail', function(test){- console.log(' not ok %d %s', n, test.fullTitle());- });-- runner.on('end', function(){- process.exit(stats.failures);- });-}\ No newline at end of filediff --git a/lib/runner.js b/lib/runner.jsdeleted file mode 100644index 5c919e6c..00000000--- a/lib/runner.js+++ /dev/null@@ -1,302 +0,0 @@--/**- * Module dependencies.- */--var EventEmitter = require('events').EventEmitter- , Test = require('./test')- , noop = function(){};--/**- * Expose `Runner`.- */--module.exports = Runner;--/**- * Initialize a `Runner` for the given `suite`.- *- * Events:- *- * - `start` execution started- * - `end` execution complete- * - `suite` (suite) test suite execution started- * - `suite end` (suite) all tests (and sub-suites) have finished- * - `test` (test) test execution started- * - `test end` (test) test completed- * - `pass` (test) test passed- * - `fail` (test, err) test failed- *- * @api public- */--function Runner(suite) {- this.suite = suite;- this.total = suite.total();- this.globals = Object.keys(global).concat(['errno']);- this.on('test end', this.checkGlobals.bind(this));- this.grep(/.*/);-}--/**- * Inherit from `EventEmitter.prototype`.- */--Runner.prototype.__proto__ = EventEmitter.prototype;--/**- * Run tests with full titles matching `re`.- *- * @param {RegExp} re- * @return {Runner} for chaining- * @api public- */--Runner.prototype.grep = function(re){- this._grep = re;- return this;-};--/**- * Check for global variable leaks.- *- * @api private- */--Runner.prototype.checkGlobals = function(test){- var leaks = Object.keys(global).filter(function(key){- return !~this.globals.indexOf(key);- }, this);-- this.globals = this.globals.concat(leaks);-- if (leaks.length > 1) {- this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));- } else if (leaks.length) {- this.fail(test, new Error('global leak detected: ' + leaks[0]));- }-};--/**- * Fail the given `test`.- *- * @param {Test} test- * @param {Error} err- * @api private- */--Runner.prototype.fail = function(test, err){- test.failed = true;- this.emit('fail', test, err);-};--/**- * Fail the given `hook` name.- *- * @param {String} hook- * @param {Error} err- * @api private- */--Runner.prototype.failHook = function(hook, err){- var test = new Test(hook + ' hook', noop);- test.parent = this.suite;- this.fail(test, err);- this.emit('end');- process.exit(0);-};--/**- * Run hook `name` callbacks and then invoke `fn(err)`.- *- * @param {String} name- * @param {Function} function- * @api private- */--Runner.prototype.hook = function(name, fn){- var suite = this.suite- , test = this.test- , callbacks = suite[name + 'Callbacks']- , pending = callbacks.length;-- function next(i) {- var callback = callbacks[i]- if (!callback) return fn();-- // async- if (1 == callback.length) {- // async- try {- callback(function(err){- if (err) return fn(err);- next(++i);- });- } catch (err) {- fn(err);- }- return;- }-- // serial- try {- callback();- process.nextTick(function(){- next(++i);- });- } catch (err) {- fn(err);- }- }-- process.nextTick(function(){- next(0);- });-};--/**- * Run the current test and callback `fn(err)`.- *- * @param {Function} fn- * @api private- */--Runner.prototype.runTest = function(fn){- var test = this.test- , self = this;-- // run the test- try {- // async- if (test.async) return test.run(function(err){- if (test.finished) {- self.fail(test, new Error('done() called multiple times'));- return;- }- fn(err);- });- // sync- process.nextTick(function(){- test.run();- fn();- });- } catch (err) {- fn(err);- }-};--/**- * Run tests in the given `suite` and invoke- * the callback `fn()` when complete.- *- * @param {Suite} suite- * @param {Function} fn- * @api private- */--Runner.prototype.runTests = function(suite, fn){- var self = this- , tests = suite.tests- , test;-- function next(err) {- // error handling- if (err) self.fail(test, err);-- // next test- test = tests.shift();-- // all done- if (!test) return fn();-- // grep- if (!self._grep.test(test.fullTitle())) return next();-- // pending- if (test.pending) {- self.emit('pending', test);- self.emit('test end', test);- return next();- }-- // execute test and hook(s)- self.emit('test', self.test = test);- self.hook('beforeEach', function(err){- if (err) return self.failHook('beforeEach', err);- self.runTest(function(err){- if (err) return next(err);- self.emit('pass', test);- test.passed = true;- self.emit('test end', test);- if (err) return self.failHook('beforeEach', err);- self.hook('afterEach', function(err){- if (err) return self.failHook('afterEach', err);- next();- });- });- });- }-- next();-};--/**- * Run the given `suite` and invoke the- * callback `fn()` when complete.- *- * @param {Suite} suite- * @param {Function} fn- * @api private- */--Runner.prototype.runSuite = function(suite, fn){- var self = this- , i = 0;-- this.emit('suite', this.suite = suite);-- function next() {- var curr = suite.suites[i++];- if (!curr) return done();- self.runSuite(curr, next);- }-- function done() {- self.suite = suite;- self.hook('afterAll', function(err){- if (err) return self.failHook('afterAll', err);- self.emit('suite end', suite);- fn();- });- }-- this.hook('beforeAll', function(err){- // TODO: use interface names- if (err) return self.failHook('beforeAll', err);- self.runTests(suite, next);- });-};--/**- * Run the root suite.- *- * @api public- */--Runner.prototype.run = function(){- var self = this;-- // run suites- this.emit('start');- this.runSuite(this.suite, function(){- self.emit('end');- });-- // uncaught exception- process.on('uncaughtException', function(err){- self.fail(self.test, err);- self.emit('end');- });-- return this;-};diff --git a/lib/suite.js b/lib/suite.jsdeleted file mode 100644index 719beec2..00000000--- a/lib/suite.js+++ /dev/null@@ -1,194 +0,0 @@--/**- * Module dependencies.- */--var EventEmitter = require('events').EventEmitter;--/**- * Expose `Suite`.- */--exports = module.exports = Suite;--/**- * Suite map.- */--var map = {};--/**- * Create a new `Suite` with the given `title`- * and parent `Suite`. When a suite with the- * same title is already present, that suite- * is returned to provide nicer reporter- * and more flexible meta-testing.- *- * @param {Suite} parent- * @param {String} title- * @return {Suite}- * @api public- */--exports.create = function(parent, title){- var suite = new Suite(title);- suite.parent = parent;- title = suite.fullTitle();- if (map[title]) return map[title];- parent.addSuite(suite);- return map[title] = suite;-};--/**- * Initialize a new `Suite` with the given `title`.- *- * @param {String} title- * @api private- */--function Suite(title) {- this.title = title;- this.suites = [];- this.tests = [];- this.beforeAllCallbacks = [];- this.beforeEachCallbacks = [];- this.afterAllCallbacks = [];- this.afterEachCallbacks = [];- this.root = !title;-}--/**- * Inherit from `EventEmitter.prototype`.- */--Suite.prototype.__proto__ = EventEmitter.prototype;--/**- * Set timeout `ms`.- *- * @param {Number} ms- * @return {Suite} for chaining- * @api private- */--Suite.prototype.timeout = function(ms){- this._timeout = ms;- return this;-};--/**- * Run `fn(test[, done])` before running tests.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.beforeAll = function(fn){- this.beforeAllCallbacks.push(fn);- this.emit('beforeAll', fn);- return this;-};--/**- * Run `fn(test[, done])` after running tests.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.afterAll = function(fn){- this.afterAllCallbacks.push(fn);- this.emit('afterAll', fn);- return this;-};--/**- * Run `fn(test[, done])` before each test case.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.beforeEach = function(fn){- this.beforeEachCallbacks.push(fn);- this.emit('beforeEach', fn);- return this;-};--/**- * Run `fn(test[, done])` after each test case.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.afterEach = function(fn){- this.afterEachCallbacks.push(fn);- this.emit('afterEach', fn);- return this;-};--/**- * Add a test `suite`.- *- * @param {Suite} suite- * @return {Suite} for chaining- * @api private- */--Suite.prototype.addSuite = function(suite){- suite.parent = this;- if (this._timeout) suite.timeout(this._timeout);- this.suites.push(suite);- this.emit('suite', suite);- return this;-};--/**- * Add a `test` to this suite.- *- * @param {Test} test- * @return {Suite} for chaining- * @api private- */--Suite.prototype.addTest = function(test){- test.parent = this;- if (this._timeout) test.timeout(this._timeout);- this.tests.push(test);- this.emit('test', test);- return this;-};--/**- * Return the full title generated by recursively- * concatenating the parent's full title.- *- * @return {String}- * @api public- */--Suite.prototype.fullTitle = function(){- if (this.parent) {- var full = this.parent.fullTitle();- if (full) return full + ' ' + this.title;- }- return this.title;-};--/**- * Return the total number of tests.- *- * @return {Number}- * @api public- */--Suite.prototype.total = function(){- return this.suites.reduce(function(sum, suite){- return sum + suite.total();- }, 0) + this.tests.length;-};diff --git a/lib/test.js b/lib/test.jsdeleted file mode 100644index 41301996..00000000--- a/lib/test.js+++ /dev/null@@ -1,83 +0,0 @@--/**- * Expose `Test`.- */--module.exports = Test;--/**- * Initialize a new `Test` with the given `title` and callback `fn`.- *- * @param {String} title- * @param {Function} fn- * @api private- */--function Test(title, fn) {- this.title = title;- this.fn = fn;- this.pending = !fn;- this.async = fn && fn.length;- this.sync = ! this.async;- this.timeout(2000);-}--/**- * Set timeout `ms`.- *- * @param {Number} ms- * @return {Test} for chaining- * @api private- */--Test.prototype.timeout = function(ms){- this._timeout = ms;- return this;-};--/**- * Return the full title generated by recursively- * concatenating the parent's full title.- *- * @return {String}- * @api public- */--Test.prototype.fullTitle = function(){- return this.parent.fullTitle() + ' ' + this.title;-};--/**- * Run the test and invoke `fn(err)`.- *- * @param {Function} fn- * @api private- */--Test.prototype.run = function(fn){- var timer- , self = this- , ms = this._timeout- , start = new Date;-- // timeout- if (this.async) {- timer = setTimeout(function(){- fn(new Error('timeout of ' + ms + 'ms exceeded'));- }, ms);- }-- // async- if (this.async) {- this.fn(function(err){- clearTimeout(timer);- self.duration = new Date - start;- fn(err);- self.finished = true;- });- // sync- } else {- if (!this.pending) this.fn();- this.duration = new Date - start;- }-};diff --git a/mocha.js b/mocha.jsdeleted file mode 100644index 7ce59dc4..00000000--- a/mocha.js+++ /dev/null@@ -1,2043 +0,0 @@--// CommonJS require()--function require(p){- var path = require.resolve(p)- , mod = require.modules[path];- if (!mod) throw new Error('failed to require "' + p + '"');- if (!mod.exports) {- mod.exports = {};- mod.call(mod.exports, mod, mod.exports, require.relative(path));- }- return mod.exports;- }--require.modules = {};--require.resolve = function (path){- var orig = path- , reg = path + '.js'- , index = path + '/index.js';- return require.modules[reg] && reg- || require.modules[index] && index- || orig;- };--require.register = function (path, fn){- require.modules[path] = fn;- };--require.relative = function (parent) {- return function(p){- if ('.' != p[0]) return require(p);-- var path = parent.split('/')- , segs = p.split('/');- path.pop();-- for (var i = 0; i < segs.length; i++) {- var seg = segs[i];- if ('..' == seg) path.pop();- else if ('.' != seg) path.push(seg);- }-- return require(path.join('/'));- };- };---require.register("browser/events.js", function(module, exports, require){--/**- * Expose `EventEmitter`.- */--exports.EventEmitter = EventEmitter;--/**- * Slice reference.- */--var slice = [].slice;--/**- * EventEmitter.- */--function EventEmitter() {- this.callbacks = {};-};--/**- * Listen on the given `event` with `fn`.- *- * @param {String} event- * @param {Function} fn- */--EventEmitter.prototype.on = function(event, fn){- (this.callbacks[event] = this.callbacks[event] || [])- .push(fn);- return this;-};--/**- * Emit `event` with the given args.- *- * @param {String} event- * @param {Mixed} ...- */--EventEmitter.prototype.emit = function(event){- var args = slice.call(arguments, 1)- , callbacks = this.callbacks[event];-- if (callbacks) {- for (var i = 0, len = callbacks.length; i < len; ++i) {- callbacks[i].apply(this, args)- }- }-- return this;-};--}); // module: browser/events.js--require.register("browser/tty.js", function(module, exports, require){--exports.isatty = function(){- return true;-};--exports.getWindowSize = function(){- return [window.innerHeight, window.innerWidth];-};-}); // module: browser/tty.js--require.register("interfaces/bdd.js", function(module, exports, require){--/**- * Module dependencies.- */--var Suite = require('../suite')- , Test = require('../test');--/**- * BDD-style interface:- *- * describe('Array', function(){- * describe('#indexOf()', function(){- * it('should return -1 when not present', function(){- *- * });- *- * it('should return the index when present', function(){- *- * });- * });- * });- *- */--module.exports = function(suite){- var suites = [suite];-- suite.on('pre-require', function(context){-- /**- * Execute before running tests.- */-- context.before = function(fn){- suites[0].beforeAll(fn);- };-- /**- * Execute after running tests.- */-- context.after = function(fn){- suites[0].afterAll(fn);- };-- /**- * Execute before each test case.- */-- context.beforeEach = function(fn){- suites[0].beforeEach(fn);- };-- /**- * Execute after each test case.- */-- context.afterEach = function(fn){- suites[0].afterEach(fn);- };-- /**- * Describe a "suite" with the given `title`- * and callback `fn` containing nested suites- * and/or tests.- */-- context.describe = function(title, fn){- var suite = Suite.create(suites[0], title);- suites.unshift(suite);- fn();- suites.shift();- };-- /**- * Describe a specification or test-case- * with the given `title` and callback `fn`- * acting as a thunk.- */-- context.it = function(title, fn){- suites[0].addTest(new Test(title, fn));- };- });-};--}); // module: interfaces/bdd.js--require.register("interfaces/exports.js", function(module, exports, require){--/**- * Module dependencies.- */--var Suite = require('../suite')- , Test = require('../test');--/**- * TDD-style interface:- *- * exports.Array = {- * '#indexOf()': {- * 'should return -1 when the value is not present': function(){- *- * },- *- * 'should return the correct index when the value is present': function(){- *- * }- * }- * };- *- */--module.exports = function(suite){- var suites = [suite];-- suite.on('require', visit);-- function visit(obj) {- var suite;- for (var key in obj) {- if ('function' == typeof obj[key]) {- var fn = obj[key];- switch (key) {- case 'before':- suites[0].beforeAll(fn);- break;- case 'after':- suites[0].afterAll(fn);- break;- case 'beforeEach':- suites[0].beforeEach(fn);- break;- case 'afterEach':- suites[0].afterEach(fn);- break;- default:- suites[0].addTest(new Test(key, fn));- }- } else {- var suite = Suite.create(suites[0], key);- suites.unshift(suite);- visit(obj[key]);- suites.shift();- }- }- }-};-}); // module: interfaces/exports.js--require.register("interfaces/index.js", function(module, exports, require){--exports.bdd = require('./bdd');-exports.tdd = require('./tdd');-exports.exports = require('./exports');-}); // module: interfaces/index.js--require.register("interfaces/tdd.js", function(module, exports, require){--/**- * Module dependencies.- */--var Suite = require('../suite')- , Test = require('../test');--/**- * TDD-style interface:- *- * suite('Array', function(){- * suite('#indexOf()', function(){- * test('should return -1 when not present', function(){- *- * });- *- * test('should return the index when present', function(){- *- * });- * });- * });- *- */--module.exports = function(suite){- var suites = [suite];-- suite.on('pre-require', function(context){-- /**- * Execute before each test case.- */-- context.setup = function(fn){- suites[0].beforeEach(fn);- };-- /**- * Execute before each test case.- */-- context.tearDown = function(fn){- suites[0].afterEach(fn);- };-- /**- * Describe a "suite" with the given `title`- * and callback `fn` containing nested suites- * and/or tests.- */-- context.suite = function(title, fn){- var suite = Suite.create(suites[0], title);- suites.unshift(suite);- fn();- suites.shift();- };-- /**- * Describe a specification or test-case- * with the given `title` and callback `fn`- * acting as a thunk.- */-- context.test = function(title, fn){- suites[0].addTest(new Test(title, fn));- };- });-};--}); // module: interfaces/tdd.js--require.register("mocha.js", function(module, exports, require){--/*!- * mocha- * Copyright(c) 2011 TJ Holowaychuk <[email protected]>- * MIT Licensed- */--/**- * Library version.- */--exports.version = '0.0.1-alpha5';--exports.interfaces = require('./interfaces');-exports.reporters = require('./reporters');-exports.Runner = require('./runner');-exports.Suite = require('./suite');-exports.Test = require('./test');-}); // module: mocha.js--require.register("reporters/base.js", function(module, exports, require){--/**- * Module dependencies.- */--var tty = require('browser/tty');--/**- * Check if both stdio streams are associated with a tty.- */--var isatty = tty.isatty(1) && tty.isatty(2);--/**- * Expose `Base`.- */--exports = module.exports = Base;--/**- * Enable coloring by default.- */--exports.useColors = isatty;--/**- * Default color map.- */--exports.colors = {- 'pass': 90- , 'fail': 31- , 'pending': 36- , 'suite': '40'- , 'error title': 0- , 'error message': 31- , 'error stack': 90- , 'checkmark': 32- , 'fast': 90- , 'medium': 33- , 'slow': 31-};--/**- * Color `str` with the given `type`,- * allowing colors to be disabled,- * as well as user-defined color- * schemes.- *- * @param {String} type- * @param {String} str- * @return {String}- * @api private- */--var color = exports.color = function(type, str) {- if (!exports.useColors) return str;- return '\033[' + exports.colors[type] + 'm' + str + '\033[0m';-};--/**- * Expose term window size, with some- * defaults for when stderr is not a tty.- */--exports.window = {- width: isatty- ? process.stdout.getWindowSize- ? process.stdout.getWindowSize(1)[0]- : tty.getWindowSize()[1]- : 75-};--/**- * Expose some basic cursor interactions- * that are common among reporters.- */--exports.cursor = {- hide: function(){- process.stdout.write('\033[?25l');- },-- show: function(){- process.stdout.write('\033[?25h');- }-};--/**- * A test is considered slow if it- * exceeds the following value in milliseconds.- */--exports.slow = 75;--/**- * Outut the given `failures` as a list.- *- * @param {Array} failures- * @api public- */--exports.list = function(failures){- console.error();- failures.forEach(function(test, i){- // format- var fmt = color('error title', ' %s) %s: ')- + color('error message', '%s')- + color('error stack', '\n%s\n');-- // msg- var stack = test.err.stack- , index = stack.indexOf('at')- , msg = stack.slice(0, index);-- // indent stack trace without msg- stack = stack.slice(index)- .replace(/^/gm, ' ');-- console.error(fmt, i, test.fullTitle(), msg, stack);- });-};--/**- * Initialize a new `Base` reporter.- *- * All other reporters generally- * inherit from this reporter, providing- * stats such as test duration, number- * of tests passed / failed etc.- *- * @param {Runner} runner- * @api public- */--function Base(runner) {- var self = this- , stats = this.stats = { suites: 0, tests: 0, passes: 0, failures: 0 }- , failures = this.failures = [];-- if (!runner) return;-- runner.on('start', function(){- stats.start = new Date;- });-- runner.on('suite', function(suite){- stats.suites = stats.suites || 0;- stats.suites++;- });-- runner.on('test end', function(test){- stats.tests = stats.tests || 0;- stats.tests++;- });-- runner.on('pass', function(test){- stats.passes = stats.passes || 0;-- var medium = exports.slow / 2;- test.speed = test.duration > exports.slow- ? 'slow'- : test.duration > medium- ? 'medium'- : 'fast';-- stats.passes++;- });-- runner.on('fail', function(test, err){- stats.failures = stats.failures || 0;- stats.failures++;- test.err = err;- failures.push(test);- });-- runner.on('end', function(){- stats.end = new Date;- stats.duration = new Date - stats.start;- });-}--/**- * Output common epilogue used by many of- * the bundled reporters.- *- * @api public- */--Base.prototype.epilogue = function(){- var stats = this.stats;-- console.log();-- // failure- if (stats.failures) {- console.error(- ' \033[91m✖\033[31m %d of %d tests failed\033[90m:\033[0m'- , stats.failures, stats.tests);- Base.list(this.failures);- console.error();- process.nextTick(function(){- process.exit(stats.failures);- });- return;- }-- // pass- console.log(- ' \033[92m✔\033[32m %d tests completed\033[90m (%dms)\033[0m'- , stats.tests || 0- , stats.duration);-- console.log();- process.nextTick(function(){- process.exit(0);- });-};--}); // module: reporters/base.js--require.register("reporters/doc.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base');--/**- * Expose `Doc`.- */--exports = module.exports = Doc;--/**- * Initialize a new `Doc` reporter.- *- * @param {Runner} runner- * @api public- */--function Doc(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , total = runner.total- , indents = 2;-- function indent() {- return Array(indents).join(' ');- }-- runner.on('suite', function(suite){- if (suite.root) return;- ++indents;- console.log('%s<section class="suite">', indent());- ++indents;- console.log('%s<h1>%s</h1>', indent(), suite.title);- console.log('%s<dl>', indent());- });-- runner.on('suite end', function(suite){- if (suite.root) return;- console.log('%s</dl>', indent());- --indents;- console.log('%s</section>', indent());- --indents;- });-- runner.on('pass', function(test){- console.log('%s<dt>%s</dt>', indent(), test.title);- var code = clean(test.fn.toString());- console.log('%s<dd><pre><code>%s</code></pre></dd>', indent(), code);- });-- runner.on('end', function(){- process.exit(stats.failures);- });-}--/**- * Strip the function definition from `str`,- * and re-indent for pre whitespace.- */--function clean(str) {- str = str- .replace(/^function *\(.*\) *{/, '')- .replace(/\s+\}$/, '');-- var spaces = str.match(/^\n?( *)/)[1].length- , re = new RegExp('^ {' + spaces + '}', 'gm');-- str = str.replace(re, '');-- return str;-}-}); // module: reporters/doc.js--require.register("reporters/dot.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `Dot`.- */--exports = module.exports = Dot;--/**- * Initialize a new `Dot` matrix test reporter.- *- * @param {Runner} runner- * @api public- */--function Dot(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , width = Base.window.width * .75 | 0- , n = 0;-- runner.on('start', function(){- process.stdout.write('\n ');- });-- runner.on('pending', function(test){- process.stdout.write(color('pending', '.'));- });-- runner.on('pass', function(test){- if (++n % width == 0) process.stdout.write('\n ');- if ('slow' == test.speed) {- process.stdout.write('\033[93m.\033[0m');- } else {- process.stdout.write(color(test.speed, '.'));- }- });-- runner.on('fail', function(test, err){- if (++n % width == 0) process.stdout.write('\n ');- process.stdout.write(color('fail', '.'));- });-- runner.on('end', function(){- console.log();- self.epilogue();- });-}--/**- * Inherit from `Base.prototype`.- */--Dot.prototype = new Base;-Dot.prototype.constructor = Dot;--}); // module: reporters/dot.js--require.register("reporters/html.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base');--/**- * Expose `Doc`.- */--exports = module.exports = HTML;--/**- * Initialize a new `Doc` reporter.- *- * @param {Runner} runner- * @api public- */--function HTML(runner) {- Base.call(this, runner);-- // TODO: clean up-- var self = this- , stats = this.stats- , total = runner.total- , root = document.getElementById('mocha')- , stack = [root]- , stat = document.createElement('div');-- stat.innerHTML = '<ul id="stats">'- + '<li class="passes">passes: <em>0</em></li>'- + '<li class="failures">failures: <em>0</em></li>'- + '</ul>';-- if (!root) error('#mocha div missing, add it to your document');-- document.body.appendChild(root);- document.body.appendChild(stat);-- runner.on('suite', function(suite){- if (suite.root) return;-- // suite- var el = document.createElement('div');- el.setAttribute('class', 'suite');-- // title- var title = document.createElement('h1');- title.textContent = suite.title;- el.appendChild(title);-- // container- stack[0].appendChild(el);- stack.unshift(document.createElement('div'));- el.appendChild(stack[0]);- });-- runner.on('suite end', function(suite){- if (suite.root) return;- stack.shift();- });-- runner.on('test end', function(test){- console.log(stats);- // test- var el = document.createElement('div');- el.setAttribute('class', 'test ' + (test.passed ? 'pass' : 'fail'));-- // title- var title = document.createElement('h2');- title.textContent = test.title;- el.appendChild(title);-- // code- var pre = document.createElement('pre');- var code = document.createElement('code');- pre.appendChild(code);- code.textContent = clean(test.fn.toString());- el.appendChild(pre);-- stack[0].appendChild(el);- });-- runner.on('end', function(){- process.exit(stats.failures);- });-}--function error(msg) {- // TODO: nicer- throw new Error(msg);-}--/**- * Strip the function definition from `str`,- * and re-indent for pre whitespace.- */--function clean(str) {- str = str- .replace(/^function *\(.*\) *{/, '')- .replace(/\s+\}$/, '');-- var spaces = str.match(/^\n?( *)/)[1].length- , re = new RegExp('^ {' + spaces + '}', 'gm');-- str = str- .replace(re, '')- .replace(/^\s+/, '');-- return str;-}-}); // module: reporters/html.js--require.register("reporters/index.js", function(module, exports, require){--exports.Base = require('./base');-exports.Dot = require('./dot');-exports.Doc = require('./doc');-exports.TAP = require('./tap');-exports.JSON = require('./json');-exports.HTML = require('./html');-exports.List = require('./list');-exports.Progress = require('./progress');-exports.Landing = require('./landing');-exports.JSONStream = require('./json-stream');--}); // module: reporters/index.js--require.register("reporters/json-stream.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `List`.- */--exports = module.exports = List;--/**- * Initialize a new `List` test reporter.- *- * @param {Runner} runner- * @api public- */--function List(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , total = runner.total;-- runner.on('start', function(){- console.log(JSON.stringify(['start', { total: total }]));- });-- runner.on('pass', function(test){- console.log(JSON.stringify(['pass', clean(test)]));- });-- runner.on('fail', function(test, err){- console.log(JSON.stringify(['fail', clean(test)]));- });-- runner.on('end', function(){- process.stdout.write(JSON.stringify(['end', self.stats]), function(){- process.exit(0);- });- });-}--/**- * Return a plain-object representation of `test`- * free of cyclic properties etc.- *- * @param {Object} test- * @return {Object}- * @api private- */--function clean(test) {- return {- title: test.title- , fullTitle: test.fullTitle()- , duration: test.duration- }-}-}); // module: reporters/json-stream.js--require.register("reporters/json.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `JSON`.- */--exports = module.exports = JSONReporter;--/**- * Initialize a new `JSON` reporter.- *- * @param {Runner} runner- * @api public- */--function JSONReporter(runner) {- var self = this;- Base.call(this, runner);-- var tests = []- , failures = []- , passes = [];-- runner.on('test end', function(test){- tests.push(test);- });-- runner.on('pass', function(test){- passes.push(test);- });-- runner.on('fail', function(test){- failures.push(test);- });-- runner.on('end', function(){- var obj = {- stats: self.stats- , tests: tests.map(clean)- , failures: failures.map(clean)- , passes: passes.map(clean)- };-- process.stdout.write(JSON.stringify(obj), function(){- process.exit(0);- });- });-}--/**- * Return a plain-object representation of `test`- * free of cyclic properties etc.- *- * @param {Object} test- * @return {Object}- * @api private- */--function clean(test) {- return {- title: test.title- , fullTitle: test.fullTitle()- , duration: test.duration- }-}-}); // module: reporters/json.js--require.register("reporters/landing.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `Landing`.- */--exports = module.exports = Landing;--/**- * Airplane color.- */--Base.colors.plane = 0;--/**- * Airplane crash color.- */--Base.colors['plane crash'] = 31;--/**- * Runway color.- */--Base.colors.runway = 90;--/**- * Initialize a new `Landing` reporter.- *- * @param {Runner} runner- * @api public- */--function Landing(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , width = Base.window.width * .75 | 0- , total = runner.total- , stream = process.stdout- , plane = color('plane', '✈')- , crashed = -1- , n = 0;-- function runway() {- var buf = Array(width).join('-');- return ' ' + color('runway', buf);- }-- runner.on('start', function(){- stream.write('\n ');- cursor.hide();- });-- runner.on('test end', function(test){- // check if the plane crashed- var col = -1 == crashed- ? width * ++n / total | 0- : crashed;-- // show the crash- if (test.failed) {- plane = color('plane crash', '✈');- crashed = col;- }-- // render landing strip- stream.write('\033[4F\n\n');- stream.write(runway());- stream.write('\n ');- stream.write(color('runway', Array(col).join('⋅')));- stream.write(plane)- stream.write(color('runway', Array(width - col).join('⋅') + '\n'));- stream.write(runway());- stream.write('\033[0m');- });-- runner.on('end', function(){- cursor.show();- console.log();- self.epilogue();- });-}--/**- * Inherit from `Base.prototype`.- */--Landing.prototype = new Base;-Landing.prototype.constructor = Landing;--}); // module: reporters/landing.js--require.register("reporters/list.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `List`.- */--exports = module.exports = List;--/**- * Initialize a new `List` test reporter.- *- * @param {Runner} runner- * @api public- */--function List(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , n = 0;-- runner.on('start', function(){- console.log();- });-- runner.on('test', function(test){- process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));- });-- runner.on('pending', function(test){- var fmt = color('checkmark', ' -')- + color('pending', ' %s');- console.log(fmt, test.fullTitle());- });-- runner.on('pass', function(test){- var fmt = color('checkmark', ' ✓')- + color('pass', ' %s: ')- + color(test.speed, '%dms');- console.log('\r' + fmt, test.fullTitle(), test.duration);- });-- runner.on('fail', function(test, err){- console.log('\r' + color('fail', ' %d) %s'), n++, test.fullTitle());- });-- runner.on('end', self.epilogue.bind(self));-}--/**- * Inherit from `Base.prototype`.- */--List.prototype = new Base;-List.prototype.constructor = List;--}); // module: reporters/list.js--require.register("reporters/progress.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `Progress`.- */--exports = module.exports = Progress;--/**- * General progress bar color.- */--Base.colors.progress = 90;--/**- * Initialize a new `Progress` bar test reporter.- *- * @param {Runner} runner- * @param {Object} options- * @api public- */--function Progress(runner, options) {- Base.call(this, runner);-- var self = this- , options = options || {}- , stats = this.stats- , width = Base.window.width * .50 | 0- , total = runner.total- , complete = 0- , max = Math.max;-- // default chars- options.open = options.open || '[';- options.complete = options.complete || '▬';- options.incomplete = options.incomplete || '⋅';- options.close = options.close || ']';- options.verbose = false;-- // tests started- runner.on('start', function(){- console.log();- cursor.hide();- });-- // tests complete- runner.on('test end', function(){- var incomplete = total - complete- , percent = complete++ / total- , n = width * percent | 0- , i = width - n;-- process.stdout.write('\r\033[J');- process.stdout.write(color('progress', ' ' + options.open));- process.stdout.write(Array(n).join(options.complete));- process.stdout.write(Array(i).join(options.incomplete));- process.stdout.write(color('progress', options.close));- if (options.verbose) {- process.stdout.write(color('progress', ' ' + complete + ' of ' + total));- }- });-- // tests are complete, output some stats- // and the failures if any- runner.on('end', function(){- cursor.show();- console.log();- self.epilogue();- });-}--/**- * Inherit from `Base.prototype`.- */--Progress.prototype = new Base;-Progress.prototype.constructor = Progress;--}); // module: reporters/progress.js--require.register("reporters/spec.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , color = Base.color;--/**- * Expose `Spec`.- */--exports = module.exports = Spec;--/**- * Initialize a new `Spec` test reporter.- *- * @param {Runner} runner- * @api public- */--function Spec(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , indents = 0- , n = 0;-- function indent() {- return Array(indents).join(' ')- }-- runner.on('start', function(){- console.log();- });-- runner.on('suite', function(suite){- ++indents;- console.log(color('suite', '%s%s'), indent(), suite.title);- });-- runner.on('suite end', function(suite){- --indents;- if (1 == indents) console.log();- });-- runner.on('test', function(test){- process.stdout.write(indent() + color('pass', test.title + ': '));- });-- runner.on('pending', function(test){- var fmt = indent() + color('pending', ' - %s');- console.log(fmt, test.title);- });-- runner.on('pass', function(test){- if ('fast' == test.speed) {- var fmt = indent()- + color('checkmark', ' ✓')- + color('pass', ' %s ');- console.log('\r' + fmt, test.title);- } else {- var fmt = indent()- + color('checkmark', ' ✓')- + color('pass', ' %s ')- + color(test.speed, '(%dms)');- console.log('\r' + fmt, test.title, test.duration);- }- });-- runner.on('fail', function(test, err){- console.log('\r' + indent() + color('fail', ' %d) %s'), n++, test.title);- });-- runner.on('end', self.epilogue.bind(self));-}--/**- * Inherit from `Base.prototype`.- */--Spec.prototype = new Base;-Spec.prototype.constructor = Spec;--}); // module: reporters/spec.js--require.register("reporters/tap.js", function(module, exports, require){--/**- * Module dependencies.- */--var Base = require('./base')- , cursor = Base.cursor- , color = Base.color;--/**- * Expose `TAP`.- */--exports = module.exports = TAP;--/**- * Initialize a new `TAP` reporter.- *- * @param {Runner} runner- * @api public- */--function TAP(runner) {- Base.call(this, runner);-- var self = this- , stats = this.stats- , total = runner.total- , n = 1;-- runner.on('start', function(){- console.log(' %d..%d', 1, total);- });-- runner.on('test end', function(){- ++n;- });-- runner.on('pass', function(test){- console.log(' ok %d %s', n, test.fullTitle());- });-- runner.on('fail', function(test){- console.log(' not ok %d %s', n, test.fullTitle());- });-- runner.on('end', function(){- process.exit(stats.failures);- });-}-}); // module: reporters/tap.js--require.register("runner.js", function(module, exports, require){--/**- * Module dependencies.- */--var EventEmitter = require('browser/events').EventEmitter- , Test = require('./test')- , noop = function(){};--/**- * Expose `Runner`.- */--module.exports = Runner;--/**- * Initialize a `Runner` for the given `suite`.- *- * Events:- *- * - `start` execution started- * - `end` execution complete- * - `suite` (suite) test suite execution started- * - `suite end` (suite) all tests (and sub-suites) have finished- * - `test` (test) test execution started- * - `test end` (test) test completed- * - `pass` (test) test passed- * - `fail` (test, err) test failed- *- * @api public- */--function Runner(suite) {- this.suite = suite;- this.total = suite.total();- this.globals = Object.keys(global).concat(['errno']);- this.on('test end', this.checkGlobals.bind(this));- this.grep(/.*/);-}--/**- * Inherit from `EventEmitter.prototype`.- */--Runner.prototype = new EventEmitter;-Runner.prototype.constructor = Runner;---/**- * Run tests with full titles matching `re`.- *- * @param {RegExp} re- * @return {Runner} for chaining- * @api public- */--Runner.prototype.grep = function(re){- this._grep = re;- return this;-};--/**- * Check for global variable leaks.- *- * @api private- */--Runner.prototype.checkGlobals = function(test){- var leaks = Object.keys(global).filter(function(key){- return !~this.globals.indexOf(key);- }, this);-- this.globals = this.globals.concat(leaks);-- if (leaks.length > 1) {- this.fail(test, new Error('global leaks detected: ' + leaks.join(', ') + ''));- } else if (leaks.length) {- this.fail(test, new Error('global leak detected: ' + leaks[0]));- }-};--/**- * Fail the given `test`.- *- * @param {Test} test- * @param {Error} err- * @api private- */--Runner.prototype.fail = function(test, err){- test.failed = true;- this.emit('fail', test, err);-};--/**- * Fail the given `hook` name.- *- * @param {String} hook- * @param {Error} err- * @api private- */--Runner.prototype.failHook = function(hook, err){- var test = new Test(hook + ' hook', noop);- test.parent = this.suite;- this.fail(test, err);- this.emit('end');- process.exit(0);-};--/**- * Run hook `name` callbacks and then invoke `fn(err)`.- *- * @param {String} name- * @param {Function} function- * @api private- */--Runner.prototype.hook = function(name, fn){- var suite = this.suite- , test = this.test- , callbacks = suite[name + 'Callbacks']- , pending = callbacks.length;-- function next(i) {- var callback = callbacks[i]- if (!callback) return fn();-- // async- if (1 == callback.length) {- // async- try {- callback(function(err){- if (err) return fn(err);- next(++i);- });- } catch (err) {- fn(err);- }- return;- }-- // serial- try {- callback();- process.nextTick(function(){- next(++i);- });- } catch (err) {- fn(err);- }- }-- process.nextTick(function(){- next(0);- });-};--/**- * Run the current test and callback `fn(err)`.- *- * @param {Function} fn- * @api private- */--Runner.prototype.runTest = function(fn){- var test = this.test- , self = this;-- // run the test- try {- // async- if (test.async) return test.run(function(err){- if (test.finished) {- self.fail(test, new Error('done() called multiple times'));- return;- }- fn(err);- });- // sync- process.nextTick(function(){- test.run();- fn();- });- } catch (err) {- fn(err);- }-};--/**- * Run tests in the given `suite` and invoke- * the callback `fn()` when complete.- *- * @param {Suite} suite- * @param {Function} fn- * @api private- */--Runner.prototype.runTests = function(suite, fn){- var self = this- , tests = suite.tests- , test;-- function next(err) {- // error handling- if (err) self.fail(test, err);-- // next test- test = tests.shift();-- // all done- if (!test) return fn();-- // grep- if (!self._grep.test(test.fullTitle())) return next();-- // pending- if (test.pending) {- self.emit('pending', test);- self.emit('test end', test);- return next();- }-- // execute test and hook(s)- self.emit('test', self.test = test);- self.hook('beforeEach', function(err){- if (err) return self.failHook('beforeEach', err);- self.runTest(function(err){- if (err) return next(err);- self.emit('pass', test);- test.passed = true;- self.emit('test end', test);- if (err) return self.failHook('beforeEach', err);- self.hook('afterEach', function(err){- if (err) return self.failHook('afterEach', err);- next();- });- });- });- }-- next();-};--/**- * Run the given `suite` and invoke the- * callback `fn()` when complete.- *- * @param {Suite} suite- * @param {Function} fn- * @api private- */--Runner.prototype.runSuite = function(suite, fn){- var self = this- , i = 0;-- this.emit('suite', this.suite = suite);-- function next() {- var curr = suite.suites[i++];- if (!curr) return done();- self.runSuite(curr, next);- }-- function done() {- self.suite = suite;- self.hook('afterAll', function(err){- if (err) return self.failHook('afterAll', err);- self.emit('suite end', suite);- fn();- });- }-- this.hook('beforeAll', function(err){- // TODO: use interface names- if (err) return self.failHook('beforeAll', err);- self.runTests(suite, next);- });-};--/**- * Run the root suite.- *- * @api public- */--Runner.prototype.run = function(){- var self = this;-- // run suites- this.emit('start');- this.runSuite(this.suite, function(){- self.emit('end');- });-- // uncaught exception- process.on('uncaughtException', function(err){- self.fail(self.test, err);- self.emit('end');- });-- return this;-};--}); // module: runner.js--require.register("suite.js", function(module, exports, require){--/**- * Module dependencies.- */--var EventEmitter = require('browser/events').EventEmitter;--/**- * Expose `Suite`.- */--exports = module.exports = Suite;--/**- * Suite map.- */--var map = {};--/**- * Create a new `Suite` with the given `title`- * and parent `Suite`. When a suite with the- * same title is already present, that suite- * is returned to provide nicer reporter- * and more flexible meta-testing.- *- * @param {Suite} parent- * @param {String} title- * @return {Suite}- * @api public- */--exports.create = function(parent, title){- var suite = new Suite(title);- suite.parent = parent;- title = suite.fullTitle();- if (map[title]) return map[title];- parent.addSuite(suite);- return map[title] = suite;-};--/**- * Initialize a new `Suite` with the given `title`.- *- * @param {String} title- * @api private- */--function Suite(title) {- this.title = title;- this.suites = [];- this.tests = [];- this.beforeAllCallbacks = [];- this.beforeEachCallbacks = [];- this.afterAllCallbacks = [];- this.afterEachCallbacks = [];- this.root = !title;-}--/**- * Inherit from `EventEmitter.prototype`.- */--Suite.prototype = new EventEmitter;-Suite.prototype.constructor = Suite;---/**- * Set timeout `ms`.- *- * @param {Number} ms- * @return {Suite} for chaining- * @api private- */--Suite.prototype.timeout = function(ms){- this._timeout = ms;- return this;-};--/**- * Run `fn(test[, done])` before running tests.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.beforeAll = function(fn){- this.beforeAllCallbacks.push(fn);- this.emit('beforeAll', fn);- return this;-};--/**- * Run `fn(test[, done])` after running tests.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.afterAll = function(fn){- this.afterAllCallbacks.push(fn);- this.emit('afterAll', fn);- return this;-};--/**- * Run `fn(test[, done])` before each test case.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.beforeEach = function(fn){- this.beforeEachCallbacks.push(fn);- this.emit('beforeEach', fn);- return this;-};--/**- * Run `fn(test[, done])` after each test case.- *- * @param {Function} fn- * @return {Suite} for chaining- * @api private- */--Suite.prototype.afterEach = function(fn){- this.afterEachCallbacks.push(fn);- this.emit('afterEach', fn);- return this;-};--/**- * Add a test `suite`.- *- * @param {Suite} suite- * @return {Suite} for chaining- * @api private- */--Suite.prototype.addSuite = function(suite){- suite.parent = this;- if (this._timeout) suite.timeout(this._timeout);- this.suites.push(suite);- this.emit('suite', suite);- return this;-};--/**- * Add a `test` to this suite.- *- * @param {Test} test- * @return {Suite} for chaining- * @api private- */--Suite.prototype.addTest = function(test){- test.parent = this;- if (this._timeout) test.timeout(this._timeout);- this.tests.push(test);- this.emit('test', test);- return this;-};--/**- * Return the full title generated by recursively- * concatenating the parent's full title.- *- * @return {String}- * @api public- */--Suite.prototype.fullTitle = function(){- if (this.parent) {- var full = this.parent.fullTitle();- if (full) return full + ' ' + this.title;- }- return this.title;-};--/**- * Return the total number of tests.- *- * @return {Number}- * @api public- */--Suite.prototype.total = function(){- return this.suites.reduce(function(sum, suite){- return sum + suite.total();- }, 0) + this.tests.length;-};--}); // module: suite.js--require.register("test.js", function(module, exports, require){--/**- * Expose `Test`.- */--module.exports = Test;--/**- * Initialize a new `Test` with the given `title` and callback `fn`.- *- * @param {String} title- * @param {Function} fn- * @api private- */--function Test(title, fn) {- this.title = title;- this.fn = fn;- this.pending = !fn;- this.async = fn && fn.length;- this.sync = ! this.async;- this.timeout(2000);-}--/**- * Set timeout `ms`.- *- * @param {Number} ms- * @return {Test} for chaining- * @api private- */--Test.prototype.timeout = function(ms){- this._timeout = ms;- return this;-};--/**- * Return the full title generated by recursively- * concatenating the parent's full title.- *- * @return {String}- * @api public- */--Test.prototype.fullTitle = function(){- return this.parent.fullTitle() + ' ' + this.title;-};--/**- * Run the test and invoke `fn(err)`.- *- * @param {Function} fn- * @api private- */--Test.prototype.run = function(fn){- var timer- , self = this- , ms = this._timeout- , start = new Date;-- // timeout- if (this.async) {- timer = setTimeout(function(){- fn(new Error('timeout of ' + ms + 'ms exceeded'));- }, ms);- }-- // async- if (this.async) {- this.fn(function(err){- clearTimeout(timer);- self.duration = new Date - start;- fn(err);- self.finished = true;- });- // sync- } else {- if (!this.pending) this.fn();- this.duration = new Date - start;- }-};--}); // module: test.js--/**- * Node shims.- *- * These are meant only to allow- * mocha.js to run untouched, not- * to allow running node code on- * the server.- */--process = {};--process.nextTick = function(fn){ setTimeout(fn, 0); };-process.on = function(){};-process.exit = function(status){};-process.stdout = {};--global = this;--// boot--;(function(){- var mocha = require('mocha');- var suite = new mocha.Suite;- var Reporter = mocha.reporters.HTML;- mocha.interfaces.bdd(suite);- suite.emit('pre-require', global);-- global.onload = run; // TODO: remove-- function run() {- suite.emit('run');- var runner = new mocha.Runner(suite);- var reporter = new Reporter(runner);- runner.run();- }-})();\ No newline at end of filediff --git a/package.json b/package.jsondeleted file mode 100644index 21cdbfba..00000000--- a/package.json+++ /dev/null@@ -1,20 +0,0 @@-{- "name": "mocha"- , "version": "0.0.1-alpha5"- , "description": "Test framework inspired by JSpec, Expresso, & Qunit"- , "keywords": ["test", "bdd", "tdd", "tap"]- , "bin": { "mocha": "./bin/mocha" }- , "author": "TJ Holowaychuk <[email protected]>"- , "main": "index"- , "bin": {- "mocha": "./bin/mocha"- , "mocha-debug": "./bin/mocha-debug"- }- , "engines": { "node": ">= 0.4.x < 0.7.0" }- , "dependencies":{- "commander": "0.3.2"- }- , "devDependencies": {- "should": "0.3.x"- }-}diff --git a/style.css b/style.cssnew file mode 100644index 00000000..1f847136--- /dev/null+++ b/style.css@@ -0,0 +1,123 @@++body {+ font: 14px/1.6 "Helvetica Neue", Helvetica, Arial, sans-serif;+ margin: 0;+ padding: 140px 110px;+ color: #2C2C2C;+ border-top: 2px solid #ddd;+}++h1 {+ position: relative;+ font-style: normal;+ font-weight: 100;+ text-transform: lowercase;+ background: #8A6343;+ color: white;+ display: inline-block;+ padding: 48px 30px;+ opacity: 0;+ -webkit-border-radius: 100px;+ -webkit-transition: opacity 1s, background-color 200ms;+}++h1:hover {+ background: #A07A5C;+}++h1 a {+ color: inherit;+ font-weight: inherit;+}++h1 a:hover {+ text-decoration: none;+}++.onload h1 {+ opacity: 1;+}++h2 {+ margin-top: 40px;+ font-weight: 100;+ letter-spacing: 1px;+ border-bottom: 1px solid #eee;+}++#tag {+ opacity: 0;+ color: #C29D7F;+ font-weight: 100;+ font-size: 30px;+ margin-top: -110px;+ margin-left: 140px;+ margin-bottom: 100px;+ letter-spacing: 2px;+ -webkit-transition: opacity 1s, margin-top 200ms, margin-bottom 200ms, margin-left 1s;+}++#tag em {+ font-style: normal+}++.onload #tag {+ opacity: 1;+ margin-left: 170px;+}++a {+ color: #8A6343;+ font-weight: bold;+ text-decoration: none;+}++a:hover {+ text-decoration: underline;+}++ul {+ width: 100%;+}++ul li {+ float: left;+ width: 40%;+ margin-right: 60px;+}++ul::after {+ content: '.';+ height: 0;+ display: block;+ visibility: hidden;+ clear: both;+}++code {+ font: 12px monaco, monospace;+}++pre {+ padding: 30px;+ border: 1px solid #eee;+ border-bottom-color: #ddd;+ -webkit-border-radius: 2px;+ -webkit-box-shadow: inset 0 0 10px #eee;+}++@media all and (max-width: 600px) {+ #tag {+ margin-top: 0;+ margin-left: 0;+ margin-bottom: 0;+ }++ .onload #tag {+ margin-left: 0;+ }++ ul li {+ width: 100%;+ }+}diff --git a/support/compile.js b/support/compile.jsdeleted file mode 100644index 65be223d..00000000--- a/support/compile.js+++ /dev/null@@ -1,150 +0,0 @@--/**- * Module dependencies.- */--var fs = require('fs');--/**- * Arguments.- */--var args = process.argv.slice(2)- , pending = args.length- , files = {};--console.log('');--// parse arguments--args.forEach(function(file){- var mod = file.replace('lib/', '');- fs.readFile(file, 'utf8', function(err, js){- if (err) throw err;- console.log(' \033[90mcompile : \033[0m\033[36m%s\033[0m', file);- files[file] = ~js.indexOf('require: off')- ? js- : parse(js);- --pending || compile();- });-});--/**- * Parse the given `js`.- */--function parse(js) {- return parseRequires(parseInheritance(js));-}--/**- * Parse requires.- */--function parseRequires(js) {- return js- .replace(/require\('events'\)/g, "require('browser/events')")- .replace(/require\('tty'\)/g, "require('browser/tty')")-}--/**- * Parse __proto__.- */--function parseInheritance(js) {- return js- .replace(/^ *(\w+)\.prototype\.__proto__ * = *(\w+)\.prototype *;?/gm, function(_, child, parent){- return child + '.prototype = new ' + parent + ';\n'- + child + '.prototype.constructor = '+ child + ';\n';- });-}--/**- * Compile the files.- */--function compile() {- var buf = '';- buf += '\n// CommonJS require()\n\n';- buf += browser.require + '\n\n';- buf += 'require.modules = {};\n\n';- buf += 'require.resolve = ' + browser.resolve + ';\n\n';- buf += 'require.register = ' + browser.register + ';\n\n';- buf += 'require.relative = ' + browser.relative + ';\n\n';- args.forEach(function(file){- var js = files[file];- file = file.replace('lib/', '');- buf += '\nrequire.register("' + file + '", function(module, exports, require){\n';- buf += js;- buf += '\n}); // module: ' + file + '\n';- });- fs.writeFile('mocha.js', buf, function(err){- if (err) throw err;- console.log(' \033[90m create : \033[0m\033[36m%s\033[0m', 'mocha.js');- console.log();- });-}--// refactored version of weepy's-// https://github.com/weepy/brequire/blob/master/browser/brequire.js--var browser = {-- /**- * Require a module.- */-- require: function require(p){- var path = require.resolve(p)- , mod = require.modules[path];- if (!mod) throw new Error('failed to require "' + p + '"');- if (!mod.exports) {- mod.exports = {};- mod.call(mod.exports, mod, mod.exports, require.relative(path));- }- return mod.exports;- },-- /**- * Resolve module path.- */-- resolve: function(path){- var orig = path- , reg = path + '.js'- , index = path + '/index.js';- return require.modules[reg] && reg- || require.modules[index] && index- || orig;- },-- /**- * Return relative require().- */-- relative: function(parent) {- return function(p){- if ('.' != p[0]) return require(p);-- var path = parent.split('/')- , segs = p.split('/');- path.pop();-- for (var i = 0; i < segs.length; i++) {- var seg = segs[i];- if ('..' == seg) path.pop();- else if ('.' != seg) path.push(seg);- }-- return require(path.join('/'));- };- },-- /**- * Register a module.- */-- register: function(path, fn){- require.modules[path] = fn;- }-};\ No newline at end of filediff --git a/support/tail.js b/support/tail.jsdeleted file mode 100644index 1f07fcfe..00000000--- a/support/tail.js+++ /dev/null@@ -1,37 +0,0 @@--/**- * Node shims.- *- * These are meant only to allow- * mocha.js to run untouched, not- * to allow running node code on- * the server.- */--process = {};--process.nextTick = function(fn){ setTimeout(fn, 0); };-process.on = function(){};-process.exit = function(status){};-process.stdout = {};--global = this;--// boot--;(function(){- var mocha = require('mocha');- var suite = new mocha.Suite;- var Reporter = mocha.reporters.HTML;- mocha.interfaces.bdd(suite);- suite.emit('pre-require', global);-- global.onload = run; // TODO: remove-- function run() {- suite.emit('run');- var runner = new mocha.Runner(suite);- var reporter = new Reporter(runner);- runner.run();- }-})();\ No newline at end of filediff --git a/test/browser/array.js b/test/browser/array.jsdeleted file mode 100644index 388149e7..00000000--- a/test/browser/array.js+++ /dev/null@@ -1,33 +0,0 @@-describe('Array', function(){- describe('#indexOf()', function(){- it('should return -1 when the value is not present', function(){- var arr = [1,2,3];- assert(-1 == arr.indexOf(5));- })-- it('should return the correct index when the value is present', function(){- var arr = [1,2,3];- assert(0 == arr.indexOf(1)); // just to test indentation- assert(1 == arr.indexOf(2));- })- })-})--describe('Array', function(){- describe('#pop()', function(){- it('should remove and return the last value', function(){- var arr = [1,2,3];- assert(arr.pop() == 3);- })- })-})--describe('Array', function(){- describe('#pop()', function(){- it('should adjust .length', function(){- var arr = [1,2,3];- arr.pop();- assert(arr.length == 2);- })- })-})\ No newline at end of filediff --git a/test/browser/index.html b/test/browser/index.htmldeleted file mode 100644index 594a421f..00000000--- a/test/browser/index.html+++ /dev/null@@ -1,18 +0,0 @@-<html>- <head>- <title>Mocha</title>- <script src="../../mocha.js"></script>- <link rel="stylesheet" href="style.css" />- <script>- function assert(expr, msg) {- if (!expr) throw new Error(msg || 'failed');- }- </script>- <script src="array.js"></script>- <script src="../duration.js"></script>- <script src="../timeout.js"></script>- </head>- <body>- <div id="mocha"></div>- </body>-</html>\ No newline at end of filediff --git a/test/browser/style.css b/test/browser/style.cssdeleted file mode 100644index f2f4dc96..00000000--- a/test/browser/style.css+++ /dev/null@@ -1,45 +0,0 @@--body {- font: 18px/1.5 "Helvetica Neue", Helvetica, Aria;, sans-serif;- padding: 60px 50px;-}--h1, h2 {- margin: 0;-}--h1 {- font-size: 1em;-}--.suite .suite h1 {- font-size: .8em;-}--h2 {- font-size: 12px;- font-weight: normal;-}--.suite {- margin-left: 15px;-}--.test {- margin-left: 15px;-}--.test pre {- display: none;- margin: 5px;- padding: 15px;- border: 1px solid #eee;- border-bottom-color: #ddd;- -webkit-border-radius: 3px;- -webkit-box-shadow: 0 1px 3px #eee;-}--.test:hover pre {- font: 12px/1.5 monaco, monospace;- display: inline-block;-}\ No newline at end of filediff --git a/test/duration.js b/test/duration.jsdeleted file mode 100644index 400ba956..00000000--- a/test/duration.js+++ /dev/null@@ -1,20 +0,0 @@--describe('durations', function(){- describe('when slow', function(){- it('should highlight in red', function(done){- setTimeout(done, 100);- })- })-- describe('when reasonable', function(){- it('should highlight in yellow', function(done){- setTimeout(done, 50);- })- })-- describe('when fast', function(){- it('should highlight in green', function(done){- setTimeout(done, 10);- })- })-})\ No newline at end of filediff --git a/test/fs.js b/test/fs.jsdeleted file mode 100644index 102b8e1e..00000000--- a/test/fs.js+++ /dev/null@@ -1,18 +0,0 @@--var fs = require('fs');--describe('fs.readFile()', function(){- describe('when the file exists', function(){- it('should succeed', function(done){- fs.writeFile('/tmp/mocha', 'wahoo', done)- })- })-- describe('when the file does not exist', function(){- it('should fail', function(done){- // uncomment- // fs.readFile('/tmp/does-not-exist', done);- done();- })- })-})diff --git a/test/globals.js b/test/globals.jsdeleted file mode 100644index f9c2ef67..00000000--- a/test/globals.js+++ /dev/null@@ -1,19 +0,0 @@--describe('global leaks', function(){- beforeEach(function(){- // uncomment to test- // foo = 'bar'- });-- it('should cause tests to fail', function(){- // uncomment to test- // foo = 'bar';- // bar = 'baz';- // baz = 'raz';- });-- afterEach(function(){- // uncomment to test- // foo = 'bar'- });-});\ No newline at end of filediff --git a/test/hook.async.js b/test/hook.async.jsdeleted file mode 100644index 81abb41f..00000000--- a/test/hook.async.js+++ /dev/null@@ -1,94 +0,0 @@--describe('async', function(){- var calls = [];-- before(function(){- calls.push('root before all');- })-- after(function(){- calls.push('root after all');- calls.should.eql([- 'root before all'- , 'before all'- , 'before'- , 'one'- , 'after'- , 'before'- , 'two'- , 'after'- , 'before'- , 'three'- , 'after'- , 'after all'- , 'root after all']);- })-- beforeEach(function(){- // should not be invoked- calls.push('parent before');- })-- afterEach(function(){- // should not be invoked- calls.push('parent after' );- })-- describe('hooks', function(){- before(function(){- calls.push('before all');- });-- after(function(){- calls.push('after all');- });-- beforeEach(function(done){- process.nextTick(function(){- calls.push('before');- done();- })- })-- it('one', function(done){- calls.should.eql([- 'root before all'- , 'before all'- , 'before']);- calls.push('one');- process.nextTick(done);- })-- it('two', function(){- calls.should.eql([- 'root before all'- , 'before all'- , 'before'- , 'one'- , 'after'- , 'before']);- calls.push('two');- })-- it('three', function(){- calls.should.eql([- 'root before all'- , 'before all'- , 'before'- , 'one'- , 'after'- , 'before'- , 'two'- , 'after'- , 'before']);- calls.push('three');- })-- afterEach(function(done){- process.nextTick(function(){- calls.push('after');- done();- })- })- })-})diff --git a/test/hook.sync.js b/test/hook.sync.jsdeleted file mode 100644index d5ad9936..00000000--- a/test/hook.sync.js+++ /dev/null@@ -1,63 +0,0 @@--describe('serial', function(){- var calls = [];-- beforeEach(function(){- // not hit- calls.push('parent before');- })-- afterEach(function(){- // not hit- calls.push('parent after');- })-- describe('hooks', function(){- beforeEach(function(){- calls.push('before');- })-- it('one', function(){- calls.should.eql(['before']);- calls.push('one');- })-- it('two', function(){- calls.should.eql([- 'before'- , 'one'- , 'after'- , 'before']);- calls.push('two');- })-- it('three', function(){- calls.should.eql([- 'before'- , 'one'- , 'after'- , 'before'- , 'two'- , 'after'- , 'before']);- calls.push('three');- })-- afterEach(function(){- calls.push('after');- })-- after(function(){- calls.should.eql([- 'before'- , 'one'- , 'after'- , 'before'- , 'two'- , 'after'- , 'before'- , 'three'- , 'after']);- })- })-})\ No newline at end of filediff --git a/test/hook.sync.nested.js b/test/hook.sync.nested.jsdeleted file mode 100644index 88fe72c8..00000000--- a/test/hook.sync.nested.js+++ /dev/null@@ -1,62 +0,0 @@--describe('serial', function(){- describe('nested', function(){- var calls = [];-- beforeEach(function(){- calls.push('parent before');- })-- afterEach(function(){- calls.push('parent after');- });-- it('foo', function(){- calls.should.eql(['parent before']);- calls.push('foo');- })-- it('bar', function(){- calls.should.eql([- 'parent before'- , 'foo'- , 'parent after'- , 'parent before']);- })-- describe('hooks', function(){- beforeEach(function(){- calls.push('before');- })-- it('one', function(){- calls.should.eql([- 'parent before'- , 'foo'- , 'parent after'- , 'parent before'- , 'parent after'- , 'before']);- calls.push('one');- })-- it('two', function(){- calls.should.eql([- 'parent before'- , 'foo'- , 'parent after'- , 'parent before'- , 'parent after'- , 'before'- , 'one'- , 'after'- , 'before']);- calls.push('two');- });-- afterEach(function(){- calls.push('after');- })- })- })-})\ No newline at end of filediff --git a/test/http.js b/test/http.jsdeleted file mode 100644index 14ddd4f5..00000000--- a/test/http.js+++ /dev/null@@ -1,17 +0,0 @@--var http = require('http');--var server = http.createServer(function(req, res){- res.end('Hello World\n');-})--server.listen(8888);--describe('http', function(){- it('should provide an example', function(done){- http.get({ path: '/', port: 8888 }, function(res){- res.statusCode.should.equal(200);- done();- })- })-})\ No newline at end of filediff --git a/test/http.meta.2.js b/test/http.meta.2.jsdeleted file mode 100644index c9606495..00000000--- a/test/http.meta.2.js+++ /dev/null@@ -1,82 +0,0 @@--var http = require('http');--var server = http.createServer(function(req, res){- var accept = req.headers.accept || ''- , json = ~accept.indexOf('json');-- switch (req.url) {- case '/':- res.end('hello');- break;- case '/users':- if (json) {- res.end('["tobi","loki","jane"]');- } else {- res.end('tobi, loki, jane');- }- break;- }-})--server.listen(8899);--function get(url) {- var fields- , expected- , header = {};-- function request(done) {- http.get({ path: url, port: 8899, headers: header }, function(res){- var buf = '';- res.statusCode.should.equal(200);- res.setEncoding('utf8');- res.on('data', function(chunk){ buf += chunk });- res.on('end', function(){- buf.should.equal(expected);- done();- });- })- }-- return {- set: function(field, val){- header[field] = val;- return this;- },-- should: {- respond: function(body){- fields = Object.keys(header).map(function(field){- return field + ': ' + header[field];- }).join(', ');-- expected = body;- describe('GET ' + url, function(){- if (fields) {- describe('when given ' + fields, function(){- it('should respond with "' + body + '"', request);- });- } else {- it('should respond with "' + body + '"', request);- }- });- }- }- };-}--describe('http server', function(){- get('/')- .should- .respond('hello')-- get('/users')- .should- .respond('tobi, loki, jane')-- get('/users')- .set('Accept', 'application/json')- .should- .respond('["tobi","loki","jane"]')-})\ No newline at end of filediff --git a/test/http.meta.js b/test/http.meta.jsdeleted file mode 100644index 1a4a7ff2..00000000--- a/test/http.meta.js+++ /dev/null@@ -1,52 +0,0 @@--var http = require('http');--var server = http.createServer(function(req, res){- var accept = req.headers.accept || ''- , json = ~accept.indexOf('json');-- switch (req.url) {- case '/':- res.end('hello');- break;- case '/users':- if (json) {- res.end('["tobi","loki","jane"]');- } else {- res.end('tobi, loki, jane');- }- break;- }-})--server.listen(8889);--function get(url, body, header) {- return function(done){- http.get({ path: url, port: 8889, headers: header }, function(res){- var buf = '';- res.statusCode.should.equal(200);- res.setEncoding('utf8');- res.on('data', function(chunk){ buf += chunk });- res.on('end', function(){- buf.should.equal(body);- done();- });- })- }-}--describe('http requests', function(){- describe('GET /', function(){- it('should respond with hello',- get('/', 'hello'))- })-- describe('GET /users', function(){- it('should respond with users',- get('/users', 'tobi, loki, jane'))-- it('should respond with users',- get('/users', '["tobi","loki","jane"]', { Accept: 'application/json' }))- })-})\ No newline at end of filediff --git a/test/interfaces/bdd.js b/test/interfaces/bdd.jsdeleted file mode 100644index 9e95817d..00000000--- a/test/interfaces/bdd.js+++ /dev/null@@ -1,25 +0,0 @@--describe('Array', function(){- describe('#indexOf()', function(){- it('should return -1 when the value is not present', function(){- [1,2,3].indexOf(5).should.equal(-1);- [1,2,3].indexOf(0).should.equal(-1);- })-- it('should return the correct index when the value is present', function(){- [1,2,3].indexOf(1).should.equal(0);- [1,2,3].indexOf(2).should.equal(1);- [1,2,3].indexOf(3).should.equal(2);- })- })-})--describe('Array', function(){- describe('#pop()', function(){- it('should remove and return the last value', function(){- var arr = [1,2,3];- arr.pop().should.equal(3);- arr.should.eql([1,2]);- })- })-})\ No newline at end of filediff --git a/test/interfaces/exports.js b/test/interfaces/exports.jsdeleted file mode 100644index 8746cbcc..00000000--- a/test/interfaces/exports.js+++ /dev/null@@ -1,44 +0,0 @@--var calls = [];--exports.Array = {- before: function(){- calls.push('before');- },-- after: function(){- calls.push('after');- calls.should.eql([- 'before'- , 'before each'- , 'one'- , 'after each'- , 'before each'- , 'two'- , 'after each'- , 'after']);- },-- '#indexOf()': {- beforeEach: function(){- calls.push('before each');- },-- afterEach: function(){- calls.push('after each');- },-- 'should return -1 when the value is not present': function(){- calls.push('one');- [1,2,3].indexOf(5).should.equal(-1);- [1,2,3].indexOf(0).should.equal(-1);- },-- 'should return the correct index when the value is present': function(){- calls.push('two');- [1,2,3].indexOf(1).should.equal(0);- [1,2,3].indexOf(2).should.equal(1);- [1,2,3].indexOf(3).should.equal(2);- }- }-};diff --git a/test/interfaces/tdd.js b/test/interfaces/tdd.jsdeleted file mode 100644index c6f23080..00000000--- a/test/interfaces/tdd.js+++ /dev/null@@ -1,15 +0,0 @@--suite('Array', function(){- suite('#indexOf()', function(){- test('should return -1 when the value is not present', function(){- [1,2,3].indexOf(5).should.equal(-1);- [1,2,3].indexOf(0).should.equal(-1);- })-- test('should return the correct index when the value is present', function(){- [1,2,3].indexOf(1).should.equal(0);- [1,2,3].indexOf(2).should.equal(1);- [1,2,3].indexOf(3).should.equal(2);- })- })-})diff --git a/test/merge.js b/test/merge.jsdeleted file mode 100644index 10487feb..00000000--- a/test/merge.js+++ /dev/null@@ -1,34 +0,0 @@--describe('merge', function(){- describe('stuff', function(){- describe('one', function(){- it('should do something', function(){-- })- })-- describe('two', function(){- it('should do stuff', function(){-- })- })- })-})--describe('merge', function(){- describe('stuff', function(){- describe('three', function(){- it('should do something', function(){-- })- })- })-})--describe('merge stuff', function(){- describe('four', function(){- it('should do something', function(){-- })- })-})\ No newline at end of filediff --git a/test/misc/grep.js b/test/misc/grep.jsdeleted file mode 100644index d40effb1..00000000--- a/test/misc/grep.js+++ /dev/null@@ -1,22 +0,0 @@--describe('grep', function(){- describe('fast', function(){- it('should run fast', function(){-- })-- it('should run fast again', function(){-- })- })-- describe('slow', function(){- it('should run slow', function(done){- setTimeout(done, 1000);- })-- it('should run slow again', function(done){- setTimeout(done, 1000);- })- })-})diff --git a/test/mocha.opts b/test/mocha.optsdeleted file mode 100644index 7104117c..00000000--- a/test/mocha.opts+++ /dev/null@@ -1,4 +0,0 @@---require should---reporter dot---ui bdd---growldiff --git a/test/multiple.done.js b/test/multiple.done.jsdeleted file mode 100644index 0425e7e7..00000000--- a/test/multiple.done.js+++ /dev/null@@ -1,10 +0,0 @@--describe('multiple calls to done()', function(){- it('should fail in a test-case', function(done){- process.nextTick(function(){- done();- // uncomment- // done();- });- })-})\ No newline at end of filediff --git a/test/pending.js b/test/pending.jsdeleted file mode 100644index cf738b27..00000000--- a/test/pending.js+++ /dev/null@@ -1,4 +0,0 @@--describe('pending', function(){- it('should be allowed')-})\ No newline at end of filediff --git a/test/timeout.js b/test/timeout.jsdeleted file mode 100644index 11481600..00000000--- a/test/timeout.js+++ /dev/null@@ -1,8 +0,0 @@--describe('timeouts', function(){- it('should error on timeout', function(done){- // uncomment- // setTimeout(done, 3000);- done();- });-});\ No newline at end of filediff --git a/test/uncaught.js b/test/uncaught.jsdeleted file mode 100644index e1964da7..00000000--- a/test/uncaught.js+++ /dev/null@@ -1,10 +0,0 @@--describe('uncaught', function(){- it('should report properly', function(done){- process.nextTick(function(){- // if you uncomment this :)- // throw new Error("I'm uncaught!");- done();- })- })-})\ No newline at end of file