OLD | NEW |
1 ;(function(){ | 1 ;(function(){ |
2 | 2 |
3 // CommonJS require() | 3 // CommonJS require() |
4 | 4 |
5 function require(p){ | 5 function require(p){ |
6 var path = require.resolve(p) | 6 var path = require.resolve(p) |
7 , mod = require.modules[path]; | 7 , mod = require.modules[path]; |
8 if (!mod) throw new Error('failed to require "' + p + '"'); | 8 if (!mod) throw new Error('failed to require "' + p + '"'); |
9 if (!mod.exports) { | 9 if (!mod.exports) { |
10 mod.exports = {}; | 10 mod.exports = {}; |
(...skipping 30 matching lines...) Expand all Loading... |
41 if ('..' == seg) path.pop(); | 41 if ('..' == seg) path.pop(); |
42 else if ('.' != seg) path.push(seg); | 42 else if ('.' != seg) path.push(seg); |
43 } | 43 } |
44 | 44 |
45 return require(path.join('/')); | 45 return require(path.join('/')); |
46 }; | 46 }; |
47 }; | 47 }; |
48 | 48 |
49 | 49 |
50 require.register("browser/debug.js", function(module, exports, require){ | 50 require.register("browser/debug.js", function(module, exports, require){ |
| 51 |
51 module.exports = function(type){ | 52 module.exports = function(type){ |
52 return function(){ | 53 return function(){ |
53 } | 54 } |
54 }; | 55 }; |
55 | 56 |
56 }); // module: browser/debug.js | 57 }); // module: browser/debug.js |
57 | 58 |
58 require.register("browser/diff.js", function(module, exports, require){ | 59 require.register("browser/diff.js", function(module, exports, require){ |
59 /* See LICENSE file for terms of use */ | 60 /* See LICENSE file for terms of use */ |
60 | 61 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 } | 407 } |
407 }; | 408 }; |
408 })(); | 409 })(); |
409 | 410 |
410 if (typeof module !== 'undefined') { | 411 if (typeof module !== 'undefined') { |
411 module.exports = JsDiff; | 412 module.exports = JsDiff; |
412 } | 413 } |
413 | 414 |
414 }); // module: browser/diff.js | 415 }); // module: browser/diff.js |
415 | 416 |
416 require.register("browser/escape-string-regexp.js", function(module, exports, re
quire){ | 417 require.register("browser/events.js", function(module, exports, require){ |
417 'use strict'; | |
418 | 418 |
419 var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; | |
420 | |
421 module.exports = function (str) { | |
422 if (typeof str !== 'string') { | |
423 throw new TypeError('Expected a string'); | |
424 } | |
425 | |
426 return str.replace(matchOperatorsRe, '\\$&'); | |
427 }; | |
428 | |
429 }); // module: browser/escape-string-regexp.js | |
430 | |
431 require.register("browser/events.js", function(module, exports, require){ | |
432 /** | 419 /** |
433 * Module exports. | 420 * Module exports. |
434 */ | 421 */ |
435 | 422 |
436 exports.EventEmitter = EventEmitter; | 423 exports.EventEmitter = EventEmitter; |
437 | 424 |
438 /** | 425 /** |
439 * Check if `obj` is an array. | 426 * Check if `obj` is an array. |
440 */ | 427 */ |
441 | 428 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 586 |
600 for (var i = 0, l = listeners.length; i < l; i++) { | 587 for (var i = 0, l = listeners.length; i < l; i++) { |
601 listeners[i].apply(this, args); | 588 listeners[i].apply(this, args); |
602 } | 589 } |
603 } else { | 590 } else { |
604 return false; | 591 return false; |
605 } | 592 } |
606 | 593 |
607 return true; | 594 return true; |
608 }; | 595 }; |
609 | |
610 }); // module: browser/events.js | 596 }); // module: browser/events.js |
611 | 597 |
612 require.register("browser/fs.js", function(module, exports, require){ | 598 require.register("browser/fs.js", function(module, exports, require){ |
613 | 599 |
614 }); // module: browser/fs.js | 600 }); // module: browser/fs.js |
615 | 601 |
616 require.register("browser/glob.js", function(module, exports, require){ | |
617 | |
618 }); // module: browser/glob.js | |
619 | |
620 require.register("browser/path.js", function(module, exports, require){ | 602 require.register("browser/path.js", function(module, exports, require){ |
621 | 603 |
622 }); // module: browser/path.js | 604 }); // module: browser/path.js |
623 | 605 |
624 require.register("browser/progress.js", function(module, exports, require){ | 606 require.register("browser/progress.js", function(module, exports, require){ |
625 /** | 607 /** |
626 * Expose `Progress`. | 608 * Expose `Progress`. |
627 */ | 609 */ |
628 | 610 |
629 module.exports = Progress; | 611 module.exports = Progress; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 | 693 |
712 Progress.prototype.draw = function(ctx){ | 694 Progress.prototype.draw = function(ctx){ |
713 try { | 695 try { |
714 var percent = Math.min(this.percent, 100) | 696 var percent = Math.min(this.percent, 100) |
715 , size = this._size | 697 , size = this._size |
716 , half = size / 2 | 698 , half = size / 2 |
717 , x = half | 699 , x = half |
718 , y = half | 700 , y = half |
719 , rad = half - 1 | 701 , rad = half - 1 |
720 , fontSize = this._fontSize; | 702 , fontSize = this._fontSize; |
721 | 703 |
722 ctx.font = fontSize + 'px ' + this._font; | 704 ctx.font = fontSize + 'px ' + this._font; |
723 | 705 |
724 var angle = Math.PI * 2 * (percent / 100); | 706 var angle = Math.PI * 2 * (percent / 100); |
725 ctx.clearRect(0, 0, size, size); | 707 ctx.clearRect(0, 0, size, size); |
726 | 708 |
727 // outer circle | 709 // outer circle |
728 ctx.strokeStyle = '#9f9f9f'; | 710 ctx.strokeStyle = '#9f9f9f'; |
729 ctx.beginPath(); | 711 ctx.beginPath(); |
730 ctx.arc(x, y, rad, 0, angle, false); | 712 ctx.arc(x, y, rad, 0, angle, false); |
731 ctx.stroke(); | 713 ctx.stroke(); |
732 | 714 |
733 // inner circle | 715 // inner circle |
734 ctx.strokeStyle = '#eee'; | 716 ctx.strokeStyle = '#eee'; |
735 ctx.beginPath(); | 717 ctx.beginPath(); |
736 ctx.arc(x, y, rad - 1, 0, angle, true); | 718 ctx.arc(x, y, rad - 1, 0, angle, true); |
737 ctx.stroke(); | 719 ctx.stroke(); |
738 | 720 |
739 // text | 721 // text |
740 var text = this._text || (percent | 0) + '%' | 722 var text = this._text || (percent | 0) + '%' |
741 , w = ctx.measureText(text).width; | 723 , w = ctx.measureText(text).width; |
742 | 724 |
743 ctx.fillText( | 725 ctx.fillText( |
744 text | 726 text |
745 , x - w / 2 + 1 | 727 , x - w / 2 + 1 |
746 , y + fontSize / 2 - 1); | 728 , y + fontSize / 2 - 1); |
747 } catch (ex) {} //don't fail if we can't render progress | 729 } catch (ex) {} //don't fail if we can't render progress |
748 return this; | 730 return this; |
749 }; | 731 }; |
750 | 732 |
751 }); // module: browser/progress.js | 733 }); // module: browser/progress.js |
752 | 734 |
753 require.register("browser/tty.js", function(module, exports, require){ | 735 require.register("browser/tty.js", function(module, exports, require){ |
| 736 |
754 exports.isatty = function(){ | 737 exports.isatty = function(){ |
755 return true; | 738 return true; |
756 }; | 739 }; |
757 | 740 |
758 exports.getWindowSize = function(){ | 741 exports.getWindowSize = function(){ |
759 if ('innerHeight' in global) { | 742 if ('innerHeight' in global) { |
760 return [global.innerHeight, global.innerWidth]; | 743 return [global.innerHeight, global.innerWidth]; |
761 } else { | 744 } else { |
762 // In a Web Worker, the DOM Window is not available. | 745 // In a Web Worker, the DOM Window is not available. |
763 return [640, 480]; | 746 return [640, 480]; |
764 } | 747 } |
765 }; | 748 }; |
766 | 749 |
767 }); // module: browser/tty.js | 750 }); // module: browser/tty.js |
768 | 751 |
769 require.register("context.js", function(module, exports, require){ | 752 require.register("context.js", function(module, exports, require){ |
| 753 |
770 /** | 754 /** |
771 * Expose `Context`. | 755 * Expose `Context`. |
772 */ | 756 */ |
773 | 757 |
774 module.exports = Context; | 758 module.exports = Context; |
775 | 759 |
776 /** | 760 /** |
777 * Initialize a new `Context`. | 761 * Initialize a new `Context`. |
778 * | 762 * |
779 * @api private | 763 * @api private |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 return JSON.stringify(this, function(key, val){ | 831 return JSON.stringify(this, function(key, val){ |
848 if ('_runnable' == key) return; | 832 if ('_runnable' == key) return; |
849 if ('test' == key) return; | 833 if ('test' == key) return; |
850 return val; | 834 return val; |
851 }, 2); | 835 }, 2); |
852 }; | 836 }; |
853 | 837 |
854 }); // module: context.js | 838 }); // module: context.js |
855 | 839 |
856 require.register("hook.js", function(module, exports, require){ | 840 require.register("hook.js", function(module, exports, require){ |
| 841 |
857 /** | 842 /** |
858 * Module dependencies. | 843 * Module dependencies. |
859 */ | 844 */ |
860 | 845 |
861 var Runnable = require('./runnable'); | 846 var Runnable = require('./runnable'); |
862 | 847 |
863 /** | 848 /** |
864 * Expose `Hook`. | 849 * Expose `Hook`. |
865 */ | 850 */ |
866 | 851 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 this._error = null; | 888 this._error = null; |
904 return err; | 889 return err; |
905 } | 890 } |
906 | 891 |
907 this._error = err; | 892 this._error = err; |
908 }; | 893 }; |
909 | 894 |
910 }); // module: hook.js | 895 }); // module: hook.js |
911 | 896 |
912 require.register("interfaces/bdd.js", function(module, exports, require){ | 897 require.register("interfaces/bdd.js", function(module, exports, require){ |
| 898 |
913 /** | 899 /** |
914 * Module dependencies. | 900 * Module dependencies. |
915 */ | 901 */ |
916 | 902 |
917 var Suite = require('../suite') | 903 var Suite = require('../suite') |
918 , Test = require('../test') | 904 , Test = require('../test') |
919 , utils = require('../utils') | 905 , utils = require('../utils'); |
920 , escapeRe = require('browser/escape-string-regexp'); | |
921 | 906 |
922 /** | 907 /** |
923 * BDD-style interface: | 908 * BDD-style interface: |
924 * | 909 * |
925 * describe('Array', function(){ | 910 * describe('Array', function(){ |
926 * describe('#indexOf()', function(){ | 911 * describe('#indexOf()', function(){ |
927 * it('should return -1 when not present', function(){ | 912 * it('should return -1 when not present', function(){ |
928 * | 913 * |
929 * }); | 914 * }); |
930 * | 915 * |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 }; | 998 }; |
1014 | 999 |
1015 /** | 1000 /** |
1016 * Describe a specification or test-case | 1001 * Describe a specification or test-case |
1017 * with the given `title` and callback `fn` | 1002 * with the given `title` and callback `fn` |
1018 * acting as a thunk. | 1003 * acting as a thunk. |
1019 */ | 1004 */ |
1020 | 1005 |
1021 context.it = context.specify = function(title, fn){ | 1006 context.it = context.specify = function(title, fn){ |
1022 var suite = suites[0]; | 1007 var suite = suites[0]; |
1023 if (suite.pending) fn = null; | 1008 if (suite.pending) var fn = null; |
1024 var test = new Test(title, fn); | 1009 var test = new Test(title, fn); |
1025 test.file = file; | 1010 test.file = file; |
1026 suite.addTest(test); | 1011 suite.addTest(test); |
1027 return test; | 1012 return test; |
1028 }; | 1013 }; |
1029 | 1014 |
1030 /** | 1015 /** |
1031 * Exclusive test-case. | 1016 * Exclusive test-case. |
1032 */ | 1017 */ |
1033 | 1018 |
1034 context.it.only = function(title, fn){ | 1019 context.it.only = function(title, fn){ |
1035 var test = context.it(title, fn); | 1020 var test = context.it(title, fn); |
1036 var reString = '^' + escapeRe(test.fullTitle()) + '$'; | 1021 var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$'; |
1037 mocha.grep(new RegExp(reString)); | 1022 mocha.grep(new RegExp(reString)); |
1038 return test; | 1023 return test; |
1039 }; | 1024 }; |
1040 | 1025 |
1041 /** | 1026 /** |
1042 * Pending test case. | 1027 * Pending test case. |
1043 */ | 1028 */ |
1044 | 1029 |
1045 context.xit = | 1030 context.xit = |
1046 context.xspecify = | 1031 context.xspecify = |
1047 context.it.skip = function(title){ | 1032 context.it.skip = function(title){ |
1048 context.it(title); | 1033 context.it(title); |
1049 }; | 1034 }; |
1050 }); | 1035 }); |
1051 }; | 1036 }; |
1052 | 1037 |
1053 }); // module: interfaces/bdd.js | 1038 }); // module: interfaces/bdd.js |
1054 | 1039 |
1055 require.register("interfaces/exports.js", function(module, exports, require){ | 1040 require.register("interfaces/exports.js", function(module, exports, require){ |
| 1041 |
1056 /** | 1042 /** |
1057 * Module dependencies. | 1043 * Module dependencies. |
1058 */ | 1044 */ |
1059 | 1045 |
1060 var Suite = require('../suite') | 1046 var Suite = require('../suite') |
1061 , Test = require('../test'); | 1047 , Test = require('../test'); |
1062 | 1048 |
1063 /** | 1049 /** |
1064 * TDD-style interface: | 1050 * TDD-style interface: |
1065 * | 1051 * |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 break; | 1085 break; |
1100 case 'afterEach': | 1086 case 'afterEach': |
1101 suites[0].afterEach(fn); | 1087 suites[0].afterEach(fn); |
1102 break; | 1088 break; |
1103 default: | 1089 default: |
1104 var test = new Test(key, fn); | 1090 var test = new Test(key, fn); |
1105 test.file = file; | 1091 test.file = file; |
1106 suites[0].addTest(test); | 1092 suites[0].addTest(test); |
1107 } | 1093 } |
1108 } else { | 1094 } else { |
1109 suite = Suite.create(suites[0], key); | 1095 var suite = Suite.create(suites[0], key); |
1110 suites.unshift(suite); | 1096 suites.unshift(suite); |
1111 visit(obj[key]); | 1097 visit(obj[key]); |
1112 suites.shift(); | 1098 suites.shift(); |
1113 } | 1099 } |
1114 } | 1100 } |
1115 } | 1101 } |
1116 }; | 1102 }; |
1117 | 1103 |
1118 }); // module: interfaces/exports.js | 1104 }); // module: interfaces/exports.js |
1119 | 1105 |
1120 require.register("interfaces/index.js", function(module, exports, require){ | 1106 require.register("interfaces/index.js", function(module, exports, require){ |
| 1107 |
1121 exports.bdd = require('./bdd'); | 1108 exports.bdd = require('./bdd'); |
1122 exports.tdd = require('./tdd'); | 1109 exports.tdd = require('./tdd'); |
1123 exports.qunit = require('./qunit'); | 1110 exports.qunit = require('./qunit'); |
1124 exports.exports = require('./exports'); | 1111 exports.exports = require('./exports'); |
1125 | 1112 |
1126 }); // module: interfaces/index.js | 1113 }); // module: interfaces/index.js |
1127 | 1114 |
1128 require.register("interfaces/qunit.js", function(module, exports, require){ | 1115 require.register("interfaces/qunit.js", function(module, exports, require){ |
| 1116 |
1129 /** | 1117 /** |
1130 * Module dependencies. | 1118 * Module dependencies. |
1131 */ | 1119 */ |
1132 | 1120 |
1133 var Suite = require('../suite') | 1121 var Suite = require('../suite') |
1134 , Test = require('../test') | 1122 , Test = require('../test') |
1135 , escapeRe = require('browser/escape-string-regexp') | |
1136 , utils = require('../utils'); | 1123 , utils = require('../utils'); |
1137 | 1124 |
1138 /** | 1125 /** |
1139 * QUnit-style interface: | 1126 * QUnit-style interface: |
1140 * | 1127 * |
1141 * suite('Array'); | 1128 * suite('Array'); |
1142 * | 1129 * |
1143 * test('#length', function(){ | 1130 * test('#length', function(){ |
1144 * var arr = [1,2,3]; | 1131 * var arr = [1,2,3]; |
1145 * ok(arr.length == 3); | 1132 * ok(arr.length == 3); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 suites[0].addTest(test); | 1217 suites[0].addTest(test); |
1231 return test; | 1218 return test; |
1232 }; | 1219 }; |
1233 | 1220 |
1234 /** | 1221 /** |
1235 * Exclusive test-case. | 1222 * Exclusive test-case. |
1236 */ | 1223 */ |
1237 | 1224 |
1238 context.test.only = function(title, fn){ | 1225 context.test.only = function(title, fn){ |
1239 var test = context.test(title, fn); | 1226 var test = context.test(title, fn); |
1240 var reString = '^' + escapeRe(test.fullTitle()) + '$'; | 1227 var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$'; |
1241 mocha.grep(new RegExp(reString)); | 1228 mocha.grep(new RegExp(reString)); |
1242 }; | 1229 }; |
1243 | 1230 |
1244 /** | 1231 /** |
1245 * Pending test case. | 1232 * Pending test case. |
1246 */ | 1233 */ |
1247 | 1234 |
1248 context.test.skip = function(title){ | 1235 context.test.skip = function(title){ |
1249 context.test(title); | 1236 context.test(title); |
1250 }; | 1237 }; |
1251 }); | 1238 }); |
1252 }; | 1239 }; |
1253 | 1240 |
1254 }); // module: interfaces/qunit.js | 1241 }); // module: interfaces/qunit.js |
1255 | 1242 |
1256 require.register("interfaces/tdd.js", function(module, exports, require){ | 1243 require.register("interfaces/tdd.js", function(module, exports, require){ |
| 1244 |
1257 /** | 1245 /** |
1258 * Module dependencies. | 1246 * Module dependencies. |
1259 */ | 1247 */ |
1260 | 1248 |
1261 var Suite = require('../suite') | 1249 var Suite = require('../suite') |
1262 , Test = require('../test') | 1250 , Test = require('../test') |
1263 , escapeRe = require('browser/escape-string-regexp') | 1251 , utils = require('../utils');; |
1264 , utils = require('../utils'); | |
1265 | 1252 |
1266 /** | 1253 /** |
1267 * TDD-style interface: | 1254 * TDD-style interface: |
1268 * | 1255 * |
1269 * suite('Array', function(){ | 1256 * suite('Array', function(){ |
1270 * suite('#indexOf()', function(){ | 1257 * suite('#indexOf()', function(){ |
1271 * suiteSetup(function(){ | 1258 * suiteSetup(function(){ |
1272 * | 1259 * |
1273 * }); | 1260 * }); |
1274 * | 1261 * |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 }; | 1348 }; |
1362 | 1349 |
1363 /** | 1350 /** |
1364 * Describe a specification or test-case | 1351 * Describe a specification or test-case |
1365 * with the given `title` and callback `fn` | 1352 * with the given `title` and callback `fn` |
1366 * acting as a thunk. | 1353 * acting as a thunk. |
1367 */ | 1354 */ |
1368 | 1355 |
1369 context.test = function(title, fn){ | 1356 context.test = function(title, fn){ |
1370 var suite = suites[0]; | 1357 var suite = suites[0]; |
1371 if (suite.pending) fn = null; | 1358 if (suite.pending) var fn = null; |
1372 var test = new Test(title, fn); | 1359 var test = new Test(title, fn); |
1373 test.file = file; | 1360 test.file = file; |
1374 suite.addTest(test); | 1361 suite.addTest(test); |
1375 return test; | 1362 return test; |
1376 }; | 1363 }; |
1377 | 1364 |
1378 /** | 1365 /** |
1379 * Exclusive test-case. | 1366 * Exclusive test-case. |
1380 */ | 1367 */ |
1381 | 1368 |
1382 context.test.only = function(title, fn){ | 1369 context.test.only = function(title, fn){ |
1383 var test = context.test(title, fn); | 1370 var test = context.test(title, fn); |
1384 var reString = '^' + escapeRe(test.fullTitle()) + '$'; | 1371 var reString = '^' + utils.escapeRegexp(test.fullTitle()) + '$'; |
1385 mocha.grep(new RegExp(reString)); | 1372 mocha.grep(new RegExp(reString)); |
1386 }; | 1373 }; |
1387 | 1374 |
1388 /** | 1375 /** |
1389 * Pending test case. | 1376 * Pending test case. |
1390 */ | 1377 */ |
1391 | 1378 |
1392 context.test.skip = function(title){ | 1379 context.test.skip = function(title){ |
1393 context.test(title); | 1380 context.test(title); |
1394 }; | 1381 }; |
1395 }); | 1382 }); |
1396 }; | 1383 }; |
1397 | 1384 |
1398 }); // module: interfaces/tdd.js | 1385 }); // module: interfaces/tdd.js |
1399 | 1386 |
1400 require.register("mocha.js", function(module, exports, require){ | 1387 require.register("mocha.js", function(module, exports, require){ |
1401 /*! | 1388 /*! |
1402 * mocha | 1389 * mocha |
1403 * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca> | 1390 * Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca> |
1404 * MIT Licensed | 1391 * MIT Licensed |
1405 */ | 1392 */ |
1406 | 1393 |
1407 /** | 1394 /** |
1408 * Module dependencies. | 1395 * Module dependencies. |
1409 */ | 1396 */ |
1410 | 1397 |
1411 var path = require('browser/path') | 1398 var path = require('browser/path') |
1412 , escapeRe = require('browser/escape-string-regexp') | |
1413 , utils = require('./utils'); | 1399 , utils = require('./utils'); |
1414 | 1400 |
1415 /** | 1401 /** |
1416 * Expose `Mocha`. | 1402 * Expose `Mocha`. |
1417 */ | 1403 */ |
1418 | 1404 |
1419 exports = module.exports = Mocha; | 1405 exports = module.exports = Mocha; |
1420 | 1406 |
1421 /** | 1407 /** |
1422 * To require local UIs and reporters when running in node. | 1408 * To require local UIs and reporters when running in node. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 /** | 1600 /** |
1615 * Add regexp to grep, if `re` is a string it is escaped. | 1601 * Add regexp to grep, if `re` is a string it is escaped. |
1616 * | 1602 * |
1617 * @param {RegExp|String} re | 1603 * @param {RegExp|String} re |
1618 * @return {Mocha} | 1604 * @return {Mocha} |
1619 * @api public | 1605 * @api public |
1620 */ | 1606 */ |
1621 | 1607 |
1622 Mocha.prototype.grep = function(re){ | 1608 Mocha.prototype.grep = function(re){ |
1623 this.options.grep = 'string' == typeof re | 1609 this.options.grep = 'string' == typeof re |
1624 ? new RegExp(escapeRe(re)) | 1610 ? new RegExp(utils.escapeRegexp(re)) |
1625 : re; | 1611 : re; |
1626 return this; | 1612 return this; |
1627 }; | 1613 }; |
1628 | 1614 |
1629 /** | 1615 /** |
1630 * Invert `.grep()` matches. | 1616 * Invert `.grep()` matches. |
1631 * | 1617 * |
1632 * @return {Mocha} | 1618 * @return {Mocha} |
1633 * @api public | 1619 * @api public |
1634 */ | 1620 */ |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 * @return {Mocha} | 1751 * @return {Mocha} |
1766 * @api public | 1752 * @api public |
1767 */ | 1753 */ |
1768 | 1754 |
1769 Mocha.prototype.asyncOnly = function(){ | 1755 Mocha.prototype.asyncOnly = function(){ |
1770 this.options.asyncOnly = true; | 1756 this.options.asyncOnly = true; |
1771 return this; | 1757 return this; |
1772 }; | 1758 }; |
1773 | 1759 |
1774 /** | 1760 /** |
1775 * Disable syntax highlighting (in browser). | |
1776 * @returns {Mocha} | |
1777 * @api public | |
1778 */ | |
1779 Mocha.prototype.noHighlighting = function() { | |
1780 this.options.noHighlighting = true; | |
1781 return this; | |
1782 }; | |
1783 | |
1784 /** | |
1785 * Run tests and invoke `fn()` when complete. | 1761 * Run tests and invoke `fn()` when complete. |
1786 * | 1762 * |
1787 * @param {Function} fn | 1763 * @param {Function} fn |
1788 * @return {Runner} | 1764 * @return {Runner} |
1789 * @api public | 1765 * @api public |
1790 */ | 1766 */ |
1791 | 1767 |
1792 Mocha.prototype.run = function(fn){ | 1768 Mocha.prototype.run = function(fn){ |
1793 if (this.files.length) this.loadFiles(); | 1769 if (this.files.length) this.loadFiles(); |
1794 var suite = this.suite; | 1770 var suite = this.suite; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 * | 1804 * |
1829 * @param {String|Number} val | 1805 * @param {String|Number} val |
1830 * @param {Object} options | 1806 * @param {Object} options |
1831 * @return {String|Number} | 1807 * @return {String|Number} |
1832 * @api public | 1808 * @api public |
1833 */ | 1809 */ |
1834 | 1810 |
1835 module.exports = function(val, options){ | 1811 module.exports = function(val, options){ |
1836 options = options || {}; | 1812 options = options || {}; |
1837 if ('string' == typeof val) return parse(val); | 1813 if ('string' == typeof val) return parse(val); |
1838 return options['long'] ? longFormat(val) : shortFormat(val); | 1814 return options.long ? longFormat(val) : shortFormat(val); |
1839 }; | 1815 }; |
1840 | 1816 |
1841 /** | 1817 /** |
1842 * Parse the given `str` and return milliseconds. | 1818 * Parse the given `str` and return milliseconds. |
1843 * | 1819 * |
1844 * @param {String} str | 1820 * @param {String} str |
1845 * @return {Number} | 1821 * @return {Number} |
1846 * @api private | 1822 * @api private |
1847 */ | 1823 */ |
1848 | 1824 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 | 1891 |
1916 function plural(ms, n, name) { | 1892 function plural(ms, n, name) { |
1917 if (ms < n) return; | 1893 if (ms < n) return; |
1918 if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; | 1894 if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; |
1919 return Math.ceil(ms / n) + ' ' + name + 's'; | 1895 return Math.ceil(ms / n) + ' ' + name + 's'; |
1920 } | 1896 } |
1921 | 1897 |
1922 }); // module: ms.js | 1898 }); // module: ms.js |
1923 | 1899 |
1924 require.register("reporters/base.js", function(module, exports, require){ | 1900 require.register("reporters/base.js", function(module, exports, require){ |
| 1901 |
1925 /** | 1902 /** |
1926 * Module dependencies. | 1903 * Module dependencies. |
1927 */ | 1904 */ |
1928 | 1905 |
1929 var tty = require('browser/tty') | 1906 var tty = require('browser/tty') |
1930 , diff = require('browser/diff') | 1907 , diff = require('browser/diff') |
1931 , ms = require('../ms') | 1908 , ms = require('../ms') |
1932 , utils = require('../utils'); | 1909 , utils = require('../utils'); |
1933 | 1910 |
1934 /** | 1911 /** |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2101 } | 2078 } |
2102 | 2079 |
2103 // explicitly show diff | 2080 // explicitly show diff |
2104 if (err.showDiff && sameType(actual, expected)) { | 2081 if (err.showDiff && sameType(actual, expected)) { |
2105 escape = false; | 2082 escape = false; |
2106 err.actual = actual = utils.stringify(actual); | 2083 err.actual = actual = utils.stringify(actual); |
2107 err.expected = expected = utils.stringify(expected); | 2084 err.expected = expected = utils.stringify(expected); |
2108 } | 2085 } |
2109 | 2086 |
2110 // actual / expected diff | 2087 // actual / expected diff |
2111 if (err.showDiff && 'string' == typeof actual && 'string' == typeof expected
) { | 2088 if ('string' == typeof actual && 'string' == typeof expected) { |
2112 fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n
'); | 2089 fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n
'); |
2113 var match = message.match(/^([^:]+): expected/); | 2090 var match = message.match(/^([^:]+): expected/); |
2114 msg = '\n ' + color('error message', match ? match[1] : msg); | 2091 msg = '\n ' + color('error message', match ? match[1] : msg); |
2115 | 2092 |
2116 if (exports.inlineDiffs) { | 2093 if (exports.inlineDiffs) { |
2117 msg += inlineDiff(err, escape); | 2094 msg += inlineDiff(err, escape); |
2118 } else { | 2095 } else { |
2119 msg += unifiedDiff(err, escape); | 2096 msg += unifiedDiff(err, escape); |
2120 } | 2097 } |
2121 } | 2098 } |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2377 | 2354 |
2378 function sameType(a, b) { | 2355 function sameType(a, b) { |
2379 a = Object.prototype.toString.call(a); | 2356 a = Object.prototype.toString.call(a); |
2380 b = Object.prototype.toString.call(b); | 2357 b = Object.prototype.toString.call(b); |
2381 return a == b; | 2358 return a == b; |
2382 } | 2359 } |
2383 | 2360 |
2384 }); // module: reporters/base.js | 2361 }); // module: reporters/base.js |
2385 | 2362 |
2386 require.register("reporters/doc.js", function(module, exports, require){ | 2363 require.register("reporters/doc.js", function(module, exports, require){ |
| 2364 |
2387 /** | 2365 /** |
2388 * Module dependencies. | 2366 * Module dependencies. |
2389 */ | 2367 */ |
2390 | 2368 |
2391 var Base = require('./base') | 2369 var Base = require('./base') |
2392 , utils = require('../utils'); | 2370 , utils = require('../utils'); |
2393 | 2371 |
2394 /** | 2372 /** |
2395 * Expose `Doc`. | 2373 * Expose `Doc`. |
2396 */ | 2374 */ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 console.log('%s <dt class="error">%s</dt>', indent(), utils.escape(test.tit
le)); | 2421 console.log('%s <dt class="error">%s</dt>', indent(), utils.escape(test.tit
le)); |
2444 var code = utils.escape(utils.clean(test.fn.toString())); | 2422 var code = utils.escape(utils.clean(test.fn.toString())); |
2445 console.log('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(
), code); | 2423 console.log('%s <dd class="error"><pre><code>%s</code></pre></dd>', indent(
), code); |
2446 console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err)); | 2424 console.log('%s <dd class="error">%s</dd>', indent(), utils.escape(err)); |
2447 }); | 2425 }); |
2448 } | 2426 } |
2449 | 2427 |
2450 }); // module: reporters/doc.js | 2428 }); // module: reporters/doc.js |
2451 | 2429 |
2452 require.register("reporters/dot.js", function(module, exports, require){ | 2430 require.register("reporters/dot.js", function(module, exports, require){ |
| 2431 |
2453 /** | 2432 /** |
2454 * Module dependencies. | 2433 * Module dependencies. |
2455 */ | 2434 */ |
2456 | 2435 |
2457 var Base = require('./base') | 2436 var Base = require('./base') |
2458 , color = Base.color; | 2437 , color = Base.color; |
2459 | 2438 |
2460 /** | 2439 /** |
2461 * Expose `Dot`. | 2440 * Expose `Dot`. |
2462 */ | 2441 */ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 | 2492 |
2514 function F(){}; | 2493 function F(){}; |
2515 F.prototype = Base.prototype; | 2494 F.prototype = Base.prototype; |
2516 Dot.prototype = new F; | 2495 Dot.prototype = new F; |
2517 Dot.prototype.constructor = Dot; | 2496 Dot.prototype.constructor = Dot; |
2518 | 2497 |
2519 | 2498 |
2520 }); // module: reporters/dot.js | 2499 }); // module: reporters/dot.js |
2521 | 2500 |
2522 require.register("reporters/html-cov.js", function(module, exports, require){ | 2501 require.register("reporters/html-cov.js", function(module, exports, require){ |
| 2502 |
2523 /** | 2503 /** |
2524 * Module dependencies. | 2504 * Module dependencies. |
2525 */ | 2505 */ |
2526 | 2506 |
2527 var JSONCov = require('./json-cov') | 2507 var JSONCov = require('./json-cov') |
2528 , fs = require('browser/fs'); | 2508 , fs = require('browser/fs'); |
2529 | 2509 |
2530 /** | 2510 /** |
2531 * Expose `HTMLCov`. | 2511 * Expose `HTMLCov`. |
2532 */ | 2512 */ |
(...skipping 30 matching lines...) Expand all Loading... |
2563 * @return {String} | 2543 * @return {String} |
2564 * @api private | 2544 * @api private |
2565 */ | 2545 */ |
2566 | 2546 |
2567 function coverageClass(n) { | 2547 function coverageClass(n) { |
2568 if (n >= 75) return 'high'; | 2548 if (n >= 75) return 'high'; |
2569 if (n >= 50) return 'medium'; | 2549 if (n >= 50) return 'medium'; |
2570 if (n >= 25) return 'low'; | 2550 if (n >= 25) return 'low'; |
2571 return 'terrible'; | 2551 return 'terrible'; |
2572 } | 2552 } |
2573 | |
2574 }); // module: reporters/html-cov.js | 2553 }); // module: reporters/html-cov.js |
2575 | 2554 |
2576 require.register("reporters/html.js", function(module, exports, require){ | 2555 require.register("reporters/html.js", function(module, exports, require){ |
| 2556 |
2577 /** | 2557 /** |
2578 * Module dependencies. | 2558 * Module dependencies. |
2579 */ | 2559 */ |
2580 | 2560 |
2581 var Base = require('./base') | 2561 var Base = require('./base') |
2582 , utils = require('../utils') | 2562 , utils = require('../utils') |
2583 , Progress = require('../browser/progress') | 2563 , Progress = require('../browser/progress') |
2584 , escape = utils.escape; | 2564 , escape = utils.escape; |
2585 | 2565 |
2586 /** | 2566 /** |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 el.appendChild(pre); | 2726 el.appendChild(pre); |
2747 pre.style.display = 'none'; | 2727 pre.style.display = 'none'; |
2748 } | 2728 } |
2749 | 2729 |
2750 // Don't call .appendChild if #mocha-report was already .shift()'ed off the
stack. | 2730 // Don't call .appendChild if #mocha-report was already .shift()'ed off the
stack. |
2751 if (stack[0]) stack[0].appendChild(el); | 2731 if (stack[0]) stack[0].appendChild(el); |
2752 }); | 2732 }); |
2753 } | 2733 } |
2754 | 2734 |
2755 /** | 2735 /** |
2756 * Makes a URL, preserving querystring ("search") parameters. | |
2757 * @param {string} s | |
2758 * @returns {string} your new URL | |
2759 */ | |
2760 var makeUrl = function makeUrl(s) { | |
2761 var search = window.location.search; | |
2762 return (search ? search + '&' : '?' ) + 'grep=' + encodeURIComponent(s); | |
2763 }; | |
2764 | |
2765 /** | |
2766 * Provide suite URL | 2736 * Provide suite URL |
2767 * | 2737 * |
2768 * @param {Object} [suite] | 2738 * @param {Object} [suite] |
2769 */ | 2739 */ |
| 2740 |
2770 HTML.prototype.suiteURL = function(suite){ | 2741 HTML.prototype.suiteURL = function(suite){ |
2771 return makeUrl(suite.fullTitle()); | 2742 return '?grep=' + encodeURIComponent(suite.fullTitle()); |
2772 }; | 2743 }; |
2773 | 2744 |
2774 /** | 2745 /** |
2775 * Provide test URL | 2746 * Provide test URL |
2776 * | 2747 * |
2777 * @param {Object} [test] | 2748 * @param {Object} [test] |
2778 */ | 2749 */ |
2779 | 2750 |
2780 HTML.prototype.testURL = function(test){ | 2751 HTML.prototype.testURL = function(test){ |
2781 return makeUrl(test.fullTitle()); | 2752 return '?grep=' + encodeURIComponent(test.fullTitle()); |
2782 }; | 2753 }; |
2783 | 2754 |
2784 /** | 2755 /** |
2785 * Display error `msg`. | 2756 * Display error `msg`. |
2786 */ | 2757 */ |
2787 | 2758 |
2788 function error(msg) { | 2759 function error(msg) { |
2789 document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg)); | 2760 document.body.appendChild(fragment('<div id="mocha-error">%s</div>', msg)); |
2790 } | 2761 } |
2791 | 2762 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2852 if (el.addEventListener) { | 2823 if (el.addEventListener) { |
2853 el.addEventListener(event, fn, false); | 2824 el.addEventListener(event, fn, false); |
2854 } else { | 2825 } else { |
2855 el.attachEvent('on' + event, fn); | 2826 el.attachEvent('on' + event, fn); |
2856 } | 2827 } |
2857 } | 2828 } |
2858 | 2829 |
2859 }); // module: reporters/html.js | 2830 }); // module: reporters/html.js |
2860 | 2831 |
2861 require.register("reporters/index.js", function(module, exports, require){ | 2832 require.register("reporters/index.js", function(module, exports, require){ |
| 2833 |
2862 exports.Base = require('./base'); | 2834 exports.Base = require('./base'); |
2863 exports.Dot = require('./dot'); | 2835 exports.Dot = require('./dot'); |
2864 exports.Doc = require('./doc'); | 2836 exports.Doc = require('./doc'); |
2865 exports.TAP = require('./tap'); | 2837 exports.TAP = require('./tap'); |
2866 exports.JSON = require('./json'); | 2838 exports.JSON = require('./json'); |
2867 exports.HTML = require('./html'); | 2839 exports.HTML = require('./html'); |
2868 exports.List = require('./list'); | 2840 exports.List = require('./list'); |
2869 exports.Min = require('./min'); | 2841 exports.Min = require('./min'); |
2870 exports.Spec = require('./spec'); | 2842 exports.Spec = require('./spec'); |
2871 exports.Nyan = require('./nyan'); | 2843 exports.Nyan = require('./nyan'); |
2872 exports.XUnit = require('./xunit'); | 2844 exports.XUnit = require('./xunit'); |
2873 exports.Markdown = require('./markdown'); | 2845 exports.Markdown = require('./markdown'); |
2874 exports.Progress = require('./progress'); | 2846 exports.Progress = require('./progress'); |
2875 exports.Landing = require('./landing'); | 2847 exports.Landing = require('./landing'); |
2876 exports.JSONCov = require('./json-cov'); | 2848 exports.JSONCov = require('./json-cov'); |
2877 exports.HTMLCov = require('./html-cov'); | 2849 exports.HTMLCov = require('./html-cov'); |
2878 exports.JSONStream = require('./json-stream'); | 2850 exports.JSONStream = require('./json-stream'); |
2879 | 2851 |
2880 }); // module: reporters/index.js | 2852 }); // module: reporters/index.js |
2881 | 2853 |
2882 require.register("reporters/json-cov.js", function(module, exports, require){ | 2854 require.register("reporters/json-cov.js", function(module, exports, require){ |
| 2855 |
2883 /** | 2856 /** |
2884 * Module dependencies. | 2857 * Module dependencies. |
2885 */ | 2858 */ |
2886 | 2859 |
2887 var Base = require('./base'); | 2860 var Base = require('./base'); |
2888 | 2861 |
2889 /** | 2862 /** |
2890 * Expose `JSONCov`. | 2863 * Expose `JSONCov`. |
2891 */ | 2864 */ |
2892 | 2865 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2963 | 2936 |
2964 ret.files.sort(function(a, b) { | 2937 ret.files.sort(function(a, b) { |
2965 return a.filename.localeCompare(b.filename); | 2938 return a.filename.localeCompare(b.filename); |
2966 }); | 2939 }); |
2967 | 2940 |
2968 if (ret.sloc > 0) { | 2941 if (ret.sloc > 0) { |
2969 ret.coverage = (ret.hits / ret.sloc) * 100; | 2942 ret.coverage = (ret.hits / ret.sloc) * 100; |
2970 } | 2943 } |
2971 | 2944 |
2972 return ret; | 2945 return ret; |
2973 } | 2946 }; |
2974 | 2947 |
2975 /** | 2948 /** |
2976 * Map jscoverage data for a single source file | 2949 * Map jscoverage data for a single source file |
2977 * to a JSON structure suitable for reporting. | 2950 * to a JSON structure suitable for reporting. |
2978 * | 2951 * |
2979 * @param {String} filename name of the source file | 2952 * @param {String} filename name of the source file |
2980 * @param {Object} data jscoverage coverage data | 2953 * @param {Object} data jscoverage coverage data |
2981 * @return {Object} | 2954 * @return {Object} |
2982 * @api private | 2955 * @api private |
2983 */ | 2956 */ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3029 return { | 3002 return { |
3030 title: test.title | 3003 title: test.title |
3031 , fullTitle: test.fullTitle() | 3004 , fullTitle: test.fullTitle() |
3032 , duration: test.duration | 3005 , duration: test.duration |
3033 } | 3006 } |
3034 } | 3007 } |
3035 | 3008 |
3036 }); // module: reporters/json-cov.js | 3009 }); // module: reporters/json-cov.js |
3037 | 3010 |
3038 require.register("reporters/json-stream.js", function(module, exports, require){ | 3011 require.register("reporters/json-stream.js", function(module, exports, require){ |
| 3012 |
3039 /** | 3013 /** |
3040 * Module dependencies. | 3014 * Module dependencies. |
3041 */ | 3015 */ |
3042 | 3016 |
3043 var Base = require('./base') | 3017 var Base = require('./base') |
3044 , color = Base.color; | 3018 , color = Base.color; |
3045 | 3019 |
3046 /** | 3020 /** |
3047 * Expose `List`. | 3021 * Expose `List`. |
3048 */ | 3022 */ |
(...skipping 16 matching lines...) Expand all Loading... |
3065 | 3039 |
3066 runner.on('start', function(){ | 3040 runner.on('start', function(){ |
3067 console.log(JSON.stringify(['start', { total: total }])); | 3041 console.log(JSON.stringify(['start', { total: total }])); |
3068 }); | 3042 }); |
3069 | 3043 |
3070 runner.on('pass', function(test){ | 3044 runner.on('pass', function(test){ |
3071 console.log(JSON.stringify(['pass', clean(test)])); | 3045 console.log(JSON.stringify(['pass', clean(test)])); |
3072 }); | 3046 }); |
3073 | 3047 |
3074 runner.on('fail', function(test, err){ | 3048 runner.on('fail', function(test, err){ |
3075 test = clean(test); | 3049 console.log(JSON.stringify(['fail', clean(test)])); |
3076 test.err = err.message; | |
3077 console.log(JSON.stringify(['fail', test])); | |
3078 }); | 3050 }); |
3079 | 3051 |
3080 runner.on('end', function(){ | 3052 runner.on('end', function(){ |
3081 process.stdout.write(JSON.stringify(['end', self.stats])); | 3053 process.stdout.write(JSON.stringify(['end', self.stats])); |
3082 }); | 3054 }); |
3083 } | 3055 } |
3084 | 3056 |
3085 /** | 3057 /** |
3086 * Return a plain-object representation of `test` | 3058 * Return a plain-object representation of `test` |
3087 * free of cyclic properties etc. | 3059 * free of cyclic properties etc. |
3088 * | 3060 * |
3089 * @param {Object} test | 3061 * @param {Object} test |
3090 * @return {Object} | 3062 * @return {Object} |
3091 * @api private | 3063 * @api private |
3092 */ | 3064 */ |
3093 | 3065 |
3094 function clean(test) { | 3066 function clean(test) { |
3095 return { | 3067 return { |
3096 title: test.title | 3068 title: test.title |
3097 , fullTitle: test.fullTitle() | 3069 , fullTitle: test.fullTitle() |
3098 , duration: test.duration | 3070 , duration: test.duration |
3099 } | 3071 } |
3100 } | 3072 } |
3101 | |
3102 }); // module: reporters/json-stream.js | 3073 }); // module: reporters/json-stream.js |
3103 | 3074 |
3104 require.register("reporters/json.js", function(module, exports, require){ | 3075 require.register("reporters/json.js", function(module, exports, require){ |
| 3076 |
3105 /** | 3077 /** |
3106 * Module dependencies. | 3078 * Module dependencies. |
3107 */ | 3079 */ |
3108 | 3080 |
3109 var Base = require('./base') | 3081 var Base = require('./base') |
3110 , cursor = Base.cursor | 3082 , cursor = Base.cursor |
3111 , color = Base.color; | 3083 , color = Base.color; |
3112 | 3084 |
3113 /** | 3085 /** |
3114 * Expose `JSON`. | 3086 * Expose `JSON`. |
3115 */ | 3087 */ |
3116 | 3088 |
3117 exports = module.exports = JSONReporter; | 3089 exports = module.exports = JSONReporter; |
3118 | 3090 |
3119 /** | 3091 /** |
3120 * Initialize a new `JSON` reporter. | 3092 * Initialize a new `JSON` reporter. |
3121 * | 3093 * |
3122 * @param {Runner} runner | 3094 * @param {Runner} runner |
3123 * @api public | 3095 * @api public |
3124 */ | 3096 */ |
3125 | 3097 |
3126 function JSONReporter(runner) { | 3098 function JSONReporter(runner) { |
3127 var self = this; | 3099 var self = this; |
3128 Base.call(this, runner); | 3100 Base.call(this, runner); |
3129 | 3101 |
3130 var tests = [] | 3102 var tests = [] |
3131 , pending = [] | |
3132 , failures = [] | 3103 , failures = [] |
3133 , passes = []; | 3104 , passes = []; |
3134 | 3105 |
3135 runner.on('test end', function(test){ | 3106 runner.on('test end', function(test){ |
3136 tests.push(test); | 3107 tests.push(test); |
3137 }); | 3108 }); |
3138 | 3109 |
3139 runner.on('pass', function(test){ | 3110 runner.on('pass', function(test){ |
3140 passes.push(test); | 3111 passes.push(test); |
3141 }); | 3112 }); |
3142 | 3113 |
3143 runner.on('fail', function(test){ | 3114 runner.on('fail', function(test, err){ |
3144 failures.push(test); | 3115 failures.push(test); |
3145 }); | 3116 if (err === Object(err)) { |
3146 | 3117 test.errMsg = err.message; |
3147 runner.on('pending', function(test){ | 3118 test.errStack = err.stack; |
3148 pending.push(test); | 3119 } |
3149 }); | 3120 }); |
3150 | 3121 |
3151 runner.on('end', function(){ | 3122 runner.on('end', function(){ |
3152 var obj = { | 3123 var obj = { |
3153 stats: self.stats, | 3124 stats: self.stats, |
3154 tests: tests.map(clean), | 3125 tests: tests.map(clean), |
3155 pending: pending.map(clean), | |
3156 failures: failures.map(clean), | 3126 failures: failures.map(clean), |
3157 passes: passes.map(clean) | 3127 passes: passes.map(clean) |
3158 }; | 3128 }; |
3159 | |
3160 runner.testResults = obj; | 3129 runner.testResults = obj; |
3161 | 3130 |
3162 process.stdout.write(JSON.stringify(obj, null, 2)); | 3131 process.stdout.write(JSON.stringify(obj, null, 2)); |
3163 }); | 3132 }); |
3164 } | 3133 } |
3165 | 3134 |
3166 /** | 3135 /** |
3167 * Return a plain-object representation of `test` | 3136 * Return a plain-object representation of `test` |
3168 * free of cyclic properties etc. | 3137 * free of cyclic properties etc. |
3169 * | 3138 * |
3170 * @param {Object} test | 3139 * @param {Object} test |
3171 * @return {Object} | 3140 * @return {Object} |
3172 * @api private | 3141 * @api private |
3173 */ | 3142 */ |
3174 | 3143 |
3175 function clean(test) { | 3144 function clean(test) { |
3176 return { | 3145 return { |
3177 title: test.title, | 3146 title: test.title, |
3178 fullTitle: test.fullTitle(), | 3147 fullTitle: test.fullTitle(), |
3179 duration: test.duration, | 3148 duration: test.duration, |
3180 err: errorJSON(test.err || {}) | 3149 err: test.err, |
| 3150 errStack: test.err.stack, |
| 3151 errMessage: test.err.message |
3181 } | 3152 } |
3182 } | 3153 } |
3183 | 3154 |
3184 /** | |
3185 * Transform `error` into a JSON object. | |
3186 * @param {Error} err | |
3187 * @return {Object} | |
3188 */ | |
3189 | |
3190 function errorJSON(err) { | |
3191 var res = {}; | |
3192 Object.getOwnPropertyNames(err).forEach(function(key) { | |
3193 res[key] = err[key]; | |
3194 }, err); | |
3195 return res; | |
3196 } | |
3197 | |
3198 }); // module: reporters/json.js | 3155 }); // module: reporters/json.js |
3199 | 3156 |
3200 require.register("reporters/landing.js", function(module, exports, require){ | 3157 require.register("reporters/landing.js", function(module, exports, require){ |
| 3158 |
3201 /** | 3159 /** |
3202 * Module dependencies. | 3160 * Module dependencies. |
3203 */ | 3161 */ |
3204 | 3162 |
3205 var Base = require('./base') | 3163 var Base = require('./base') |
3206 , cursor = Base.cursor | 3164 , cursor = Base.cursor |
3207 , color = Base.color; | 3165 , color = Base.color; |
3208 | 3166 |
3209 /** | 3167 /** |
3210 * Expose `Landing`. | 3168 * Expose `Landing`. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3248 , plane = color('plane', '✈') | 3206 , plane = color('plane', '✈') |
3249 , crashed = -1 | 3207 , crashed = -1 |
3250 , n = 0; | 3208 , n = 0; |
3251 | 3209 |
3252 function runway() { | 3210 function runway() { |
3253 var buf = Array(width).join('-'); | 3211 var buf = Array(width).join('-'); |
3254 return ' ' + color('runway', buf); | 3212 return ' ' + color('runway', buf); |
3255 } | 3213 } |
3256 | 3214 |
3257 runner.on('start', function(){ | 3215 runner.on('start', function(){ |
3258 stream.write('\n\n\n '); | 3216 stream.write('\n '); |
3259 cursor.hide(); | 3217 cursor.hide(); |
3260 }); | 3218 }); |
3261 | 3219 |
3262 runner.on('test end', function(test){ | 3220 runner.on('test end', function(test){ |
3263 // check if the plane crashed | 3221 // check if the plane crashed |
3264 var col = -1 == crashed | 3222 var col = -1 == crashed |
3265 ? width * ++n / total | 0 | 3223 ? width * ++n / total | 0 |
3266 : crashed; | 3224 : crashed; |
3267 | 3225 |
3268 // show the crash | 3226 // show the crash |
3269 if ('failed' == test.state) { | 3227 if ('failed' == test.state) { |
3270 plane = color('plane crash', '✈'); | 3228 plane = color('plane crash', '✈'); |
3271 crashed = col; | 3229 crashed = col; |
3272 } | 3230 } |
3273 | 3231 |
3274 // render landing strip | 3232 // render landing strip |
3275 stream.write('\u001b['+(width+1)+'D\u001b[2A'); | 3233 stream.write('\u001b[4F\n\n'); |
3276 stream.write(runway()); | 3234 stream.write(runway()); |
3277 stream.write('\n '); | 3235 stream.write('\n '); |
3278 stream.write(color('runway', Array(col).join('â‹…'))); | 3236 stream.write(color('runway', Array(col).join('â‹…'))); |
3279 stream.write(plane) | 3237 stream.write(plane) |
3280 stream.write(color('runway', Array(width - col).join('â‹…') + '\n')); | 3238 stream.write(color('runway', Array(width - col).join('â‹…') + '\n')); |
3281 stream.write(runway()); | 3239 stream.write(runway()); |
3282 stream.write('\u001b[0m'); | 3240 stream.write('\u001b[0m'); |
3283 }); | 3241 }); |
3284 | 3242 |
3285 runner.on('end', function(){ | 3243 runner.on('end', function(){ |
3286 cursor.show(); | 3244 cursor.show(); |
3287 console.log(); | 3245 console.log(); |
3288 self.epilogue(); | 3246 self.epilogue(); |
3289 }); | 3247 }); |
3290 } | 3248 } |
3291 | 3249 |
3292 /** | 3250 /** |
3293 * Inherit from `Base.prototype`. | 3251 * Inherit from `Base.prototype`. |
3294 */ | 3252 */ |
3295 | 3253 |
3296 function F(){}; | 3254 function F(){}; |
3297 F.prototype = Base.prototype; | 3255 F.prototype = Base.prototype; |
3298 Landing.prototype = new F; | 3256 Landing.prototype = new F; |
3299 Landing.prototype.constructor = Landing; | 3257 Landing.prototype.constructor = Landing; |
3300 | 3258 |
3301 | |
3302 }); // module: reporters/landing.js | 3259 }); // module: reporters/landing.js |
3303 | 3260 |
3304 require.register("reporters/list.js", function(module, exports, require){ | 3261 require.register("reporters/list.js", function(module, exports, require){ |
| 3262 |
3305 /** | 3263 /** |
3306 * Module dependencies. | 3264 * Module dependencies. |
3307 */ | 3265 */ |
3308 | 3266 |
3309 var Base = require('./base') | 3267 var Base = require('./base') |
3310 , cursor = Base.cursor | 3268 , cursor = Base.cursor |
3311 , color = Base.color; | 3269 , color = Base.color; |
3312 | 3270 |
3313 /** | 3271 /** |
3314 * Expose `List`. | 3272 * Expose `List`. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3457 buf += code + '\n'; | 3415 buf += code + '\n'; |
3458 buf += '```\n\n'; | 3416 buf += '```\n\n'; |
3459 }); | 3417 }); |
3460 | 3418 |
3461 runner.on('end', function(){ | 3419 runner.on('end', function(){ |
3462 process.stdout.write('# TOC\n'); | 3420 process.stdout.write('# TOC\n'); |
3463 process.stdout.write(generateTOC(runner.suite)); | 3421 process.stdout.write(generateTOC(runner.suite)); |
3464 process.stdout.write(buf); | 3422 process.stdout.write(buf); |
3465 }); | 3423 }); |
3466 } | 3424 } |
3467 | |
3468 }); // module: reporters/markdown.js | 3425 }); // module: reporters/markdown.js |
3469 | 3426 |
3470 require.register("reporters/min.js", function(module, exports, require){ | 3427 require.register("reporters/min.js", function(module, exports, require){ |
| 3428 |
3471 /** | 3429 /** |
3472 * Module dependencies. | 3430 * Module dependencies. |
3473 */ | 3431 */ |
3474 | 3432 |
3475 var Base = require('./base'); | 3433 var Base = require('./base'); |
3476 | 3434 |
3477 /** | 3435 /** |
3478 * Expose `Min`. | 3436 * Expose `Min`. |
3479 */ | 3437 */ |
3480 | 3438 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3693 var stats = this.stats; | 3651 var stats = this.stats; |
3694 if (stats.failures) { | 3652 if (stats.failures) { |
3695 return '( x .x)'; | 3653 return '( x .x)'; |
3696 } else if (stats.pending) { | 3654 } else if (stats.pending) { |
3697 return '( o .o)'; | 3655 return '( o .o)'; |
3698 } else if(stats.passes) { | 3656 } else if(stats.passes) { |
3699 return '( ^ .^)'; | 3657 return '( ^ .^)'; |
3700 } else { | 3658 } else { |
3701 return '( - .-)'; | 3659 return '( - .-)'; |
3702 } | 3660 } |
3703 }; | 3661 } |
3704 | 3662 |
3705 /** | 3663 /** |
3706 * Move cursor up `n`. | 3664 * Move cursor up `n`. |
3707 * | 3665 * |
3708 * @param {Number} n | 3666 * @param {Number} n |
3709 * @api private | 3667 * @api private |
3710 */ | 3668 */ |
3711 | 3669 |
3712 NyanCat.prototype.cursorUp = function(n) { | 3670 NyanCat.prototype.cursorUp = function(n) { |
3713 write('\u001b[' + n + 'A'); | 3671 write('\u001b[' + n + 'A'); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3874 | 3832 |
3875 function F(){}; | 3833 function F(){}; |
3876 F.prototype = Base.prototype; | 3834 F.prototype = Base.prototype; |
3877 Progress.prototype = new F; | 3835 Progress.prototype = new F; |
3878 Progress.prototype.constructor = Progress; | 3836 Progress.prototype.constructor = Progress; |
3879 | 3837 |
3880 | 3838 |
3881 }); // module: reporters/progress.js | 3839 }); // module: reporters/progress.js |
3882 | 3840 |
3883 require.register("reporters/spec.js", function(module, exports, require){ | 3841 require.register("reporters/spec.js", function(module, exports, require){ |
| 3842 |
3884 /** | 3843 /** |
3885 * Module dependencies. | 3844 * Module dependencies. |
3886 */ | 3845 */ |
3887 | 3846 |
3888 var Base = require('./base') | 3847 var Base = require('./base') |
3889 , cursor = Base.cursor | 3848 , cursor = Base.cursor |
3890 , color = Base.color; | 3849 , color = Base.color; |
3891 | 3850 |
3892 /** | 3851 /** |
3893 * Expose `Spec`. | 3852 * Expose `Spec`. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3964 | 3923 |
3965 function F(){}; | 3924 function F(){}; |
3966 F.prototype = Base.prototype; | 3925 F.prototype = Base.prototype; |
3967 Spec.prototype = new F; | 3926 Spec.prototype = new F; |
3968 Spec.prototype.constructor = Spec; | 3927 Spec.prototype.constructor = Spec; |
3969 | 3928 |
3970 | 3929 |
3971 }); // module: reporters/spec.js | 3930 }); // module: reporters/spec.js |
3972 | 3931 |
3973 require.register("reporters/tap.js", function(module, exports, require){ | 3932 require.register("reporters/tap.js", function(module, exports, require){ |
| 3933 |
3974 /** | 3934 /** |
3975 * Module dependencies. | 3935 * Module dependencies. |
3976 */ | 3936 */ |
3977 | 3937 |
3978 var Base = require('./base') | 3938 var Base = require('./base') |
3979 , cursor = Base.cursor | 3939 , cursor = Base.cursor |
3980 , color = Base.color; | 3940 , color = Base.color; |
3981 | 3941 |
3982 /** | 3942 /** |
3983 * Expose `TAP`. | 3943 * Expose `TAP`. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4040 * @api private | 4000 * @api private |
4041 */ | 4001 */ |
4042 | 4002 |
4043 function title(test) { | 4003 function title(test) { |
4044 return test.fullTitle().replace(/#/g, ''); | 4004 return test.fullTitle().replace(/#/g, ''); |
4045 } | 4005 } |
4046 | 4006 |
4047 }); // module: reporters/tap.js | 4007 }); // module: reporters/tap.js |
4048 | 4008 |
4049 require.register("reporters/xunit.js", function(module, exports, require){ | 4009 require.register("reporters/xunit.js", function(module, exports, require){ |
| 4010 |
4050 /** | 4011 /** |
4051 * Module dependencies. | 4012 * Module dependencies. |
4052 */ | 4013 */ |
4053 | 4014 |
4054 var Base = require('./base') | 4015 var Base = require('./base') |
4055 , utils = require('../utils') | 4016 , utils = require('../utils') |
4056 , escape = utils.escape; | 4017 , escape = utils.escape; |
4057 | 4018 |
4058 /** | 4019 /** |
4059 * Save timer references to avoid Sinon interfering (see GH-237). | 4020 * Save timer references to avoid Sinon interfering (see GH-237). |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4165 * Return cdata escaped CDATA `str`. | 4126 * Return cdata escaped CDATA `str`. |
4166 */ | 4127 */ |
4167 | 4128 |
4168 function cdata(str) { | 4129 function cdata(str) { |
4169 return '<![CDATA[' + escape(str) + ']]>'; | 4130 return '<![CDATA[' + escape(str) + ']]>'; |
4170 } | 4131 } |
4171 | 4132 |
4172 }); // module: reporters/xunit.js | 4133 }); // module: reporters/xunit.js |
4173 | 4134 |
4174 require.register("runnable.js", function(module, exports, require){ | 4135 require.register("runnable.js", function(module, exports, require){ |
| 4136 |
4175 /** | 4137 /** |
4176 * Module dependencies. | 4138 * Module dependencies. |
4177 */ | 4139 */ |
4178 | 4140 |
4179 var EventEmitter = require('browser/events').EventEmitter | 4141 var EventEmitter = require('browser/events').EventEmitter |
4180 , debug = require('browser/debug')('mocha:runnable') | 4142 , debug = require('browser/debug')('mocha:runnable') |
4181 , milliseconds = require('./ms'); | 4143 , milliseconds = require('./ms'); |
4182 | 4144 |
4183 /** | 4145 /** |
4184 * Save timer references to avoid Sinon interfering (see GH-237). | 4146 * Save timer references to avoid Sinon interfering (see GH-237). |
(...skipping 27 matching lines...) Expand all Loading... |
4212 | 4174 |
4213 function Runnable(title, fn) { | 4175 function Runnable(title, fn) { |
4214 this.title = title; | 4176 this.title = title; |
4215 this.fn = fn; | 4177 this.fn = fn; |
4216 this.async = fn && fn.length; | 4178 this.async = fn && fn.length; |
4217 this.sync = ! this.async; | 4179 this.sync = ! this.async; |
4218 this._timeout = 2000; | 4180 this._timeout = 2000; |
4219 this._slow = 75; | 4181 this._slow = 75; |
4220 this._enableTimeouts = true; | 4182 this._enableTimeouts = true; |
4221 this.timedOut = false; | 4183 this.timedOut = false; |
4222 this._trace = new Error('done() called multiple times') | |
4223 } | 4184 } |
4224 | 4185 |
4225 /** | 4186 /** |
4226 * Inherit from `EventEmitter.prototype`. | 4187 * Inherit from `EventEmitter.prototype`. |
4227 */ | 4188 */ |
4228 | 4189 |
4229 function F(){}; | 4190 function F(){}; |
4230 F.prototype = EventEmitter.prototype; | 4191 F.prototype = EventEmitter.prototype; |
4231 Runnable.prototype = new F; | 4192 Runnable.prototype = new F; |
4232 Runnable.prototype.constructor = Runnable; | 4193 Runnable.prototype.constructor = Runnable; |
4233 | 4194 |
4234 | 4195 |
4235 /** | 4196 /** |
4236 * Set & get timeout `ms`. | 4197 * Set & get timeout `ms`. |
4237 * | 4198 * |
4238 * @param {Number|String} ms | 4199 * @param {Number|String} ms |
4239 * @return {Runnable|Number} ms or self | 4200 * @return {Runnable|Number} ms or self |
4240 * @api private | 4201 * @api private |
4241 */ | 4202 */ |
4242 | 4203 |
4243 Runnable.prototype.timeout = function(ms){ | 4204 Runnable.prototype.timeout = function(ms){ |
4244 if (0 == arguments.length) return this._timeout; | 4205 if (0 == arguments.length) return this._timeout; |
4245 if (ms === 0) this._enableTimeouts = false; | |
4246 if ('string' == typeof ms) ms = milliseconds(ms); | 4206 if ('string' == typeof ms) ms = milliseconds(ms); |
4247 debug('timeout %d', ms); | 4207 debug('timeout %d', ms); |
4248 this._timeout = ms; | 4208 this._timeout = ms; |
4249 if (this.timer) this.resetTimeout(); | 4209 if (this.timer) this.resetTimeout(); |
4250 return this; | 4210 return this; |
4251 }; | 4211 }; |
4252 | 4212 |
4253 /** | 4213 /** |
4254 * Set & get slow `ms`. | 4214 * Set & get slow `ms`. |
4255 * | 4215 * |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4325 * @api private | 4285 * @api private |
4326 */ | 4286 */ |
4327 | 4287 |
4328 Runnable.prototype.resetTimeout = function(){ | 4288 Runnable.prototype.resetTimeout = function(){ |
4329 var self = this; | 4289 var self = this; |
4330 var ms = this.timeout() || 1e9; | 4290 var ms = this.timeout() || 1e9; |
4331 | 4291 |
4332 if (!this._enableTimeouts) return; | 4292 if (!this._enableTimeouts) return; |
4333 this.clearTimeout(); | 4293 this.clearTimeout(); |
4334 this.timer = setTimeout(function(){ | 4294 this.timer = setTimeout(function(){ |
4335 if (!self._enableTimeouts) return; | |
4336 self.callback(new Error('timeout of ' + ms + 'ms exceeded')); | 4295 self.callback(new Error('timeout of ' + ms + 'ms exceeded')); |
4337 self.timedOut = true; | 4296 self.timedOut = true; |
4338 }, ms); | 4297 }, ms); |
4339 }; | 4298 }; |
4340 | 4299 |
4341 /** | 4300 /** |
4342 * Whitelist these globals for this test run | 4301 * Whitelist these globals for this test run |
4343 * | 4302 * |
4344 * @api private | 4303 * @api private |
4345 */ | 4304 */ |
(...skipping 16 matching lines...) Expand all Loading... |
4362 , finished | 4321 , finished |
4363 , emitted; | 4322 , emitted; |
4364 | 4323 |
4365 // Some times the ctx exists but it is not runnable | 4324 // Some times the ctx exists but it is not runnable |
4366 if (ctx && ctx.runnable) ctx.runnable(this); | 4325 if (ctx && ctx.runnable) ctx.runnable(this); |
4367 | 4326 |
4368 // called multiple times | 4327 // called multiple times |
4369 function multiple(err) { | 4328 function multiple(err) { |
4370 if (emitted) return; | 4329 if (emitted) return; |
4371 emitted = true; | 4330 emitted = true; |
4372 self.emit('error', err || new Error('done() called multiple times; stacktrac
e may be inaccurate')); | 4331 self.emit('error', err || new Error('done() called multiple times')); |
4373 } | 4332 } |
4374 | 4333 |
4375 // finished | 4334 // finished |
4376 function done(err) { | 4335 function done(err) { |
4377 var ms = self.timeout(); | 4336 var ms = self.timeout(); |
4378 if (self.timedOut) return; | 4337 if (self.timedOut) return; |
4379 if (finished) return multiple(err || self._trace); | 4338 if (finished) return multiple(err); |
4380 self.clearTimeout(); | 4339 self.clearTimeout(); |
4381 self.duration = new Date - start; | 4340 self.duration = new Date - start; |
4382 finished = true; | 4341 finished = true; |
4383 if (!err && self.duration > ms && self._enableTimeouts) err = new Error('tim
eout of ' + ms + 'ms exceeded'); | 4342 if (!err && self.duration > ms && self._enableTimeouts) err = new Error('tim
eout of ' + ms + 'ms exceeded'); |
4384 fn(err); | 4343 fn(err); |
4385 } | 4344 } |
4386 | 4345 |
4387 // for .resetTimeout() | 4346 // for .resetTimeout() |
4388 this.callback = done; | 4347 this.callback = done; |
4389 | 4348 |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4976 | 4935 |
4977 /** | 4936 /** |
4978 * Handle uncaught exceptions. | 4937 * Handle uncaught exceptions. |
4979 * | 4938 * |
4980 * @param {Error} err | 4939 * @param {Error} err |
4981 * @api private | 4940 * @api private |
4982 */ | 4941 */ |
4983 | 4942 |
4984 Runner.prototype.uncaught = function(err){ | 4943 Runner.prototype.uncaught = function(err){ |
4985 if (err) { | 4944 if (err) { |
4986 debug('uncaught exception %s', err !== function () { | 4945 debug('uncaught exception %s', err.message); |
4987 return this; | |
4988 }.call(err) ? err : ( err.message || err )); | |
4989 } else { | 4946 } else { |
4990 debug('uncaught undefined exception'); | 4947 debug('uncaught undefined exception'); |
4991 err = new Error('Caught undefined error, did you throw without specifying wh
at?'); | 4948 err = new Error('Catched undefined error, did you throw without specifying w
hat?'); |
4992 } | 4949 } |
| 4950 |
| 4951 var runnable = this.currentRunnable; |
| 4952 if (!runnable || 'failed' == runnable.state) return; |
| 4953 runnable.clearTimeout(); |
4993 err.uncaught = true; | 4954 err.uncaught = true; |
4994 | |
4995 var runnable = this.currentRunnable; | |
4996 if (!runnable) return; | |
4997 | |
4998 var wasAlreadyDone = runnable.state; | |
4999 this.fail(runnable, err); | 4955 this.fail(runnable, err); |
5000 | 4956 |
5001 runnable.clearTimeout(); | |
5002 | |
5003 if (wasAlreadyDone) return; | |
5004 | |
5005 // recover from test | 4957 // recover from test |
5006 if ('test' == runnable.type) { | 4958 if ('test' == runnable.type) { |
5007 this.emit('test end', runnable); | 4959 this.emit('test end', runnable); |
5008 this.hookUp('afterEach', this.next); | 4960 this.hookUp('afterEach', this.next); |
5009 return; | 4961 return; |
5010 } | 4962 } |
5011 | 4963 |
5012 // bail on hooks | 4964 // bail on hooks |
5013 this.emit('end'); | 4965 this.emit('end'); |
5014 }; | 4966 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5054 | 5006 |
5055 /** | 5007 /** |
5056 * Cleanly abort execution | 5008 * Cleanly abort execution |
5057 * | 5009 * |
5058 * @return {Runner} for chaining | 5010 * @return {Runner} for chaining |
5059 * @api public | 5011 * @api public |
5060 */ | 5012 */ |
5061 Runner.prototype.abort = function(){ | 5013 Runner.prototype.abort = function(){ |
5062 debug('aborting'); | 5014 debug('aborting'); |
5063 this._abort = true; | 5015 this._abort = true; |
5064 }; | 5016 } |
5065 | 5017 |
5066 /** | 5018 /** |
5067 * Filter leaks with the given globals flagged as `ok`. | 5019 * Filter leaks with the given globals flagged as `ok`. |
5068 * | 5020 * |
5069 * @param {Array} ok | 5021 * @param {Array} ok |
5070 * @param {Array} globals | 5022 * @param {Array} globals |
5071 * @return {Array} | 5023 * @return {Array} |
5072 * @api private | 5024 * @api private |
5073 */ | 5025 */ |
5074 | 5026 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5118 return ['errno']; | 5070 return ['errno']; |
5119 } | 5071 } |
5120 } | 5072 } |
5121 | 5073 |
5122 return []; | 5074 return []; |
5123 } | 5075 } |
5124 | 5076 |
5125 }); // module: runner.js | 5077 }); // module: runner.js |
5126 | 5078 |
5127 require.register("suite.js", function(module, exports, require){ | 5079 require.register("suite.js", function(module, exports, require){ |
| 5080 |
5128 /** | 5081 /** |
5129 * Module dependencies. | 5082 * Module dependencies. |
5130 */ | 5083 */ |
5131 | 5084 |
5132 var EventEmitter = require('browser/events').EventEmitter | 5085 var EventEmitter = require('browser/events').EventEmitter |
5133 , debug = require('browser/debug')('mocha:suite') | 5086 , debug = require('browser/debug')('mocha:suite') |
5134 , milliseconds = require('./ms') | 5087 , milliseconds = require('./ms') |
5135 , utils = require('./utils') | 5088 , utils = require('./utils') |
5136 , Hook = require('./hook'); | 5089 , Hook = require('./hook'); |
5137 | 5090 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5222 /** | 5175 /** |
5223 * Set timeout `ms` or short-hand such as "2s". | 5176 * Set timeout `ms` or short-hand such as "2s". |
5224 * | 5177 * |
5225 * @param {Number|String} ms | 5178 * @param {Number|String} ms |
5226 * @return {Suite|Number} for chaining | 5179 * @return {Suite|Number} for chaining |
5227 * @api private | 5180 * @api private |
5228 */ | 5181 */ |
5229 | 5182 |
5230 Suite.prototype.timeout = function(ms){ | 5183 Suite.prototype.timeout = function(ms){ |
5231 if (0 == arguments.length) return this._timeout; | 5184 if (0 == arguments.length) return this._timeout; |
5232 if (ms === 0) this._enableTimeouts = false; | |
5233 if ('string' == typeof ms) ms = milliseconds(ms); | 5185 if ('string' == typeof ms) ms = milliseconds(ms); |
5234 debug('timeout %d', ms); | 5186 debug('timeout %d', ms); |
5235 this._timeout = parseInt(ms, 10); | 5187 this._timeout = parseInt(ms, 10); |
5236 return this; | 5188 return this; |
5237 }; | 5189 }; |
5238 | 5190 |
5239 /** | 5191 /** |
5240 * Set timeout `enabled`. | 5192 * Set timeout `enabled`. |
5241 * | 5193 * |
5242 * @param {Boolean} enabled | 5194 * @param {Boolean} enabled |
5243 * @return {Suite|Boolean} self or enabled | 5195 * @return {Suite|Boolean} self or enabled |
5244 * @api private | 5196 * @api private |
5245 */ | 5197 */ |
5246 | 5198 |
5247 Suite.prototype.enableTimeouts = function(enabled){ | 5199 Suite.prototype.enableTimeouts = function(enabled){ |
5248 if (arguments.length === 0) return this._enableTimeouts; | 5200 if (arguments.length === 0) return this._enableTimeouts; |
5249 debug('enableTimeouts %s', enabled); | 5201 debug('enableTimeouts %s', enabled); |
5250 this._enableTimeouts = enabled; | 5202 this._enableTimeouts = enabled; |
5251 return this; | 5203 return this; |
5252 }; | 5204 } |
5253 | 5205 |
5254 /** | 5206 /** |
5255 * Set slow `ms` or short-hand such as "2s". | 5207 * Set slow `ms` or short-hand such as "2s". |
5256 * | 5208 * |
5257 * @param {Number|String} ms | 5209 * @param {Number|String} ms |
5258 * @return {Suite|Number} for chaining | 5210 * @return {Suite|Number} for chaining |
5259 * @api private | 5211 * @api private |
5260 */ | 5212 */ |
5261 | 5213 |
5262 Suite.prototype.slow = function(ms){ | 5214 Suite.prototype.slow = function(ms){ |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5471 utils.forEach(this.tests, fn); | 5423 utils.forEach(this.tests, fn); |
5472 utils.forEach(this.suites, function(suite){ | 5424 utils.forEach(this.suites, function(suite){ |
5473 suite.eachTest(fn); | 5425 suite.eachTest(fn); |
5474 }); | 5426 }); |
5475 return this; | 5427 return this; |
5476 }; | 5428 }; |
5477 | 5429 |
5478 }); // module: suite.js | 5430 }); // module: suite.js |
5479 | 5431 |
5480 require.register("test.js", function(module, exports, require){ | 5432 require.register("test.js", function(module, exports, require){ |
| 5433 |
5481 /** | 5434 /** |
5482 * Module dependencies. | 5435 * Module dependencies. |
5483 */ | 5436 */ |
5484 | 5437 |
5485 var Runnable = require('./runnable'); | 5438 var Runnable = require('./runnable'); |
5486 | 5439 |
5487 /** | 5440 /** |
5488 * Expose `Test`. | 5441 * Expose `Test`. |
5489 */ | 5442 */ |
5490 | 5443 |
(...skipping 25 matching lines...) Expand all Loading... |
5516 | 5469 |
5517 }); // module: test.js | 5470 }); // module: test.js |
5518 | 5471 |
5519 require.register("utils.js", function(module, exports, require){ | 5472 require.register("utils.js", function(module, exports, require){ |
5520 /** | 5473 /** |
5521 * Module dependencies. | 5474 * Module dependencies. |
5522 */ | 5475 */ |
5523 | 5476 |
5524 var fs = require('browser/fs') | 5477 var fs = require('browser/fs') |
5525 , path = require('browser/path') | 5478 , path = require('browser/path') |
5526 , basename = path.basename | |
5527 , exists = fs.existsSync || path.existsSync | |
5528 , glob = require('browser/glob') | |
5529 , join = path.join | 5479 , join = path.join |
5530 , debug = require('browser/debug')('mocha:watch'); | 5480 , debug = require('browser/debug')('mocha:watch'); |
5531 | 5481 |
5532 /** | 5482 /** |
5533 * Ignored directories. | 5483 * Ignored directories. |
5534 */ | 5484 */ |
5535 | 5485 |
5536 var ignore = ['node_modules', '.git']; | 5486 var ignore = ['node_modules', '.git']; |
5537 | 5487 |
5538 /** | 5488 /** |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5740 var spaces = str.match(/^\n?( *)/)[1].length | 5690 var spaces = str.match(/^\n?( *)/)[1].length |
5741 , tabs = str.match(/^\n?(\t*)/)[1].length | 5691 , tabs = str.match(/^\n?(\t*)/)[1].length |
5742 , re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces
) + '}', 'gm'); | 5692 , re = new RegExp('^\n?' + (tabs ? '\t' : ' ') + '{' + (tabs ? tabs : spaces
) + '}', 'gm'); |
5743 | 5693 |
5744 str = str.replace(re, ''); | 5694 str = str.replace(re, ''); |
5745 | 5695 |
5746 return exports.trim(str); | 5696 return exports.trim(str); |
5747 }; | 5697 }; |
5748 | 5698 |
5749 /** | 5699 /** |
| 5700 * Escape regular expression characters in `str`. |
| 5701 * |
| 5702 * @param {String} str |
| 5703 * @return {String} |
| 5704 * @api private |
| 5705 */ |
| 5706 |
| 5707 exports.escapeRegexp = function(str){ |
| 5708 return str.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"); |
| 5709 }; |
| 5710 |
| 5711 /** |
5750 * Trim the given `str`. | 5712 * Trim the given `str`. |
5751 * | 5713 * |
5752 * @param {String} str | 5714 * @param {String} str |
5753 * @return {String} | 5715 * @return {String} |
5754 * @api private | 5716 * @api private |
5755 */ | 5717 */ |
5756 | 5718 |
5757 exports.trim = function(str){ | 5719 exports.trim = function(str){ |
5758 return str.replace(/^\s+|\s+$/g, ''); | 5720 return str.replace(/^\s+|\s+$/g, ''); |
5759 }; | 5721 }; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5798 } | 5760 } |
5799 | 5761 |
5800 /** | 5762 /** |
5801 * Highlight the contents of tag `name`. | 5763 * Highlight the contents of tag `name`. |
5802 * | 5764 * |
5803 * @param {String} name | 5765 * @param {String} name |
5804 * @api private | 5766 * @api private |
5805 */ | 5767 */ |
5806 | 5768 |
5807 exports.highlightTags = function(name) { | 5769 exports.highlightTags = function(name) { |
5808 var code = document.getElementById('mocha').getElementsByTagName(name); | 5770 var code = document.getElementsByTagName(name); |
5809 for (var i = 0, len = code.length; i < len; ++i) { | 5771 for (var i = 0, len = code.length; i < len; ++i) { |
5810 code[i].innerHTML = highlight(code[i].innerHTML); | 5772 code[i].innerHTML = highlight(code[i].innerHTML); |
5811 } | 5773 } |
5812 }; | 5774 }; |
5813 | 5775 |
5814 | 5776 |
5815 /** | 5777 /** |
5816 * Stringify `obj`. | 5778 * Stringify `obj`. |
5817 * | 5779 * |
5818 * @param {Object} obj | 5780 * @param {Object} obj |
5819 * @return {String} | 5781 * @return {String} |
5820 * @api private | 5782 * @api private |
5821 */ | 5783 */ |
5822 | 5784 |
5823 exports.stringify = function(obj) { | 5785 exports.stringify = function(obj) { |
5824 if (obj instanceof RegExp) return obj.toString(); | 5786 if (obj instanceof RegExp) return obj.toString(); |
5825 return JSON.stringify(exports.canonicalize(obj), null, 2).replace(/,(\n|$)/g,
'$1'); | 5787 return JSON.stringify(exports.canonicalize(obj), null, 2).replace(/,(\n|$)/g,
'$1'); |
5826 }; | 5788 } |
5827 | 5789 |
5828 /** | 5790 /** |
5829 * Return a new object that has the keys in sorted order. | 5791 * Return a new object that has the keys in sorted order. |
5830 * @param {Object} obj | 5792 * @param {Object} obj |
5831 * @param {Array} [stack] | |
5832 * @return {Object} | 5793 * @return {Object} |
5833 * @api private | 5794 * @api private |
5834 */ | 5795 */ |
5835 | 5796 |
5836 exports.canonicalize = function(obj, stack) { | 5797 exports.canonicalize = function(obj, stack) { |
5837 stack = stack || []; | 5798 stack = stack || []; |
5838 | 5799 |
5839 if (exports.indexOf(stack, obj) !== -1) return '[Circular]'; | 5800 if (exports.indexOf(stack, obj) !== -1) return '[Circular]'; |
5840 | 5801 |
5841 var canonicalizedObj; | 5802 var canonicalizedObj; |
5842 | 5803 |
5843 if ({}.toString.call(obj) === '[object Array]') { | 5804 if ({}.toString.call(obj) === '[object Array]') { |
5844 stack.push(obj); | 5805 stack.push(obj); |
5845 canonicalizedObj = exports.map(obj, function (item) { | 5806 canonicalizedObj = exports.map(obj, function(item) { |
5846 return exports.canonicalize(item, stack); | 5807 return exports.canonicalize(item, stack); |
5847 }); | 5808 }); |
5848 stack.pop(); | 5809 stack.pop(); |
5849 } else if (typeof obj === 'object' && obj !== null) { | 5810 } else if (typeof obj === 'object' && obj !== null) { |
5850 stack.push(obj); | 5811 stack.push(obj); |
5851 canonicalizedObj = {}; | 5812 canonicalizedObj = {}; |
5852 exports.forEach(exports.keys(obj).sort(), function (key) { | 5813 exports.forEach(exports.keys(obj).sort(), function(key) { |
5853 canonicalizedObj[key] = exports.canonicalize(obj[key], stack); | 5814 canonicalizedObj[key] = exports.canonicalize(obj[key], stack); |
5854 }); | 5815 }); |
5855 stack.pop(); | 5816 stack.pop(); |
5856 } else { | 5817 } else { |
5857 canonicalizedObj = obj; | 5818 canonicalizedObj = obj; |
5858 } | 5819 } |
5859 | 5820 |
5860 return canonicalizedObj; | 5821 return canonicalizedObj; |
5861 }; | 5822 } |
5862 | |
5863 /** | |
5864 * Lookup file names at the given `path`. | |
5865 */ | |
5866 exports.lookupFiles = function lookupFiles(path, extensions, recursive) { | |
5867 var files = []; | |
5868 var re = new RegExp('\\.(' + extensions.join('|') + ')$'); | |
5869 | |
5870 if (!exists(path)) { | |
5871 if (exists(path + '.js')) { | |
5872 path += '.js'; | |
5873 } else { | |
5874 files = glob.sync(path); | |
5875 if (!files.length) throw new Error("cannot resolve path (or pattern) '" +
path + "'"); | |
5876 return files; | |
5877 } | |
5878 } | |
5879 | |
5880 try { | |
5881 var stat = fs.statSync(path); | |
5882 if (stat.isFile()) return path; | |
5883 } | |
5884 catch (ignored) { | |
5885 return; | |
5886 } | |
5887 | |
5888 fs.readdirSync(path).forEach(function(file){ | |
5889 file = join(path, file); | |
5890 try { | |
5891 var stat = fs.statSync(file); | |
5892 if (stat.isDirectory()) { | |
5893 if (recursive) { | |
5894 files = files.concat(lookupFiles(file, extensions, recursive)); | |
5895 } | |
5896 return; | |
5897 } | |
5898 } | |
5899 catch (ignored) { | |
5900 return; | |
5901 } | |
5902 if (!stat.isFile() || !re.test(file) || basename(file)[0] === '.') return; | |
5903 files.push(file); | |
5904 }); | |
5905 | |
5906 return files; | |
5907 }; | |
5908 | 5823 |
5909 }); // module: utils.js | 5824 }); // module: utils.js |
5910 // The global object is "self" in Web Workers. | 5825 // The global object is "self" in Web Workers. |
5911 var global = (function() { return this; })(); | 5826 var global = (function() { return this; })(); |
5912 | 5827 |
5913 /** | 5828 /** |
5914 * Save timer references to avoid Sinon interfering (see GH-237). | 5829 * Save timer references to avoid Sinon interfering (see GH-237). |
5915 */ | 5830 */ |
5916 | 5831 |
5917 var Date = global.Date; | 5832 var Date = global.Date; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6046 mocha.run = function(fn){ | 5961 mocha.run = function(fn){ |
6047 var options = mocha.options; | 5962 var options = mocha.options; |
6048 mocha.globals('location'); | 5963 mocha.globals('location'); |
6049 | 5964 |
6050 var query = Mocha.utils.parseQuery(global.location.search || ''); | 5965 var query = Mocha.utils.parseQuery(global.location.search || ''); |
6051 if (query.grep) mocha.grep(query.grep); | 5966 if (query.grep) mocha.grep(query.grep); |
6052 if (query.invert) mocha.invert(); | 5967 if (query.invert) mocha.invert(); |
6053 | 5968 |
6054 return Mocha.prototype.run.call(mocha, function(err){ | 5969 return Mocha.prototype.run.call(mocha, function(err){ |
6055 // The DOM Document is not available in Web Workers. | 5970 // The DOM Document is not available in Web Workers. |
6056 var document = global.document; | 5971 if (global.document) { |
6057 if (document && document.getElementById('mocha') && options.noHighlighting !
== true) { | |
6058 Mocha.utils.highlightTags('code'); | 5972 Mocha.utils.highlightTags('code'); |
6059 } | 5973 } |
6060 if (fn) fn(err); | 5974 if (fn) fn(err); |
6061 }); | 5975 }); |
6062 }; | 5976 }; |
6063 | 5977 |
6064 /** | 5978 /** |
6065 * Expose the process shim. | 5979 * Expose the process shim. |
6066 */ | 5980 */ |
6067 | 5981 |
6068 Mocha.process = process; | 5982 Mocha.process = process; |
6069 })(); | 5983 })(); |
OLD | NEW |