Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change dependency-resolving code so that modules work sensibly when c…

…oncatenated with jsbuild.
  • Loading branch information...
commit d41c91362c9f9c51c3a2a76cbe4a619640bb59d0 1 parent 5c2be15
James Coglan authored
Showing with 131 additions and 115 deletions.
  1. +2 −0  bin/jsbuild
  2. +5 −1 index.js
  3. +3 −2 source/benchmark.js
  4. +3 −3 source/command.js
  5. +1 −1  source/comparable.js
  6. +2 −2 source/console/_head.js
  7. +1 −1  source/constant_scope.js
  8. +6 −5 source/core/_head.js
  9. +3 −2 source/core/method.js
  10. +1 −1  source/decorator.js
  11. +1 −1  source/deferrable.js
  12. +1 −1  source/dom/_head.js
  13. +1 −1  source/enumerable.js
  14. +1 −1  source/forwardable.js
  15. +3 −3 source/hash.js
  16. +3 −2 source/linked_list.js
  17. +1 −1  source/method_chain.js
  18. +1 −1  source/observable.js
  19. +5 −2 source/package/_head.js
  20. +2 −2 source/package/config.js
  21. +1 −1  source/proxy.js
  22. +3 −3 source/range.js
  23. +3 −3 source/set.js
  24. +4 −4 source/stack_trace.js
  25. +1 −1  source/state.js
  26. +9 −9 source/test/_head.js
  27. +3 −2 source/tsort.js
  28. +1 −1  test/console.js
  29. +1 −1  test/examples/async.js
  30. +1 −1  test/examples/benchmarks.js
  31. +1 −1  test/examples/reformat.js
  32. +1 −1  test/examples/tracing.js
  33. +2 −2 test/phantom.js
  34. +10 −8 test/runner.js
  35. +1 −1  test/specs/command_spec.js
  36. +1 −1  test/specs/comparable_spec.js
  37. +1 −1  test/specs/console_spec.js
  38. +1 −1  test/specs/constant_scope_spec.js
  39. +1 −1  test/specs/decorator_spec.js
  40. +1 −1  test/specs/deferrable_spec.js
  41. +1 −1  test/specs/enumerable_spec.js
  42. +1 −1  test/specs/forwardable_spec.js
  43. +1 −1  test/specs/hash_spec.js
  44. +1 −1  test/specs/linked_list_spec.js
  45. +1 −1  test/specs/method_chain_spec.js
  46. +1 −1  test/specs/observable_spec.js
  47. +24 −24 test/specs/package_spec.js
  48. +1 −1  test/specs/proxy_spec.js
  49. +1 −1  test/specs/range_spec.js
  50. +1 −1  test/specs/set_spec.js
  51. +1 −1  test/specs/state_spec.js
  52. +1 −1  test/specs/test/context_spec.js
  53. +1 −1  test/specs/test/mocking_spec.js
  54. +1 −1  test/specs/test/unit_spec.js
  55. +1 −1  test/specs/tsort_spec.js
2  bin/jsbuild
View
@@ -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')
6 index.js
View
@@ -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;
+
5 source/benchmark.js
View
@@ -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);
6 source/command.js
View
@@ -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);
2  source/comparable.js
View
@@ -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);
4 source/console/_head.js
View
@@ -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);
2  source/constant_scope.js
View
@@ -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);
11 source/core/_head.js
View
@@ -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) {
5 source/core/method.js
View
@@ -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;
2  source/decorator.js
View
@@ -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);
2  source/deferrable.js
View
@@ -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);
2  source/dom/_head.js
View
@@ -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);
2  source/enumerable.js
View
@@ -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);
2  source/forwardable.js
View
@@ -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);
6 source/hash.js
View
@@ -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);
5 source/linked_list.js
View
@@ -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);
2  source/method_chain.js
View
@@ -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);
2  source/observable.js
View
@@ -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);
7 source/package/_head.js
View
@@ -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) {
4 source/package/config.js
View
@@ -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',
2  source/proxy.js
View
@@ -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);
6 source/range.js
View
@@ -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);
6 source/set.js
View
@@ -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);
8 source/stack_trace.js
View
@@ -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);
2  source/state.js
View
@@ -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);
18 source/test/_head.js
View
@@ -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);
5 source/tsort.js
View
@@ -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);
2  test/console.js
View
@@ -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');
2  test/examples/async.js
View
@@ -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) {
2  test/examples/benchmarks.js
View
@@ -4,7 +4,7 @@
})()
if (typeof require === 'function')
- require('../../' + JSCLASS_PATH + 'loader')
+ var JS = require('../../' + JSCLASS_PATH + 'loader')
else
load(JSCLASS_PATH + 'loader.js')
2  test/examples/reformat.js
View
@@ -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}),
2  test/examples/tracing.js
View
@@ -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')
}
4 test/phantom.js
View
@@ -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)
18 test/runner.js
View
@@ -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)
})
2  test/specs/command_spec.js
View
@@ -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 })
2  test/specs/comparable_spec.js
View
@@ -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)
2  test/specs/console_spec.js
View
@@ -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) {
2  test/specs/constant_scope_spec.js
View
@@ -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)
2  test/specs/decorator_spec.js
View
@@ -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({
2  test/specs/deferrable_spec.js
View
@@ -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)
2  test/specs/enumerable_spec.js
View
@@ -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) {
2  test/specs/forwardable_spec.js
View
@@ -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({
2  test/specs/hash_spec.js
View
@@ -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)
2  test/specs/linked_list_spec.js
View
@@ -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) {
2  test/specs/method_chain_spec.js
View
@@ -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)
2  test/specs/observable_spec.js
View
@@ -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) {
48 test/specs/package_spec.js
View
@@ -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 )
}})
2  test/specs/proxy_spec.js
View
@@ -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) {
2  test/specs/range_spec.js
View
@@ -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)
2  test/specs/set_spec.js
View
@@ -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 = {
2  test/specs/state_spec.js
View
@@ -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", {
2  test/specs/test/context_spec.js
View
@@ -1,4 +1,4 @@
-JS.require('JS.Enumerable', function(Enumerable) {
+PKG.require('JS.Enumerable', function(Enumerable) {
JS.ENV.Test = JS.ENV.Test || {}
2  test/specs/test/mocking_spec.js
View
@@ -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 || {}
2  test/specs/test/unit_spec.js
View
@@ -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 || {}
2  test/specs/tsort_spec.js
View
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.