1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-09-04 20:08:02 +00:00

Revert "Merge pull request #160 from natecain/commonjs"

This reverts commit 661621c3f7, reversing
changes made to d3d72eff1b.
This commit is contained in:
Jeremy Ruston
2013-10-12 16:29:20 +01:00
parent 661621c3f7
commit 5ef4123b3d
34 changed files with 37 additions and 546 deletions

View File

@@ -1,7 +0,0 @@
title: GettingStarted
This wiki instance contains the CommonJS Modules/1.0 unit tests.
To run them, open a console repl and execute "$tw.modules.execute('allTests')" there. You should see no exceptions or output starting with "FAIL" in the console.

View File

@@ -1,11 +0,0 @@
/*\
title: absolute/b.js
type: application/javascript
module-type: library
Absolute require test
\*/
exports.foo = function() {};

View File

@@ -1,16 +0,0 @@
/*\
title: absolute/program.js
type: application/javascript
module-type: library
Absolute require test
\*/
var test = require('test');
var a = require('./submodule/a');
var b = require('./b');
test.assert(a.foo().foo === b.foo, 'require works with absolute identifiers');
test.print('DONE', 'info');

View File

@@ -1,14 +0,0 @@
/*\
title: absolute/submodule/a.js
type: application/javascript
module-type: library
Absolute require test
\*/
exports.foo = function () {
return require('../b');
};

View File

@@ -1,23 +0,0 @@
/*\
title: allTests.js
type: application/javascript
module-type: library
Runs all CommonJS Modules tests
\*/
$tw.modules.execute('absolute/program.js');
$tw.modules.execute('cyclic/program.js');
$tw.modules.execute('determinism/program.js');
$tw.modules.execute('exactExports/program.js');
$tw.modules.execute('hasOwnProperty/program.js');
$tw.modules.execute('method/program.js');
$tw.modules.execute('missing/program.js');
$tw.modules.execute('monkeys/program.js');
$tw.modules.execute('nested/program.js');
$tw.modules.execute('relative/program.js');
$tw.modules.execute('transitive/program.js');

View File

@@ -1,15 +0,0 @@
/*\
title: cyclic/a.js
type: application/javascript
module-type: library
Cycle require test A
\*/
exports.a = function () {
return b;
};
var b = require('./b');

View File

@@ -1,16 +0,0 @@
/*\
title: cyclic/b.js
type: application/javascript
module-type: library
Cycle require test B
\*/
var a = require('./a');
exports.b = function () {
return a;
};

View File

@@ -1,22 +0,0 @@
/*\
title: cyclic/program.js
type: application/javascript
module-type: library
Cycle require test
\*/
var test = require('test');
var a = require('./a');
var b = require('./b');
test.assert(a.a, 'a exists');
test.assert(b.b, 'b exists')
test.assert(a.a().b === b.b, 'a gets b');
test.assert(b.b().a === a.a, 'b gets a');
test.print('DONE', 'info');

View File

@@ -1,14 +0,0 @@
/*\
title: determinism/program.js
type: application/javascript
module-type: library
Determinism test
\*/
var test = require('test');
require('submodule/a');
test.print('DONE', 'info');

View File

@@ -1,20 +0,0 @@
/*\
title: determinism/submodule/a.js
type: application/javascript
module-type: library
Determinism require test A
\*/
var test = require('test');
var pass = false;
var test = require('test');
try {
require('a');
} catch (exception) {
pass = true;
}
test.assert(pass, 'require does not fall back to relative modules when absolutes are not available.')

View File

@@ -1,15 +0,0 @@
/*\
title: exactExports/a.js
type: application/javascript
module-type: library
ExactExports test A
\*/
exports.program = function () {
return require('./program');
};

View File

@@ -1,16 +0,0 @@
/*\
title: exactExports/program.js
type: application/javascript
module-type: library
ExactExports test
\*/
var test = require('test');
var a = require('./a');
test.assert(a.program() === exports, 'exact exports');
test.print('DONE', 'info');

View File

@@ -1,8 +0,0 @@
/*\
title: hasOwnProperty.js
type: application/javascript
module-type: library
OwnProperty test A
\*/

View File

@@ -1,15 +0,0 @@
/*\
title: hasOwnProperty/program.js
type: application/javascript
module-type: library
OwnProperty test
\*/
var hasOwnProperty = require('hasOwnProperty');
var toString = require('toString');
var test = require('test');
test.print('DONE', 'info');

View File

@@ -1,8 +0,0 @@
/*\
title: toString.js
type: application/javascript
module-type: library
OwnProperty test B
\*/

View File

@@ -1,23 +0,0 @@
/*\
title: method/a.js
type: application/javascript
module-type: library
Method test
\*/
exports.foo = function () {
return this;
};
exports.set = function (x) {
this.x = x;
};
exports.get = function () {
return this.x;
};
exports.getClosed = function () {
return exports.x;
};

View File

@@ -1,19 +0,0 @@
/*\
title: method/program.js
type: application/javascript
module-type: library
Method test
\*/
var test = require('test');
var a = require('./a');
var foo = a.foo;
test.assert(a.foo() == a, 'calling a module member');
test.assert(foo() == (function (){return this})(), 'members not implicitly bound');
a.set(10);
test.assert(a.get() == 10, 'get and set')
test.print('DONE', 'info');

View File

@@ -1,19 +0,0 @@
/*\
title: missing/program.js
type: application/javascript
module-type: library
Missing test
\*/
var test = require('test');
try {
require('bogus');
test.print('FAIL require throws error when module missing', 'fail');
} catch (exception) {
test.print('PASS require throws error when module missing', 'pass');
}
test.print('DONE', 'info');

View File

@@ -1,12 +0,0 @@
/*\
title: monkeys/a.js
type: application/javascript
module-type: library
Monkeys test A
\*/
require('./program').monkey = 10;

View File

@@ -1,15 +0,0 @@
/*\
title: monkeys/program.js
type: application/javascript
module-type: library
Monkeys test
\*/
var a = require('./a');
var test = require('test');
test.assert(exports.monkey == 10, 'monkeys permitted');
test.print('DONE', 'info');

View File

@@ -1,14 +0,0 @@
/*\
title: a/b/c/d.js
type: application/javascript
module-type: library
Nested test
\*/
exports.foo = function () {
return 1;
};

View File

@@ -1,14 +0,0 @@
/*\
title: nested/program.js
type: application/javascript
module-type: library
Nested test
\*/
var test = require('test');
test.assert(require('a/b/c/d').foo() == 1, 'nested module identifier');
test.print('DONE', 'info');

View File

@@ -1,16 +0,0 @@
/*\
title: relative/program.js
type: application/javascript
module-type: library
Relative test
\*/
var test = require('test');
var a = require('submodule/a');
var b = require('submodule/b');
test.assert(a.foo == b.foo, 'a and b share foo through a relative require');
test.print('DONE', 'info');

View File

@@ -1,13 +0,0 @@
/*\
title: submodule/a.js
type: application/javascript
module-type: library
Relative test A
\*/
exports.foo = require('./b').foo;

View File

@@ -1,12 +0,0 @@
/*\
title: submodule/b.js
type: application/javascript
module-type: library
Relative test B
\*/
exports.foo = function () {
};

View File

@@ -1,23 +0,0 @@
/*\
title: test.js
type: application/javascript
module-type: library
testing lib
\*/
exports.assert = function(cond, msg) {
if(!cond) {
if(msg) {
throw msg
} else {
throw "ASSERT FAILED"
}
}
}
exports.print = function() {
console.log.apply(console, arguments);
}

View File

@@ -1,11 +0,0 @@
/*\
title: transitive/a.js
type: application/javascript
module-type: library
Transitive test A
\*/
exports.foo = require('./b').foo;

View File

@@ -1,12 +0,0 @@
/*\
title: transitive/b.js
type: application/javascript
module-type: library
Transitive test B
\*/
exports.foo = require('./c').foo;

View File

@@ -1,14 +0,0 @@
/*\
title: transitive/c.js
type: application/javascript
module-type: library
Transitive test C
\*/
exports.foo = function () {
return 1;
};

View File

@@ -1,13 +0,0 @@
/*\
title: transitive/program.js
type: application/javascript
module-type: library
Transitive test
\*/
var test = require('test');
test.assert(require('./a').foo() == 1, 'transitive');
test.print('DONE', 'info');

View File

@@ -1,8 +0,0 @@
{
"plugins": [
"tiddlywiki/fullscreen"
],
"themes": [
"tiddlywiki/snowwhite"
]
}