spade 0.1.0 → 0.1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +0 -11
- data/.gitmodules +3 -6
- data/Gemfile +10 -0
- data/bin/spade +3 -1
- data/lib/spade.rb +70 -0
- data/lib/spade/bundle.rb +180 -0
- data/lib/spade/cli.rb +1 -17
- data/lib/spade/cli/base.rb +182 -0
- data/lib/spade/console.rb +39 -0
- data/lib/spade/context.rb +107 -0
- data/lib/spade/evaluator.rb +34 -0
- data/lib/spade/exports.rb +70 -0
- data/lib/spade/loader.rb +208 -0
- data/lib/spade/package/.gitignore +1 -0
- data/lib/spade/package/Gemfile +15 -0
- data/lib/spade/package/lib/spade.js +1283 -0
- data/lib/spade/package/lib/wrapper.js +15 -0
- data/lib/spade/package/package.json +17 -0
- data/lib/spade/package/spec/javascript/async-test.js +123 -0
- data/lib/spade/package/spec/javascript/compiler/javascript.js +13 -0
- data/lib/spade/package/spec/javascript/compiler/ruby.js +14 -0
- data/lib/spade/package/spec/javascript/loader-test.js +64 -0
- data/lib/spade/package/spec/javascript/normalize-test.js +73 -0
- data/lib/spade/package/spec/javascript/packages-test.js +50 -0
- data/lib/spade/package/spec/javascript/relative-require-test.js +72 -0
- data/lib/spade/package/spec/javascript/require-test.js +117 -0
- data/lib/spade/package/spec/javascript/sandbox/creation.js +44 -0
- data/lib/spade/package/spec/javascript/sandbox/evaluate.js +37 -0
- data/lib/spade/package/spec/javascript/sandbox/format.js +79 -0
- data/lib/spade/package/spec/javascript/sandbox/misc.js +58 -0
- data/lib/spade/package/spec/javascript/sandbox/preprocessor.js +81 -0
- data/lib/spade/package/spec/javascript/sandbox/require.js +48 -0
- data/lib/spade/package/spec/javascript/sandbox/run-command.js +21 -0
- data/lib/spade/package/spec/javascript/spade/externs.js +14 -0
- data/lib/spade/package/spec/javascript/spade/load-factory.js +15 -0
- data/lib/spade/package/spec/javascript/spade/misc.js +23 -0
- data/lib/spade/package/spec/javascript/spade/ready.js +12 -0
- data/lib/spade/package/spec/javascript/spade/register.js +13 -0
- data/lib/spade/package/spec/javascript_spec.rb +7 -0
- data/lib/spade/package/spec/spec_helper.rb +3 -0
- data/lib/spade/package/spec/support/core_test.rb +67 -0
- data/lib/spade/reactor.rb +159 -0
- data/lib/spade/server.rb +66 -0
- data/lib/spade/shell.rb +85 -0
- data/lib/spade/version.rb +1 -1
- data/spade.gemspec +15 -4
- data/spec/cli/update_spec.rb +65 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/support/cli.rb +103 -0
- data/spec/support/matchers.rb +12 -0
- data/spec/support/path.rb +66 -0
- metadata +146 -78
- data/.rspec +0 -1
- data/Buildfile +0 -18
- data/README.md +0 -152
- data/Rakefile +0 -9
- data/examples/format-app/lib/hello.coffee +0 -1
- data/examples/format-app/lib/main.js +0 -6
- data/examples/format-app/package.json +0 -10
- data/examples/format-app/resources/README.txt +0 -1
- data/examples/format-app/resources/config.json +0 -3
- data/examples/path-test/lib/hello.js +0 -1
- data/examples/path-test/lib/main.js +0 -1
- data/examples/path-test/package.json +0 -5
- data/examples/sc-app/index.html +0 -13
- data/examples/sc-app/lib/main.js +0 -24
- data/examples/sc-app/package.json +0 -8
- data/examples/single-file.js +0 -22
- data/examples/todos/index.html +0 -11
- data/examples/todos/lib/main.js +0 -11
- data/examples/todos/lib/todos.js +0 -93
- data/examples/todos/package.json +0 -10
- data/examples/todos/resources/stylesheets/todos.css +0 -162
- data/examples/todos/resources/templates/todos.handlebars +0 -31
- data/examples/web-app/README.md +0 -83
- data/examples/web-app/index.html +0 -12
- data/examples/web-app/lib/main.js +0 -3
- data/examples/web-app/package.json +0 -6
- data/examples/web-app/tests.html +0 -12
- data/examples/web-app/tests/ct-example-test.js +0 -39
- data/examples/web-app/tests/qunit-test.js +0 -23
@@ -0,0 +1,117 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2010 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade;
|
9
|
+
|
10
|
+
// ..........................................................
|
11
|
+
// BASIC REQUIRE
|
12
|
+
//
|
13
|
+
|
14
|
+
Ct.module('spade: basic require');
|
15
|
+
|
16
|
+
Ct.setup(function(t) {
|
17
|
+
t.spade = new Spade();
|
18
|
+
});
|
19
|
+
|
20
|
+
Ct.teardown(function(t) {
|
21
|
+
delete t.spade;
|
22
|
+
});
|
23
|
+
|
24
|
+
|
25
|
+
Ct.test('register then require a module', function(t) {
|
26
|
+
var spade = t.spade;
|
27
|
+
|
28
|
+
spade.register('foo/bar', function(require, exports) {
|
29
|
+
exports.foo = 'bar';
|
30
|
+
});
|
31
|
+
|
32
|
+
var exp = spade.require('foo/bar');
|
33
|
+
t.equal(exp.foo, 'bar', 'exports.foo == bar - means require succeeded');
|
34
|
+
});
|
35
|
+
|
36
|
+
Ct.test('register a string factory then require', function(t) {
|
37
|
+
var spade = t.spade;
|
38
|
+
|
39
|
+
spade.register('foo/bar', "exports.foo = 'bar';");
|
40
|
+
|
41
|
+
var exp = spade.require('foo/bar');
|
42
|
+
t.equal(exp.foo, 'bar', 'exports.foo == bar - means require succeeded');
|
43
|
+
});
|
44
|
+
|
45
|
+
Ct.test('require a non-existant module will throw an exception', function(t) {
|
46
|
+
var spade = t.spade;
|
47
|
+
t.throws(function() {
|
48
|
+
spade.require('imaginary/foo');
|
49
|
+
}, 'Module imaginary/foo not found');
|
50
|
+
});
|
51
|
+
|
52
|
+
Ct.test('require a module that was just registered symbolically. This is for compatibility with non-module items', function(t) {
|
53
|
+
var spade = t.spade;
|
54
|
+
spade.register('not/a-module');
|
55
|
+
t.ok(spade.require('not/a-module'));
|
56
|
+
});
|
57
|
+
|
58
|
+
Ct.test('require system installed packages');
|
59
|
+
|
60
|
+
|
61
|
+
// ..........................................................
|
62
|
+
// BASIC REQUIRE
|
63
|
+
//
|
64
|
+
|
65
|
+
Ct.module('spade: extension require');
|
66
|
+
|
67
|
+
Ct.setup(function(t) {
|
68
|
+
t.spade = new Spade();
|
69
|
+
|
70
|
+
t.spade.register('foo', {
|
71
|
+
'plugin:formats': {
|
72
|
+
'css': 'foo/format',
|
73
|
+
'txt': 'foo/format'
|
74
|
+
}
|
75
|
+
});
|
76
|
+
t.spade.register('foo/format', "exports.compileFormat = function(code){ return code; };");
|
77
|
+
t.spade.register('foo/bar', "exports.foo = 'bar.js';", { format: 'js' });
|
78
|
+
t.spade.register('foo/bar', "exports.foo = 'bar.css';", { format: 'css' });
|
79
|
+
});
|
80
|
+
|
81
|
+
Ct.teardown(function(t) {
|
82
|
+
delete t.spade;
|
83
|
+
});
|
84
|
+
|
85
|
+
|
86
|
+
Ct.test('valid extension', function(t) {
|
87
|
+
var exp = t.spade.require('foo/bar.js');
|
88
|
+
t.equal(exp.foo, 'bar.js', 'exports.foo == bar.js - means require succeeded');
|
89
|
+
});
|
90
|
+
|
91
|
+
Ct.test('same name different extensions', function(t){
|
92
|
+
var spade = t.spade,
|
93
|
+
jsExp = spade.require('foo/bar.js'),
|
94
|
+
cssExp = spade.require('foo/bar.css');
|
95
|
+
|
96
|
+
t.equal(jsExp.foo, 'bar.js', 'exports.foo == bar.js - means require succeeded');
|
97
|
+
t.equal(cssExp.foo, 'bar.css', 'exports.foo == bar.css - means require succeeded');
|
98
|
+
});
|
99
|
+
|
100
|
+
Ct.test("don't load file for different extension", function(t){
|
101
|
+
t.throws(function(){ t.spade.require('foo/bar.txt'); }, Error, 'adfaff');
|
102
|
+
});
|
103
|
+
|
104
|
+
Ct.test("defaults to js", function(t){
|
105
|
+
var exp = t.spade.require('foo/bar');
|
106
|
+
t.equal(exp.foo, 'bar.js', 'exports.foo == bar.js - means required js as default');
|
107
|
+
});
|
108
|
+
|
109
|
+
Ct.test("defaults to first registered if no js", function(t){
|
110
|
+
var spade = t.spade;
|
111
|
+
|
112
|
+
spade.register('foo/baz', "exports.foo = 'baz.css';", { format: 'css' });
|
113
|
+
spade.register('foo/baz', "exports.foo = 'baz.txt';", { format: 'txt' });
|
114
|
+
|
115
|
+
var exp = spade.require('foo/baz');
|
116
|
+
t.equal(exp.foo, 'baz.css', 'exports.foo == baz.css - means required last registered');
|
117
|
+
});
|
@@ -0,0 +1,44 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2011 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade,
|
9
|
+
Sandbox = require('spade').Sandbox;
|
10
|
+
|
11
|
+
|
12
|
+
Ct.module('spade: Sandbox Creation');
|
13
|
+
|
14
|
+
Ct.setup(function(t) {
|
15
|
+
t.spade = new Spade();
|
16
|
+
});
|
17
|
+
|
18
|
+
Ct.teardown(function(t) {
|
19
|
+
delete t.spade;
|
20
|
+
});
|
21
|
+
|
22
|
+
Ct.test('basic sandbox', function(t) {
|
23
|
+
var spade = t.spade,
|
24
|
+
sandbox = new Sandbox(spade);
|
25
|
+
|
26
|
+
t.equal(sandbox.spade, spade);
|
27
|
+
t.equal(sandbox.name, '(anonymous)');
|
28
|
+
t.equal(sandbox.isIsolated, false);
|
29
|
+
});
|
30
|
+
|
31
|
+
Ct.test('named sandbox', function(t) {
|
32
|
+
var sandbox = new Sandbox(t.spade, 'Test Sandbox');
|
33
|
+
|
34
|
+
t.equal(sandbox.name, 'Test Sandbox');
|
35
|
+
});
|
36
|
+
|
37
|
+
Ct.test('isolated sandbox', function(t) {
|
38
|
+
var sandbox = new Sandbox(t.spade, 'Test Sandbox', true),
|
39
|
+
sandbox2 = new Sandbox(t.spade, true);
|
40
|
+
|
41
|
+
t.equal(sandbox.isIsolated, true);
|
42
|
+
t.equal(sandbox2.isIsolated, true);
|
43
|
+
});
|
44
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2011 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade,
|
9
|
+
Sandbox = require('spade').Sandbox;
|
10
|
+
|
11
|
+
Ct.module('spade: Sandbox evaluation');
|
12
|
+
|
13
|
+
Ct.setup(function(t) {
|
14
|
+
t.sandbox = new Sandbox(new Spade());
|
15
|
+
});
|
16
|
+
|
17
|
+
Ct.teardown(function(t) {
|
18
|
+
delete t.sandbox;
|
19
|
+
});
|
20
|
+
|
21
|
+
Ct.test('normal', function(t){
|
22
|
+
t.equal(t.sandbox._evaluatorInited, undefined);
|
23
|
+
t.equal(t.sandbox.evaluate('2 * 2'), 4);
|
24
|
+
t.equal(t.sandbox._evaluatorInited, true);
|
25
|
+
});
|
26
|
+
|
27
|
+
Ct.test('already initialized', function(t){
|
28
|
+
// Initialize
|
29
|
+
t.sandbox.evaluate('');
|
30
|
+
// Test
|
31
|
+
t.equal(t.sandbox.evaluate('3 * 3'), 9);
|
32
|
+
});
|
33
|
+
|
34
|
+
Ct.test('destroyed', function(t){
|
35
|
+
t.sandbox.destroy();
|
36
|
+
t.throws(function(){ t.sandbox.evaluate('4 * 4'); }, Error, "Sandbox destroyed");
|
37
|
+
});
|
@@ -0,0 +1,79 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2011 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade,
|
9
|
+
Sandbox = require('spade').Sandbox;
|
10
|
+
|
11
|
+
Ct.module('spade: Sandbox format compilation');
|
12
|
+
|
13
|
+
Ct.setup(function(t) {
|
14
|
+
t.sandbox = new Sandbox(new Spade());
|
15
|
+
|
16
|
+
t.sandbox.spade.register('text', {
|
17
|
+
'name': 'text',
|
18
|
+
'plugin:formats': {
|
19
|
+
'txt': 'text/format'
|
20
|
+
}
|
21
|
+
});
|
22
|
+
t.sandbox.spade.register('text/format',
|
23
|
+
"exports.compileFormat = function(code, _, filename){ "+
|
24
|
+
"return '// From '+filename+'\\nreturn \"'+code+'\";'; "+
|
25
|
+
"};");
|
26
|
+
});
|
27
|
+
|
28
|
+
Ct.teardown(function(t) {
|
29
|
+
delete t.sandbox;
|
30
|
+
});
|
31
|
+
|
32
|
+
Ct.test('normal', function(t){
|
33
|
+
var sandbox = t.sandbox,
|
34
|
+
pkg = sandbox.spade.package('text');
|
35
|
+
|
36
|
+
t.equal(sandbox.compileFormat('Testing', 'test_file.txt', 'txt', pkg), '// From test_file.txt\nreturn "Testing";');
|
37
|
+
});
|
38
|
+
|
39
|
+
Ct.test("checks dependencies", function(t){
|
40
|
+
t.sandbox.spade.register('test', {
|
41
|
+
'name': 'test',
|
42
|
+
'dependencies': { 'text': '1.0' }
|
43
|
+
});
|
44
|
+
|
45
|
+
var pkg = t.sandbox.spade.package('test');
|
46
|
+
|
47
|
+
t.equal(t.sandbox.compileFormat('Testing', 'test_file.txt', 'txt', pkg), '// From test_file.txt\nreturn "Testing";');
|
48
|
+
});
|
49
|
+
|
50
|
+
Ct.test("only checks immediate dependencies", function(t){
|
51
|
+
t.sandbox.spade.register('intermediate', {
|
52
|
+
'name': 'intermediate',
|
53
|
+
'dependencies': { 'text': '1.0' }
|
54
|
+
});
|
55
|
+
t.sandbox.spade.register('test', {
|
56
|
+
'name': 'test',
|
57
|
+
'dependencies': { 'intermediate': '1.0' }
|
58
|
+
});
|
59
|
+
|
60
|
+
var pkg = t.sandbox.spade.package('test');
|
61
|
+
|
62
|
+
t.equal(t.sandbox.compileFormat('Testing', 'test_file.txt', 'txt', pkg), 'Testing');
|
63
|
+
});
|
64
|
+
|
65
|
+
Ct.test("self takes priority", function(t){
|
66
|
+
t.sandbox.spade.register('test', {
|
67
|
+
'name': 'test',
|
68
|
+
'dependencies': { 'text': '1.0' },
|
69
|
+
'plugin:formats': { 'txt': 'test/text-format' }
|
70
|
+
});
|
71
|
+
t.sandbox.spade.register('test/text-format',
|
72
|
+
"exports.compileFormat = function(code){ "+
|
73
|
+
"return '// Test Formatter\\nreturn \"'+code+'\";'; "+
|
74
|
+
"};");
|
75
|
+
|
76
|
+
var pkg = t.sandbox.spade.package('test');
|
77
|
+
|
78
|
+
t.equal(t.sandbox.compileFormat('Testing', 'test_file.txt', 'txt', pkg), '// Test Formatter\nreturn "Testing";');
|
79
|
+
});
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2011 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade,
|
9
|
+
Sandbox = require('spade').Sandbox;
|
10
|
+
|
11
|
+
Ct.module('spade: Sandbox Miscellaneous');
|
12
|
+
|
13
|
+
Ct.setup(function(t){
|
14
|
+
t.sandbox = new Sandbox(new Spade(), 'Test Sandbox');
|
15
|
+
});
|
16
|
+
|
17
|
+
Ct.teardown(function(t){
|
18
|
+
delete t.sandbox;
|
19
|
+
});
|
20
|
+
|
21
|
+
Ct.test('toString', function(t){
|
22
|
+
t.equal(t.sandbox.toString(), '[Sandbox Test Sandbox]');
|
23
|
+
});
|
24
|
+
|
25
|
+
Ct.test("exists", function(t){
|
26
|
+
t.sandbox.spade.register('test', { name: 'test' });
|
27
|
+
t.sandbox.spade.register('test/main', '');
|
28
|
+
|
29
|
+
t.ok(t.sandbox.exists('test'), "test should exist");
|
30
|
+
t.ok(!t.sandbox.exists('missing'), "missing should not exist");
|
31
|
+
});
|
32
|
+
|
33
|
+
Ct.test("async", function(t){
|
34
|
+
t.sandbox.spade.register('test', { name: 'test' });
|
35
|
+
t.sandbox.spade.register('test/main', 'exports.hello = "hi";');
|
36
|
+
|
37
|
+
t.deepEqual(t.sandbox.async('test'), {
|
38
|
+
"data": "exports.hello = \"hi\";",
|
39
|
+
"filename": "test/main",
|
40
|
+
"format": "js",
|
41
|
+
"skipPreprocess": false
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
Ct.test("url", function(t){
|
46
|
+
t.sandbox.spade.register('no-root', { name: 'no-root' });
|
47
|
+
t.sandbox.spade.register('with-root', { name: 'with-root', root: 'root/url' });
|
48
|
+
|
49
|
+
t.throws(function(){ t.sandbox.url('missing') }, "Can't get url for non-existent package missing/main");
|
50
|
+
t.throws(function(){ t.sandbox.url('no-root') }, "Package for no-root/main does not support urls");
|
51
|
+
t.equal(t.sandbox.url('with-root'), 'root/url/main');
|
52
|
+
});
|
53
|
+
|
54
|
+
Ct.test("destroy", function(t){
|
55
|
+
t.equal(t.sandbox.isDestroyed, false);
|
56
|
+
t.sandbox.destroy();
|
57
|
+
t.equal(t.sandbox.isDestroyed, true);
|
58
|
+
});
|
@@ -0,0 +1,81 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2011 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade,
|
9
|
+
Sandbox = require('spade').Sandbox;
|
10
|
+
|
11
|
+
Ct.module('spade: Sandbox preprocessor compilation');
|
12
|
+
|
13
|
+
Ct.setup(function(t) {
|
14
|
+
t.sandbox = new Sandbox(new Spade());
|
15
|
+
|
16
|
+
t.sandbox.spade.register('commenter', {
|
17
|
+
'name': 'commenter',
|
18
|
+
'plugin:preprocessors': ['commenter/preprocessor']
|
19
|
+
});
|
20
|
+
t.sandbox.spade.register('commenter/preprocessor',
|
21
|
+
"exports.compilePreprocessor = function(code, _, filename){ "+
|
22
|
+
"return '// From '+filename+'\\n'+code; "+
|
23
|
+
"};");
|
24
|
+
});
|
25
|
+
|
26
|
+
Ct.teardown(function(t) {
|
27
|
+
delete t.sandbox;
|
28
|
+
});
|
29
|
+
|
30
|
+
Ct.test('normal', function(t){
|
31
|
+
var pkg = t.sandbox.spade.package('commenter');
|
32
|
+
|
33
|
+
t.equal(t.sandbox.compilePreprocessors('var hello = "hi";', 'test_file.js', pkg), '// From test_file.js\nvar hello = "hi";');
|
34
|
+
});
|
35
|
+
|
36
|
+
Ct.test('multiple', function(t){
|
37
|
+
t.sandbox.spade.register('functionizer', {
|
38
|
+
'name': 'functionizer',
|
39
|
+
'dependencies': { 'commenter': '1.0' },
|
40
|
+
'plugin:preprocessors': ['functionizer/preprocessor', 'commenter/preprocessor']
|
41
|
+
});
|
42
|
+
t.sandbox.spade.register('functionizer/preprocessor',
|
43
|
+
"exports.compilePreprocessor = function(code){ "+
|
44
|
+
"return 'function(){ '+code+' };'; "+
|
45
|
+
"};");
|
46
|
+
|
47
|
+
var pkg = t.sandbox.spade.package('functionizer');
|
48
|
+
|
49
|
+
t.equal(t.sandbox.compilePreprocessors('var hello = "hi";', 'test_file.js', pkg), '// From test_file.js\nfunction(){ var hello = "hi"; };');
|
50
|
+
});
|
51
|
+
|
52
|
+
Ct.test("checks dependencies", function(t){
|
53
|
+
t.sandbox.spade.register('test', {
|
54
|
+
'name': 'test',
|
55
|
+
'dependencies': { 'commenter': '1.0' }
|
56
|
+
});
|
57
|
+
|
58
|
+
var pkg = t.sandbox.spade.package('test');
|
59
|
+
|
60
|
+
t.equal(t.sandbox.compilePreprocessors('var hello = "hi";', 'test_file.js', pkg), '// From test_file.js\nvar hello = "hi";');
|
61
|
+
});
|
62
|
+
|
63
|
+
Ct.test("only checks immediate dependencies", function(t){
|
64
|
+
t.sandbox.spade.register('intermediate', {
|
65
|
+
'name': 'intermediate',
|
66
|
+
'dependencies': { 'commenter': '1.0' }
|
67
|
+
});
|
68
|
+
t.sandbox.spade.register('test', {
|
69
|
+
'name': 'test',
|
70
|
+
'dependencies': { 'intermediate': '1.0' }
|
71
|
+
});
|
72
|
+
|
73
|
+
var pkg = t.sandbox.spade.package('test');
|
74
|
+
|
75
|
+
t.equal(t.sandbox.compilePreprocessors('var hello = "hi";', 'test_file.js', pkg), 'var hello = "hi";');
|
76
|
+
});
|
77
|
+
|
78
|
+
Ct.test("handles preprocessor loop");
|
79
|
+
|
80
|
+
Ct.test("proper order?");
|
81
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// ==========================================================================
|
2
|
+
// Project: Spade - CommonJS Runtime
|
3
|
+
// Copyright: ©2011 Strobe Inc. All rights reserved.
|
4
|
+
// License: Licened under MIT license (see __preamble__.js)
|
5
|
+
// ==========================================================================
|
6
|
+
|
7
|
+
var Ct = require('core-test/sync'),
|
8
|
+
Spade = require('spade').Spade,
|
9
|
+
Sandbox = require('spade').Sandbox;
|
10
|
+
|
11
|
+
Ct.module('spade: Sandbox require');
|
12
|
+
|
13
|
+
Ct.setup(function(t) {
|
14
|
+
t.sandbox = new Sandbox(new Spade());
|
15
|
+
t.sandbox.spade.register('testing', { name: 'testing' });
|
16
|
+
t.sandbox.spade.register('testing/main', "exports.hello = 'hi';");
|
17
|
+
});
|
18
|
+
|
19
|
+
Ct.teardown(function(t) {
|
20
|
+
delete t.sandbox;
|
21
|
+
});
|
22
|
+
|
23
|
+
Ct.test("require new", function(t){
|
24
|
+
t.equal(t.sandbox.require('testing').hello, 'hi');
|
25
|
+
});
|
26
|
+
|
27
|
+
// NOTE: This test doesn't necessarily tell us that anything special is happening, just that it works
|
28
|
+
Ct.test("require existing", function(t){
|
29
|
+
// Cache it
|
30
|
+
t.sandbox.require('testing');
|
31
|
+
// Now require again
|
32
|
+
t.equal(t.sandbox.require('testing').hello, 'hi');
|
33
|
+
});
|
34
|
+
|
35
|
+
// TODO: I'm not actually sure how this should work - PW
|
36
|
+
Ct.test("require circular");
|
37
|
+
/*
|
38
|
+
Ct.test("require circular", function(t){
|
39
|
+
t.sandbox.spade.register('testing/file1', "exports.value = require('testing/file2').value * 2;");
|
40
|
+
t.sandbox.spade.register('testing/file2', "exports.value = require('testing/file1').value * 2;");
|
41
|
+
t.equal(t.sandbox.require('testing/file1').value, 4);
|
42
|
+
});
|
43
|
+
*/
|
44
|
+
|
45
|
+
Ct.test("throw if doesn't exist", function(t){
|
46
|
+
t.throws(function(){ t.sandbox.require('missing'); }, "Module missing not found");
|
47
|
+
});
|
48
|
+
|