From d41c91362c9f9c51c3a2a76cbe4a619640bb59d0 Mon Sep 17 00:00:00 2001 From: James Coglan Date: Sat, 5 Jan 2013 23:11:50 +0000 Subject: [PATCH] Change dependency-resolving code so that modules work sensibly when concatenated with jsbuild. --- bin/jsbuild | 2 ++ index.js | 6 +++- source/benchmark.js | 5 ++-- source/command.js | 6 ++-- source/comparable.js | 2 +- source/console/_head.js | 4 +-- source/constant_scope.js | 2 +- source/core/_head.js | 11 +++---- source/core/method.js | 5 ++-- source/decorator.js | 2 +- source/deferrable.js | 2 +- source/dom/_head.js | 2 +- source/enumerable.js | 2 +- source/forwardable.js | 2 +- source/hash.js | 6 ++-- source/linked_list.js | 5 ++-- source/method_chain.js | 2 +- source/observable.js | 2 +- source/package/_head.js | 7 +++-- source/package/config.js | 4 +-- source/proxy.js | 2 +- source/range.js | 6 ++-- source/set.js | 6 ++-- source/stack_trace.js | 8 +++--- source/state.js | 2 +- source/test/_head.js | 18 ++++++------ source/tsort.js | 5 ++-- test/console.js | 2 +- test/examples/async.js | 2 +- test/examples/benchmarks.js | 2 +- test/examples/reformat.js | 2 +- test/examples/tracing.js | 2 +- test/phantom.js | 4 +-- test/runner.js | 18 ++++++------ test/specs/command_spec.js | 2 +- test/specs/comparable_spec.js | 2 +- test/specs/console_spec.js | 2 +- test/specs/constant_scope_spec.js | 2 +- test/specs/decorator_spec.js | 2 +- test/specs/deferrable_spec.js | 2 +- test/specs/enumerable_spec.js | 2 +- test/specs/forwardable_spec.js | 2 +- test/specs/hash_spec.js | 2 +- test/specs/linked_list_spec.js | 2 +- test/specs/method_chain_spec.js | 2 +- test/specs/observable_spec.js | 2 +- test/specs/package_spec.js | 48 +++++++++++++++---------------- test/specs/proxy_spec.js | 2 +- test/specs/range_spec.js | 2 +- test/specs/set_spec.js | 2 +- test/specs/state_spec.js | 2 +- test/specs/test/context_spec.js | 2 +- test/specs/test/mocking_spec.js | 2 +- test/specs/test/unit_spec.js | 2 +- test/specs/tsort_spec.js | 2 +- 55 files changed, 131 insertions(+), 115 deletions(-) diff --git a/bin/jsbuild b/bin/jsbuild index fcbb356e..9a94409b 100755 --- a/bin/jsbuild +++ b/bin/jsbuild @@ -33,6 +33,8 @@ var fs = require('fs'), include = params.argv.remain.slice(), dir = new RegExp('^' + path.resolve(params.directory || '.') + '/') +JSCLASS_PATH = path.dirname(__filename) + '/../src'; + var C = require('../src/console').Console, P = require('../index') diff --git a/index.js b/index.js index 88a42947..51665150 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,8 @@ -var path = require('path'); +var path = require('path'), + cleanup = (typeof JSCLASS_PATH === 'undefined'); + JSCLASS_PATH = path.dirname(__filename) + '/src'; module.exports = require(JSCLASS_PATH + '/loader'); +if (cleanup) delete JSCLASS_PATH; + diff --git a/source/benchmark.js b/source/benchmark.js index 6c698c02..74a6922f 100644 --- a/source/benchmark.js +++ b/source/benchmark.js @@ -1,7 +1,8 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, - Console = (E ? require('./console') : JS).Console; + js = (typeof JS === 'undefined') ? require('./core') : JS, + + Console = js.Console || require('./console').Console; if (E) exports.JS = exports; factory(js, Console, E ? exports : js); diff --git a/source/command.js b/source/command.js index 802e0962..27b10e28 100644 --- a/source/command.js +++ b/source/command.js @@ -1,9 +1,9 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Enumerable = (E ? require('./enumerable') : js).Enumerable, - Observable = (E ? require('./observable') : js).Observable; + Enumerable = js.Enumerable || require('./enumerable').Enumerable, + Observable = js.Observable || require('./observable').Observable; if (E) exports.JS = exports; factory(js, Enumerable, Observable, E ? exports : js); diff --git a/source/comparable.js b/source/comparable.js index aeb634d5..0d2e3a88 100644 --- a/source/comparable.js +++ b/source/comparable.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/console/_head.js b/source/console/_head.js index bc6c79d5..e1b98e8f 100644 --- a/source/console/_head.js +++ b/source/console/_head.js @@ -1,8 +1,8 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Enumerable = (E ? require('./enumerable') : js).Enumerable; + Enumerable = js.Enumerable || require('./enumerable').Enumerable; if (E) exports.JS = exports; factory(js, Enumerable, E ? exports : js); diff --git a/source/constant_scope.js b/source/constant_scope.js index 01ecfe75..9a8fc95f 100644 --- a/source/constant_scope.js +++ b/source/constant_scope.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/core/_head.js b/source/core/_head.js index d1418565..9b0da26e 100644 --- a/source/core/_head.js +++ b/source/core/_head.js @@ -1,15 +1,16 @@ <%= license %> +var JS = (typeof JS === 'undefined') ? {} : JS; + (function(factory) { var $ = (typeof this.global === 'object') ? this.global : this, E = (typeof exports === 'object'); - if (E) + if (E) { exports.JS = exports; - else - $.JS = $.JS || {}; - - factory($, E ? exports : $.JS); + JS = exports; + } + factory($, JS); })(function(global, exports) { diff --git a/source/core/method.js b/source/core/method.js index 68adce69..47d274e5 100644 --- a/source/core/method.js +++ b/source/core/method.js @@ -81,7 +81,7 @@ JS.extend(JS.Method.prototype, { return returnValue; }; - var StackTrace = ((typeof require === 'function') ? require('./stack_trace') : global.JS).StackTrace; + var StackTrace = trace && (exports.StackTrace || require('./stack_trace').StackTrace); if (trace) return StackTrace.wrap(compiled, method, environment); return compiled; }, @@ -134,7 +134,8 @@ JS.Method.keyword = function(name, filter) { }; JS.Method.tracing = function(classes, block, context) { - global.JS.require('JS.StackTrace', function(StackTrace) { + var pkg = exports.require ? exports : require('./loader'); + pkg.require('JS.StackTrace', function(StackTrace) { var logger = StackTrace.logger, active = logger.active; diff --git a/source/decorator.js b/source/decorator.js index ed918138..0c9b8522 100644 --- a/source/decorator.js +++ b/source/decorator.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/deferrable.js b/source/deferrable.js index 524b9613..fa38a838 100644 --- a/source/deferrable.js +++ b/source/deferrable.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/dom/_head.js b/source/dom/_head.js index 6afa651b..359c9ef1 100644 --- a/source/dom/_head.js +++ b/source/dom/_head.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/enumerable.js b/source/enumerable.js index 237f12c2..0ec3b814 100644 --- a/source/enumerable.js +++ b/source/enumerable.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/forwardable.js b/source/forwardable.js index 3627a4c7..1acbcf87 100644 --- a/source/forwardable.js +++ b/source/forwardable.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/hash.js b/source/hash.js index c8e64031..eb3bcf70 100644 --- a/source/hash.js +++ b/source/hash.js @@ -1,9 +1,9 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Enumerable = (E ? require('./enumerable') : js).Enumerable, - Comparable = (E ? require('./comparable') : js).Comparable; + Enumerable = js.Enumerable || require('./enumerable').Enumerable, + Comparable = js.Comparable || require('./comparable').Comparable; if (E) exports.JS = exports; factory(js, Enumerable, Comparable, E ? exports : js); diff --git a/source/linked_list.js b/source/linked_list.js index 6cd1f82b..5cbce552 100644 --- a/source/linked_list.js +++ b/source/linked_list.js @@ -1,7 +1,8 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, - Enumerable = (E ? require('./enumerable') : js).Enumerable; + js = (typeof JS === 'undefined') ? require('./core') : JS, + + Enumerable = js.Enumerable || require('./enumerable').Enumerable; if (E) exports.JS = exports; factory(js, Enumerable, E ? exports : js); diff --git a/source/method_chain.js b/source/method_chain.js index 0d10e8e7..c174c70a 100644 --- a/source/method_chain.js +++ b/source/method_chain.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/observable.js b/source/observable.js index c098df3d..cdef8552 100644 --- a/source/observable.js +++ b/source/observable.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/package/_head.js b/source/package/_head.js index da43f6f1..05ff34cf 100644 --- a/source/package/_head.js +++ b/source/package/_head.js @@ -6,8 +6,11 @@ var JS = (typeof JS === 'undefined') ? {} : JS; var $ = (typeof this.global === 'object') ? this.global : this, E = (typeof exports === 'object'); - if (E) exports.JS = exports; - factory($, E ? exports : JS); + if (E) { + exports.JS = exports; + JS = exports; + } + factory($, JS); })(function(global, exports) { diff --git a/source/package/config.js b/source/package/config.js index c8bd245a..f4c2d853 100644 --- a/source/package/config.js +++ b/source/package/config.js @@ -97,8 +97,8 @@ P.packages(function() { with(this) { 'JS.OrderedSet', 'JS.SortedSet') .requires('JS.Class', - 'JS.Enumerable') - .uses( 'JS.Hash'); + 'JS.Enumerable', + 'JS.Hash'); module('linked_list') .provides('JS.LinkedList', 'JS.LinkedList.Doubly', diff --git a/source/proxy.js b/source/proxy.js index 58c69758..f92342e8 100644 --- a/source/proxy.js +++ b/source/proxy.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/range.js b/source/range.js index b8ec5ddd..36c8a4e4 100644 --- a/source/range.js +++ b/source/range.js @@ -1,9 +1,9 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Enumerable = (E ? require('./enumerable') : js).Enumerable, - Hash = (E ? require('./hash') : js).Hash; + Enumerable = js.Enumerable || require('./enumerable').Enumerable, + Hash = js.Hash || require('./hash').Hash; if (E) exports.JS = exports; factory(js, Enumerable, Hash, E ? exports : js); diff --git a/source/set.js b/source/set.js index f7a74dda..8a91218a 100644 --- a/source/set.js +++ b/source/set.js @@ -1,9 +1,9 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Enumerable = (E ? require('./enumerable') : js).Enumerable, - hash = (E ? require('./hash') : js); + Enumerable = js.Enumerable || require('./enumerable').Enumerable, + hash = js.Hash ? js : require('./hash'); if (E) exports.JS = exports; factory(js, Enumerable, hash, E ? exports : js); diff --git a/source/stack_trace.js b/source/stack_trace.js index 7581cf0c..f51a6629 100644 --- a/source/stack_trace.js +++ b/source/stack_trace.js @@ -1,10 +1,10 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Observable = (E ? require('./observable') : js).Observable, - Enumerable = (E ? require('./enumerable') : js).Enumerable, - Console = (E ? require('./console') : js).Console; + Observable = js.Observable || require('./observable').Observable, + Enumerable = js.Enumerable || require('./enumerable').Enumerable, + Console = js.Console || require('./console').Console; if (E) exports.JS = exports; factory(js, Observable, Enumerable, Console, E ? exports : js); diff --git a/source/state.js b/source/state.js index bb90cdeb..a310ec9a 100644 --- a/source/state.js +++ b/source/state.js @@ -1,6 +1,6 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS; + js = (typeof JS === 'undefined') ? require('./core') : JS; if (E) exports.JS = exports; factory(js, E ? exports : js); diff --git a/source/test/_head.js b/source/test/_head.js index ff1af734..8960fa22 100644 --- a/source/test/_head.js +++ b/source/test/_head.js @@ -1,15 +1,15 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, + js = (typeof JS === 'undefined') ? require('./core') : JS, - Console = (E ? require('./console') : js).Console, - DOM = (E ? require('./dom') : js).DOM, - Enumerable = (E ? require('./enumerable') : js).Enumerable, - SortedSet = (E ? require('./set') : js).SortedSet, - Range = (E ? require('./range') : js).Range, - MethodChain = (E ? require('./method_chain') : js).MethodChain, - Comparable = (E ? require('./comparable') : js).Comparable, - StackTrace = (E ? require('./stack_trace') : js).StackTrace; + Console = js.Console || require('./console').Console, + DOM = js.DOM || require('./dom').DOM, + Enumerable = js.Enumerable || require('./enumerable').Enumerable, + SortedSet = js.SortedSet || require('./set').SortedSet, + Range = js.Range || require('./range').Range, + MethodChain = js.MethodChain || require('./method_chain').MethodChain, + Comparable = js.Comparable || require('./comparable').Comparable, + StackTrace = js.StackTrace || require('./stack_trace').StackTrace; if (E) exports.JS = exports; factory(js, Console, DOM, Enumerable, SortedSet, Range, MethodChain, Comparable, StackTrace, E ? exports : js); diff --git a/source/tsort.js b/source/tsort.js index 41e7ceba..02ac239f 100644 --- a/source/tsort.js +++ b/source/tsort.js @@ -1,7 +1,8 @@ (function(factory) { var E = (typeof exports === 'object'), - js = E ? require('./core') : JS, - Hash = (E ? require('./hash') : js).Hash; + js = (typeof JS === 'undefined') ? require('./core') : JS, + + Hash = js.Hash || require('./hash').Hash; if (E) exports.JS = exports; factory(js, Hash, E ? exports : js); diff --git a/test/console.js b/test/console.js index 308afaa8..d5fa13ab 100644 --- a/test/console.js +++ b/test/console.js @@ -19,7 +19,7 @@ if (this.ActiveXObject) load = function(path) { } if (typeof require === 'function') { - $.JS = require('../' + path + 'loader'); + $.PKG = require('../' + path + 'loader'); require('./runner'); } else { load(path + 'loader.js'); diff --git a/test/examples/async.js b/test/examples/async.js index 5ec0a72a..c1a4c3db 100644 --- a/test/examples/async.js +++ b/test/examples/async.js @@ -1,5 +1,5 @@ JSCLASS_PATH = "build/min/" -require("../../" + JSCLASS_PATH + "loader") +var JS = require("../../" + JSCLASS_PATH + "loader") JS.require("JS.Test", "JS.MethodChain", function(Test, MC) { diff --git a/test/examples/benchmarks.js b/test/examples/benchmarks.js index eccc0751..c03e2c5d 100644 --- a/test/examples/benchmarks.js +++ b/test/examples/benchmarks.js @@ -4,7 +4,7 @@ })() if (typeof require === 'function') - require('../../' + JSCLASS_PATH + 'loader') + var JS = require('../../' + JSCLASS_PATH + 'loader') else load(JSCLASS_PATH + 'loader.js') diff --git a/test/examples/reformat.js b/test/examples/reformat.js index 29c6663f..0b7a7ba6 100644 --- a/test/examples/reformat.js +++ b/test/examples/reformat.js @@ -6,7 +6,7 @@ // $ node test/console -f json | node test/examples/reformat -f tap JSCLASS_PATH = 'build/src' -require('../../' + JSCLASS_PATH + '/loader') +var JS = require('../../' + JSCLASS_PATH + '/loader') JS.require('JS.Test', function(Test) { var options = require('nopt')({format: String}), diff --git a/test/examples/tracing.js b/test/examples/tracing.js index a1b9b69c..5f1abe9a 100644 --- a/test/examples/tracing.js +++ b/test/examples/tracing.js @@ -15,7 +15,7 @@ if (this.ActiveXObject) load = function(path) { })() if (typeof require === 'function') { - require('../../' + JSCLASS_PATH + 'loader') + var JS = require('../../' + JSCLASS_PATH + 'loader') } else { load(JSCLASS_PATH + 'loader.js') } diff --git a/test/phantom.js b/test/phantom.js index 115f699f..602753f8 100644 --- a/test/phantom.js +++ b/test/phantom.js @@ -1,7 +1,7 @@ JSCLASS_PATH = '../build/src' -require(JSCLASS_PATH + '/loader') +var pkg = require(JSCLASS_PATH + '/loader') -JS.require('JS.Test', function(Test) { +pkg.require('JS.Test', function(Test) { var page = new WebPage(), reporter = new Test.Reporters.PhantomJS({}, page) diff --git a/test/runner.js b/test/runner.js index ea1fd406..6814727b 100644 --- a/test/runner.js +++ b/test/runner.js @@ -1,9 +1,10 @@ -JS.ENV.CWD = (typeof CWD === 'undefined') ? '.' : CWD +PKG = (typeof PKG === 'object') ? PKG : JS +PKG.ENV.CWD = (typeof CWD === 'undefined') ? '.' : CWD -JS.cacheBust = true -if (JS.ENV.JS_DEBUG) JS.debug = true +PKG.cacheBust = true +if (PKG.ENV.JS_DEBUG) PKG.debug = true -JS.packages(function() { with(this) { +PKG.packages(function() { with(this) { autoload(/^(.*)Spec$/, {from: CWD + '/test/specs', require: 'JS.$1'}) pkg('Test.UnitSpec').requires('JS.Set', 'JS.Observable') @@ -15,9 +16,10 @@ JS.packages(function() { with(this) { pkg('Test.MockingSpec').requires('TestSpecHelpers') }}) -JS.require('JS', 'JS.Test', function(js, Test) { - js.extend(JS, js) - JS.Test = Test +PKG.require('JS', 'JS.Test', function(JS, Test) { + PKG.ENV.JS = JS + JS.Package = PKG.Package + JS.Test = Test var specs = [ 'Test.UnitSpec', 'Test.ContextSpec', @@ -51,6 +53,6 @@ JS.require('JS', 'JS.Test', function(js, Test) { specs = Test.filter(specs, 'Spec') specs.push(function() { Test.autorun() }) - JS.require.apply(JS, specs) + PKG.require.apply(PKG, specs) }) diff --git a/test/specs/command_spec.js b/test/specs/command_spec.js index 099df9cf..c7fb7b66 100644 --- a/test/specs/command_spec.js +++ b/test/specs/command_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Command', function(Command) { +PKG.require('JS.Command', function(Command) { JS.ENV.CommandSpec = JS.Test.describe(Command, function() { with(this) { before(function() { this.counter = 0 }) diff --git a/test/specs/comparable_spec.js b/test/specs/comparable_spec.js index e6c3df14..14239e44 100644 --- a/test/specs/comparable_spec.js +++ b/test/specs/comparable_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Comparable', function(Comparable) { +PKG.require('JS.Comparable', function(Comparable) { JS.ENV.ComparableSpec = JS.Test.describe(Comparable, function() { with(this) { include(JS.Test.Helpers) diff --git a/test/specs/console_spec.js b/test/specs/console_spec.js index 93454754..dcf2ae88 100644 --- a/test/specs/console_spec.js +++ b/test/specs/console_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Console', function(Console) { +PKG.require('JS.Console', function(Console) { JS.ENV.ConsoleSpec = JS.Test.describe(Console, function() { with(this) { describe("convert", function() { with(this) { diff --git a/test/specs/constant_scope_spec.js b/test/specs/constant_scope_spec.js index d4e6ae5a..398ce69c 100644 --- a/test/specs/constant_scope_spec.js +++ b/test/specs/constant_scope_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.ConstantScope', function(ConstantScope) { +PKG.require('JS.ConstantScope', function(ConstantScope) { JS.ENV.ConstantScopeSpec = JS.Test.describe(ConstantScope, function() { with(this) { include(JS.Test.Helpers) diff --git a/test/specs/decorator_spec.js b/test/specs/decorator_spec.js index 23c63f13..5b01f630 100644 --- a/test/specs/decorator_spec.js +++ b/test/specs/decorator_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Decorator', function(Decorator) { +PKG.require('JS.Decorator', function(Decorator) { JS.ENV.DecoratorSpec = JS.Test.describe(Decorator, function() { with(this) { var Bicycle = new JS.Class({ diff --git a/test/specs/deferrable_spec.js b/test/specs/deferrable_spec.js index 615de872..0830fb6d 100644 --- a/test/specs/deferrable_spec.js +++ b/test/specs/deferrable_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Deferrable', function(Deferrable) { +PKG.require('JS.Deferrable', function(Deferrable) { JS.ENV.DeferrableSpec = JS.Test.describe(Deferrable, function() { with(this) { include(JS.Test.FakeClock) diff --git a/test/specs/enumerable_spec.js b/test/specs/enumerable_spec.js index 92c16ab9..9a6bb0fb 100644 --- a/test/specs/enumerable_spec.js +++ b/test/specs/enumerable_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Comparable', 'JS.Enumerable', 'JS.Hash', 'JS.Range', +PKG.require('JS.Comparable', 'JS.Enumerable', 'JS.Hash', 'JS.Range', function(Comparable, Enumerable, Hash, Range) { JS.ENV.EnumerableSpec = JS.Test.describe(Enumerable, function() { with(this) { diff --git a/test/specs/forwardable_spec.js b/test/specs/forwardable_spec.js index 87bdb4df..af63ffbb 100644 --- a/test/specs/forwardable_spec.js +++ b/test/specs/forwardable_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Forwardable', function(Forwardable) { +PKG.require('JS.Forwardable', function(Forwardable) { JS.ENV.ForwardableSpec = JS.Test.describe(Forwardable, function() { with(this) { define("Subject", new JS.Class({ diff --git a/test/specs/hash_spec.js b/test/specs/hash_spec.js index b6fb6be6..afaeff2e 100644 --- a/test/specs/hash_spec.js +++ b/test/specs/hash_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Hash', 'JS.OrderedHash', function(Hash, OrderedHash) { +PKG.require('JS.Hash', 'JS.OrderedHash', function(Hash, OrderedHash) { JS.ENV.HashSpec = JS.Test.describe(Hash, function() { with(this) { include(JS.Test.Helpers) diff --git a/test/specs/linked_list_spec.js b/test/specs/linked_list_spec.js index a516b352..4b2aa782 100644 --- a/test/specs/linked_list_spec.js +++ b/test/specs/linked_list_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Enumerable', 'JS.LinkedList', function(Enumerable, LinkedList) { +PKG.require('JS.Enumerable', 'JS.LinkedList', function(Enumerable, LinkedList) { JS.ENV.LinkedListSpec = JS.Test.describe(LinkedList, function() { with(this) { describe(LinkedList.Doubly.Circular, function() { with(this) { diff --git a/test/specs/method_chain_spec.js b/test/specs/method_chain_spec.js index 05b7fd8b..a576553d 100644 --- a/test/specs/method_chain_spec.js +++ b/test/specs/method_chain_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.MethodChain', function(MethodChain) { +PKG.require('JS.MethodChain', function(MethodChain) { JS.ENV.MethodChainSpec = JS.Test.describe(MethodChain, function() { with(this) { include(JS.Test.Helpers) diff --git a/test/specs/observable_spec.js b/test/specs/observable_spec.js index d774c634..4043d184 100644 --- a/test/specs/observable_spec.js +++ b/test/specs/observable_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Observable', function(Observable) { +PKG.require('JS.Observable', function(Observable) { JS.ENV.ObservableSpec = JS.Test.describe(Observable, function() { with(this) { before(function() { with(this) { diff --git a/test/specs/package_spec.js b/test/specs/package_spec.js index 9859b813..c4136400 100644 --- a/test/specs/package_spec.js +++ b/test/specs/package_spec.js @@ -9,7 +9,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { store: function(name) { this._objectNames.push(name); - var env = JS.Package.ENV, + var env = PKG.ENV, parts = name.split('.'), used = [], part; @@ -25,7 +25,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { this.store(name); var defineObject = function() { - var env = JS.Package.ENV, + var env = PKG.ENV, parts = name.split('.'), part; @@ -35,7 +35,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { var loaded = this._loaded; - JS.Packages(function() { with(this) { + PKG.packages(function() { with(this) { var block = function(callback) { JS.ENV.setTimeout(function() { defineObject(name); @@ -67,7 +67,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { after(function() { with(this) { forEach(_objectNames, JS.Package.remove, JS.Package) forEach(_undefined, function(name) { - var env = JS.Package.ENV, + var env = PKG.ENV, parts = name.split('.'), last = parts.pop(), part; @@ -79,7 +79,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { describe("loading a CommonJS module", function() { with(this) { before(function() { with(this) { - JS.Packages(function() { with(this) { + PKG.packages(function() { with(this) { file(CWD + "/test/fixtures/common.js").provides("Common", "HTTP") }}) }}) @@ -90,7 +90,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { }}) it("yields the required objects to the callback", function(resume) { with(this) { - JS.require("Common", "HTTP", function(Common, HTTP) { + PKG.require("Common", "HTTP", function(Common, HTTP) { resume(function() { assertEqual( "CommonJS module", Common.name ) assertEqual( "CommonJS HTTP lib", HTTP.name ) @@ -106,7 +106,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { }}) it("loads the object", function() { with(this) { - JS.require("Standalone") + PKG.require("Standalone") clock.tick(500) assertKindOf( Object, Standalone ) assertEqual( "Standalone", Standalone.name ) @@ -115,11 +115,11 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { it("loads the object once and runs every waiting block", function() { with(this) { var done1 = false, done2 = false, doneAsync = false - JS.require("Standalone", function() { done1 = true }) - JS.require("Standalone", function() { done2 = true }) + PKG.require("Standalone", function() { done1 = true }) + PKG.require("Standalone", function() { done2 = true }) JS.ENV.setTimeout(function() { - JS.require("Standalone", function() { doneAsync = true }) + PKG.require("Standalone", function() { doneAsync = true }) }, 300) assertEqual( "undefined", typeof Standalone ) @@ -143,7 +143,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { }}) it("loads the object", function() { with(this) { - JS.require("Object.In.A.Namespace") + PKG.require("Object.In.A.Namespace") clock.tick(100) assertKindOf( Object, Object.In.A.Namespace ) }}) @@ -162,7 +162,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { var bothLoaded = false - JS.require("Bar", "Foo", function() { + PKG.require("Bar", "Foo", function() { bothLoaded = (typeof Foo === "object") && (typeof Foo === "object") }) @@ -183,7 +183,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { it("loads the packages in order when one is required", function() { with(this) { var done = false - JS.require("Dependent", function() { done = true }) + PKG.require("Dependent", function() { done = true }) assertEqual( "undefined", typeof Base ) assertEqual( "undefined", typeof Dependent ) @@ -218,13 +218,13 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { describe("when the dependency is already defined", function() { with(this) { before(function() { with(this) { - JS.Package.ENV.Base = {} + PKG.ENV.Base = {} assertEqual( "undefined", typeof Dependent ) }}) it("just loads the dependent object", function() { with(this) { var done = false - JS.require("Dependent", function() { done = true }) + PKG.require("Dependent", function() { done = true }) clock.tick(50) @@ -242,13 +242,13 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { describe("when the required object is already defined", function() { with(this) { before(function() { with(this) { - JS.Package.ENV.Dependent = {} + PKG.ENV.Dependent = {} assertEqual( "undefined", typeof Base ) }}) it("loads the dependency and waits", function() { with(this) { var done = false - JS.require("Dependent", function() { done = true }) + PKG.require("Dependent", function() { done = true }) clock.tick(50) @@ -281,7 +281,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { it("loads all the objects, parallelizing where possible", function() { with(this) { var done = false - JS.require("TreeSet", function() { done = true }) + PKG.require("TreeSet", function() { done = true }) clock.tick(50) @@ -327,7 +327,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { it("loads the packages in parallel but waits until both are loaded", function() { with(this) { var done = false - JS.require("Application", function() { done = true }) + PKG.require("Application", function() { done = true }) assertEqual( "undefined", typeof Helper ) assertEqual( "undefined", typeof Application ) @@ -356,13 +356,13 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { describe("when the required object is defined but the dependency is missing", function() { with(this) { before(function() { with(this) { - JS.Package.ENV.Application = {} + PKG.ENV.Application = {} assertEqual( "undefined", typeof Helper ) }}) it("loads the dependency and waits", function() { with(this) { var done = false - JS.require("Application", function() { done = true }) + PKG.require("Application", function() { done = true }) clock.tick(250) @@ -380,13 +380,13 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { describe("when the dependency is defined but the required is not", function() { with(this) { before(function() { with(this) { - JS.Package.ENV.Helper = {} + PKG.ENV.Helper = {} assertEqual( "undefined", typeof Application ) }}) it("loads the required object and waits", function() { with(this) { var done = false - JS.require("Application", function() { done = true }) + PKG.require("Application", function() { done = true }) clock.tick(50) @@ -407,7 +407,7 @@ JS.ENV.PackageSpec = JS.Test.describe(JS.Package, function() { with(this) { it("runs the block immediately without loading anything", function() { with(this) { var done = false assertKindOf( Object, JS.Test ) - JS.require("JS.Test", function() { done = true }) + PKG.require("JS.Test", function() { done = true }) assert( done ) assertEqual( [], _loaded ) }}) diff --git a/test/specs/proxy_spec.js b/test/specs/proxy_spec.js index ecc64006..6de22db2 100644 --- a/test/specs/proxy_spec.js +++ b/test/specs/proxy_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Proxy', function(Proxy) { +PKG.require('JS.Proxy', function(Proxy) { JS.ENV.ProxySpec = JS.Test.describe(Proxy, function() { with(this) { describe(Proxy.Virtual, function() { with(this) { diff --git a/test/specs/range_spec.js b/test/specs/range_spec.js index e0b38aec..7bd0008b 100644 --- a/test/specs/range_spec.js +++ b/test/specs/range_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Range', function(Range) { +PKG.require('JS.Range', function(Range) { JS.ENV.RangeSpec = JS.Test.describe(Range, function() { with(this) { include(JS.Test.Helpers) diff --git a/test/specs/set_spec.js b/test/specs/set_spec.js index cdfc990a..a0f3210a 100644 --- a/test/specs/set_spec.js +++ b/test/specs/set_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Set', 'JS.OrderedSet', 'JS.SortedSet', 'JS.Hash', +PKG.require('JS.Set', 'JS.OrderedSet', 'JS.SortedSet', 'JS.Hash', function(Set, OrderedSet, SortedSet, Hash) { var sets = { diff --git a/test/specs/state_spec.js b/test/specs/state_spec.js index 74927691..3b967875 100644 --- a/test/specs/state_spec.js +++ b/test/specs/state_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.State', function(State) { +PKG.require('JS.State', function(State) { JS.ENV.StateSpec = JS.Test.describe(State, function() { with(this) { define("Positive", { diff --git a/test/specs/test/context_spec.js b/test/specs/test/context_spec.js index a286b869..fd13394d 100644 --- a/test/specs/test/context_spec.js +++ b/test/specs/test/context_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Enumerable', function(Enumerable) { +PKG.require('JS.Enumerable', function(Enumerable) { JS.ENV.Test = JS.ENV.Test || {} diff --git a/test/specs/test/mocking_spec.js b/test/specs/test/mocking_spec.js index af40a51a..ffc061dd 100644 --- a/test/specs/test/mocking_spec.js +++ b/test/specs/test/mocking_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Enumerable', 'JS.Comparable', 'JS.Hash', 'JS.Set', 'JS.SortedSet', +PKG.require('JS.Enumerable', 'JS.Comparable', 'JS.Hash', 'JS.Set', 'JS.SortedSet', function(Enumerable, Comparable, Hash, Set, SortedSet) { JS.ENV.Test = JS.ENV.Test || {} diff --git a/test/specs/test/unit_spec.js b/test/specs/test/unit_spec.js index 63db7f5c..a2d5e3b3 100644 --- a/test/specs/test/unit_spec.js +++ b/test/specs/test/unit_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.Enumerable', 'JS.Observable', 'JS.Range', 'JS.Set', 'JS.SortedSet', +PKG.require('JS.Enumerable', 'JS.Observable', 'JS.Range', 'JS.Set', 'JS.SortedSet', function(Enumerable, Observable, Range, Set, SortedSet) { JS.ENV.Test = JS.ENV.Test || {} diff --git a/test/specs/tsort_spec.js b/test/specs/tsort_spec.js index 6486ac82..d0631e46 100644 --- a/test/specs/tsort_spec.js +++ b/test/specs/tsort_spec.js @@ -1,4 +1,4 @@ -JS.require('JS.TSort', 'JS.Hash', function(TSort, Hash) { +PKG.require('JS.TSort', 'JS.Hash', function(TSort, Hash) { JS.ENV.TSortSpec = JS.Test.describe(TSort, function() { with(this) { before(function() { with(this) {