Permalink
Browse files

Merge branch 'commonjs'

Conflicts:
	source/console/base.js
	source/console/config.js
	source/test/reporters/spec.js
  • Loading branch information...
2 parents 3474843 + 8310a4d commit bf44ae6fef4cb43d4dd9c9193efd2d99350d760c @jcoglan committed Jan 6, 2013
Showing with 1,551 additions and 1,105 deletions.
  1. +7 −7 bin/jsbuild
  2. +7 −2 index.js
  3. +12 −0 jake.yml
  4. +20 −5 source/benchmark.js
  5. +19 −3 source/command.js
  6. +14 −1 source/comparable.js
  7. +11 −0 source/console/_head.js
  8. +3 −0 source/console/_tail.js
  9. +5 −5 source/console/base.js
  10. +4 −4 source/console/browser.js
  11. +16 −20 source/console/config.js
  12. +4 −4 source/console/console.js
  13. +2 −2 source/console/node.js
  14. +2 −2 source/console/rhino.js
  15. +2 −2 source/console/windows.js
  16. +14 −2 source/constant_scope.js
  17. +18 −0 source/core/_head.js
  18. +3 −0 source/core/_tail.js
  19. +5 −3 source/core/method.js
  20. +1 −7 source/core/utils.js
  21. +16 −3 source/decorator.js
  22. +15 −2 source/deferrable.js
  23. +9 −0 source/dom/_head.js
  24. +3 −0 source/dom/_tail.js
  25. +4 −4 source/dom/builder.js
  26. +1 −1 source/dom/dom.js
  27. +5 −5 source/dom/event.js
  28. +52 −38 source/enumerable.js
  29. +14 −1 source/forwardable.js
  30. +36 −19 source/hash.js
  31. +23 −8 source/linked_list.js
  32. +27 −17 source/method_chain.js
  33. +15 −3 source/observable.js
  34. +18 −0 source/package/_head.js
  35. +5 −0 source/package/_tail.js
  36. +2 −1 source/package/browser.js
  37. +20 −8 source/package/config.js
  38. +15 −20 source/package/dsl.js
  39. +15 −17 source/package/loader.js
  40. +6 −2 source/package/loaders/commonjs.js
  41. +9 −8 source/package/loaders/dom.js
  42. +6 −2 source/package/loaders/rhino.js
  43. +4 −3 source/package/loaders/server.js
  44. +4 −3 source/package/loaders/wsh.js
  45. +3 −2 source/package/loaders/xulrunner.js
  46. +276 −288 source/package/package.js
  47. +14 −2 source/proxy.js
  48. +30 −15 source/range.js
  49. +41 −26 source/set.js
  50. +32 −15 source/stack_trace.js
  51. +15 −3 source/state.js
  52. +18 −0 source/test/_head.js
  53. +3 −0 source/test/_tail.js
  54. +4 −4 source/test/async_steps.js
  55. +12 −12 source/test/context/context.js
  56. +5 −5 source/test/context/life_cycle.js
  57. +8 −8 source/test/context/shared_behavior.js
  58. +3 −3 source/test/context/suite.js
  59. +2 −2 source/test/context/test.js
  60. +2 −2 source/test/coverage.js
  61. +9 −9 source/test/fake_clock.js
  62. +4 −4 source/test/helpers.js
  63. +14 −14 source/test/mocking/dsl.js
  64. +8 −8 source/test/mocking/matchers.js
  65. +6 −6 source/test/mocking/parameters.js
  66. +9 −9 source/test/mocking/stub.js
  67. +15 −15 source/test/reporters/browser.js
  68. +1 −1 source/test/reporters/buster.js
  69. +3 −3 source/test/reporters/composite.js
  70. +3 −3 source/test/reporters/dot.js
  71. +8 −8 source/test/reporters/error.js
  72. +2 −2 source/test/reporters/exit_status.js
  73. +5 −5 source/test/reporters/json.js
  74. +4 −4 source/test/reporters/phantomjs.js
  75. +5 −5 source/test/reporters/progress.js
  76. +3 −3 source/test/reporters/spec.js
  77. +3 −3 source/test/reporters/tap.js
  78. +1 −1 source/test/reporters/test_swarm.js
  79. +1 −1 source/test/reporters/testacular.js
  80. +1 −1 source/test/reporters/testem.js
  81. +4 −4 source/test/reporters/xml.js
  82. +15 −15 source/test/runner.js
  83. +2 −2 source/test/ui/browser.js
  84. +6 −6 source/test/ui/terminal.js
  85. +2 −2 source/test/unit.js
  86. +4 −4 source/test/unit/assertion_message.js
  87. +8 −8 source/test/unit/assertions.js
  88. +2 −2 source/test/unit/error.js
  89. +1 −1 source/test/unit/failure.js
  90. +1 −1 source/test/unit/observable.js
  91. +17 −17 source/test/unit/test_case.js
  92. +2 −2 source/test/unit/test_result.js
  93. +3 −3 source/test/unit/test_suite.js
  94. +17 −3 source/tsort.js
  95. +11 −15 test/console.js
  96. +4 −4 test/examples/async.js
  97. +9 −9 test/examples/benchmarks.js
  98. +13 −12 test/examples/reformat.js
  99. +9 −8 test/examples/tracing.js
  100. +6 −5 test/phantom.js
  101. +49 −47 test/runner.js
  102. +13 −9 test/specs/command_spec.js
  103. +6 −2 test/specs/comparable_spec.js
  104. +21 −17 test/specs/console_spec.js
  105. +7 −3 test/specs/constant_scope_spec.js
  106. +7 −3 test/specs/decorator_spec.js
  107. +7 −3 test/specs/deferrable_spec.js
  108. +23 −18 test/specs/enumerable_spec.js
  109. +6 −2 test/specs/forwardable_spec.js
  110. +8 −4 test/specs/hash_spec.js
  111. +8 −4 test/specs/linked_list_spec.js
  112. +8 −4 test/specs/method_chain_spec.js
  113. +6 −2 test/specs/observable_spec.js
  114. +24 −24 test/specs/package_spec.js
  115. +7 −3 test/specs/proxy_spec.js
  116. +8 −4 test/specs/range_spec.js
  117. +55 −44 test/specs/set_spec.js
  118. +7 −3 test/specs/state_spec.js
  119. +5 −1 test/specs/test/context_spec.js
  120. +1 −1 test/specs/test/fake_clock_spec.js
  121. +23 −17 test/specs/test/mocking_spec.js
  122. +42 −37 test/specs/test/unit_spec.js
  123. +8 −4 test/specs/tsort_spec.js
View
@@ -33,10 +33,10 @@ var fs = require('fs'),
include = params.argv.remain.slice(),
dir = new RegExp('^' + path.resolve(params.directory || '.') + '/')
-JSCLASS_PATH = path.dirname(__filename) + '/../src'
-require(JSCLASS_PATH + '/loader')
-JS.require('JS.Console')
-var C = JS.Console
+JSCLASS_PATH = path.dirname(__filename) + '/../src';
+
+var C = require('../src/console').Console,
+ P = require('../index')
var die = function(message) {
C.consoleFormat('white', 'bgred')
@@ -69,11 +69,11 @@ if (include.length === 0) {
HTTP_REGEX = /^https?:\/\//
-JS.Package.DSL.file = function(filename) {
+P.DSL.file = function(filename) {
if (!HTTP_REGEX.test(filename))
filename = path.join(params.root || '.', filename)
- return JS.Package._getByPath(filename)
+ return P.Package._getByPath(filename)
}
if (params.manifest) require(params.manifest)
@@ -85,7 +85,7 @@ var packages = [],
output = function() { console.log(source.join('\n\n')) }
var expand = function(name, list) {
- var pkg = JS.Package._getByName(name),
+ var pkg = P.Package._getByName(name),
deps = list || []
pkg._deps.list.forEach(function(p) { expand(p, deps) })
View
@@ -1,3 +1,8 @@
-var path = require('path');
+var path = require('path'),
+ cleanup = (typeof JSCLASS_PATH === 'undefined');
+
JSCLASS_PATH = path.dirname(__filename) + '/src';
-require(JSCLASS_PATH + '/loader');
+module.exports = require(JSCLASS_PATH + '/loader');
+
+if (cleanup) delete JSCLASS_PATH;
+
View
@@ -16,6 +16,7 @@ packages:
core:
directory: core
files:
+ - _head
- utils
- method
- module
@@ -25,14 +26,17 @@ packages:
- keywords
- interface
- singleton
+ - _tail
package-browser:
directory: package
files:
+ - _head
- package
- loaders/dom
- browser
- dsl
+ - _tail
loader-browser:
extends: package-browser
@@ -42,6 +46,7 @@ packages:
package:
directory: package
files:
+ - _head
- package
- loaders/commonjs
- loaders/dom
@@ -51,6 +56,7 @@ packages:
- loaders/xulrunner
- loader
- dsl
+ - _tail
loader:
extends: package
@@ -60,6 +66,7 @@ packages:
test:
directory: test
files:
+ - _head
- unit
- unit/observable
- unit/assertions
@@ -105,24 +112,29 @@ packages:
- coverage
- helpers
- runner
+ - _tail
dom:
directory: dom
files:
+ - _head
- dom
- builder
- event
+ - _tail
console:
directory: console
files:
+ - _head
- console
- base
- browser
- node
- rhino
- windows
- config
+ - _tail
benchmark: benchmark
comparable: comparable
View
@@ -1,20 +1,31 @@
-JS.Benchmark = new JS.Module('Benchmark', {
- include: JS.Console,
+(function(factory) {
+ var E = (typeof exports === 'object'),
+ js = (typeof JS === 'undefined') ? require('./core') : JS,
+
+ Console = js.Console || require('./console').Console;
+
+ if (E) exports.JS = exports;
+ factory(js, Console, E ? exports : js);
+
+})(function(JS, Console, exports) {
+
+var Benchmark = new JS.Module('Benchmark', {
+ include: Console,
N: 5,
measure: function(name, runs, functions) {
var envs = [], env,
times = [],
block = functions.test;
- var i = runs * JS.Benchmark.N;
+ var i = runs * Benchmark.N;
while (i--) {
env = {};
if (functions.setup) functions.setup.call(env);
envs.push(env);
}
- var n = JS.Benchmark.N, start, end;
+ var n = Benchmark.N, start, end;
while (n--) {
i = runs;
start = new Date().getTime();
@@ -67,4 +78,8 @@ JS.Benchmark = new JS.Module('Benchmark', {
}
});
-JS.Benchmark.extend(JS.Benchmark);
+Benchmark.extend(Benchmark);
+
+exports.Benchmark = Benchmark;
+});
+
View
@@ -1,4 +1,16 @@
-JS.Command = new JS.Class('Command', {
+(function(factory) {
+ var E = (typeof exports === 'object'),
+ js = (typeof JS === 'undefined') ? require('./core') : JS,
+
+ Enumerable = js.Enumerable || require('./enumerable').Enumerable,
+ Observable = js.Observable || require('./observable').Observable;
+
+ if (E) exports.JS = exports;
+ factory(js, Enumerable, Observable, E ? exports : js);
+
+})(function(JS, Enumerable, Observable, exports) {
+
+var Command = new JS.Class('Command', {
initialize: function(functions) {
if (typeof functions === 'function')
functions = {execute: functions};
@@ -20,7 +32,7 @@ JS.Command = new JS.Class('Command', {
extend: {
Stack: new JS.Class({
- include: [JS.Observable || {}, JS.Enumerable || {}],
+ include: [Observable || {}, Enumerable || {}],
initialize: function(options) {
options = options || {};
@@ -30,7 +42,7 @@ JS.Command = new JS.Class('Command', {
forEach: function(block, context) {
if (!block) return this.enumFor('forEach');
- block = JS.Enumerable.toFn(block);
+ block = Enumerable.toFn(block);
for (var i = 0, n = this._stack.length; i < n; i++) {
if (this._stack[i] !== undefined)
@@ -91,3 +103,7 @@ JS.Command = new JS.Class('Command', {
})
}
});
+
+exports.Command = Command;
+});
+
View
@@ -1,4 +1,13 @@
-JS.Comparable = new JS.Module('Comparable', {
+(function(factory) {
+ var E = (typeof exports === 'object'),
+ js = (typeof JS === 'undefined') ? require('./core') : JS;
+
+ if (E) exports.JS = exports;
+ factory(js, E ? exports : js);
+
+})(function(JS, exports) {
+
+var Comparable = new JS.Module('Comparable', {
extend: {
ClassMethods: new JS.Module({
compare: function(one, another) {
@@ -35,3 +44,7 @@ JS.Comparable = new JS.Module('Comparable', {
return this.gte(a) && this.lte(b);
}
});
+
+exports.Comparable = Comparable;
+});
+
View
@@ -0,0 +1,11 @@
+(function(factory) {
+ var E = (typeof exports === 'object'),
+ js = (typeof JS === 'undefined') ? require('./core') : JS,
+
+ Enumerable = js.Enumerable || require('./enumerable').Enumerable;
+
+ if (E) exports.JS = exports;
+ factory(js, Enumerable, E ? exports : js);
+
+})(function(JS, Enumerable, exports) {
+
View
@@ -0,0 +1,3 @@
+exports.Console = Console;
+});
+
View
@@ -1,4 +1,4 @@
-JS.Console.extend({
+Console.extend({
Base: new JS.Class({
__buffer__: '',
__format__: '',
@@ -27,12 +27,12 @@ JS.Console.extend({
format: function(name, args) {
if (!this.coloring()) return;
- var escape = JS.Console.ESCAPE_CODES[name];
+ var escape = Console.ESCAPE_CODES[name];
for (var i = 0, n = args.length; i < n; i++)
escape = escape.replace('%' + (i+1), args[i]);
- this.__format__ += JS.Console.escape(escape);
+ this.__format__ += Console.escape(escape);
},
flushFormat: function() {
@@ -42,7 +42,7 @@ JS.Console.extend({
},
getDimensions: function() {
- return [JS.Console.DEFAULT_WIDTH, JS.Console.DEFAULT_HEIGHT];
+ return [Console.DEFAULT_WIDTH, Console.DEFAULT_HEIGHT];
},
output: function(string, followon) {
@@ -52,7 +52,7 @@ JS.Console.extend({
var length = this.__buffer__.length,
max = this.getDimensions()[0],
movable = (length > 0 && coloring),
- escape = movable ? JS.Console.escape('1F') + JS.Console.escape((length + 1) + 'G') : '',
+ escape = movable ? Console.escape('1F') + Console.escape((length + 1) + 'G') : '',
line = string.substr(0, max - length);
this.__buffer__ += line;
@@ -1,5 +1,5 @@
-JS.Console.extend({
- Browser: new JS.Class(JS.Console.Base, {
+Console.extend({
+ Browser: new JS.Class(Console.Base, {
backtraceFilter: function() {
return new RegExp(window.location.href.replace(/(\/[^\/]+)/g, '($1)?') + '/?', 'g');
},
@@ -9,14 +9,14 @@ JS.Console.extend({
},
envvar: function(name) {
- if (JS.Console.PHANTOM)
+ if (Console.PHANTOM)
return require('system').env[name] || null;
else
return window[name] || null;
},
getDimensions: function() {
- if (JS.Console.PHANTOM) return this.callSuper();
+ if (Console.PHANTOM) return this.callSuper();
return [1024, 1];
},
View
@@ -1,24 +1,20 @@
-(function() {
- var C = JS.Console;
+Console.BROWSER = (typeof window !== 'undefined');
+Console.NODE = (typeof process === 'object');
+Console.PHANTOM = (typeof phantom !== 'undefined');
+Console.RHINO = (typeof java !== 'undefined' && typeof java.lang !== 'undefined');
+Console.WSH = (typeof WScript !== 'undefined');
- C.BROWSER = (typeof window !== 'undefined');
- C.NODE = (typeof process === 'object');
- C.PHANTOM = (typeof phantom !== 'undefined');
- C.RHINO = (typeof java !== 'undefined' && typeof java.lang !== 'undefined');
- C.WSH = (typeof WScript !== 'undefined');
+if (Console.BROWSER) Console.adapter = new Console.Browser();
+else if (Console.NODE) Console.adapter = new Console.Node();
+else if (Console.RHINO) Console.adapter = new Console.Rhino();
+else if (Console.WSH) Console.adapter = new Console.Windows();
+else Console.adapter = new Console.Base();
- if (C.BROWSER) C.adapter = new C.Browser();
- else if (C.NODE) C.adapter = new C.Node();
- else if (C.RHINO) C.adapter = new C.Rhino();
- else if (C.WSH) C.adapter = new C.Windows();
- else C.adapter = new C.Base();
+for (var key in Console.ESCAPE_CODES) (function(key) {
+ Console.define(key, function() {
+ Console.adapter.format(key, arguments);
+ });
+})(key);
- for (var key in C.ESCAPE_CODES) (function(key) {
- C.define(key, function() {
- JS.Console.adapter.format(key, arguments);
- });
- })(key);
-
- C.extend(C);
-})();
+Console.extend(Console);
@@ -1,4 +1,4 @@
-JS.Console = new JS.Module('Console', {
+var Console = new JS.Module('Console', {
extend: {
nameOf: function(object, root) {
var results = [], i, n, field, l;
@@ -45,7 +45,7 @@ JS.Console = new JS.Module('Console', {
convert: function(object, stack) {
if (object === null || object === undefined) return String(object);
- var E = JS.Enumerable, stack = stack || [], items;
+ var E = Enumerable, stack = stack || [], items;
if (JS.indexOf(stack, object) >= 0) return '#circular';
@@ -170,12 +170,12 @@ JS.Console = new JS.Module('Console', {
print: function(string) {
string = (string === undefined ? '' : string).toString();
- JS.Console.adapter.print(string);
+ Console.adapter.print(string);
},
puts: function(string) {
string = (string === undefined ? '' : string).toString();
- JS.Console.adapter.puts(string);
+ Console.adapter.puts(string);
}
});
Oops, something went wrong.

0 comments on commit bf44ae6

Please sign in to comment.