JavaScript-V8-CommonJS

 view release on metacpan or  search on metacpan

share/require.js  view on Meta::CPAN

(function(global) {
    "use strict";

    var modules = {},
        callStack = [];

    global.require = function(id) {

        // native module
        var native = requireNative(id);
        if (native) {
            return native;
        }

        // resolve file
        var currentModule = callStack[callStack.length-1];
        var file = resolveModule(id, currentModule ? currentModule.__filename : undefined);
        if (!file) {
            throw new Error("Can't find module '" + id + "'")
        }

t/modules/1.0/absolute/program.js  view on Meta::CPAN

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');

t/modules/1.0/absolute/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/cyclic/a.js  view on Meta::CPAN

exports.a = function () {
    return b;
};
var b = require('b');

t/modules/1.0/cyclic/b.js  view on Meta::CPAN

var a = require('a');
exports.b = function () {
    return a;
};

t/modules/1.0/cyclic/program.js  view on Meta::CPAN

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');

t/modules/1.0/cyclic/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/determinism/program.js  view on Meta::CPAN

var test = require('test');
require('submodule/a');
test.print('DONE', 'info');

t/modules/1.0/determinism/submodule/a.js  view on Meta::CPAN

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.')

t/modules/1.0/determinism/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/exactExports/program.js  view on Meta::CPAN

var test = require('test');
var a = require('a');
test.assert(a.program() === exports, 'exact exports');
test.print('DONE', 'info');

t/modules/1.0/exactExports/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/hasOwnProperty/program.js  view on Meta::CPAN

var hasOwnProperty = require('hasOwnProperty');
var toString = require('toString');
var test = require('test');
test.assert(1);

t/modules/1.0/hasOwnProperty/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/method/program.js  view on Meta::CPAN

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');

t/modules/1.0/method/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/missing/program.js  view on Meta::CPAN

var test = require('test');
try {
    require('bogus');
    test.assert(0, 'require throws error when module missing');
} catch (exception) {
    test.assert(1, 'require throws error when module missing');
}
test.print('DONE', 'info');

t/modules/1.0/missing/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/monkeys/program.js  view on Meta::CPAN

var a = require('a');
var test = require('test');
test.assert(exports.monkey == 10, 'monkeys permitted');
test.print('DONE', 'info');

t/modules/1.0/monkeys/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/nested/program.js  view on Meta::CPAN

var test = require('test');
test.assert(require('a/b/c/d').foo() == 1, 'nested module identifier');
test.print('DONE', 'info');

t/modules/1.0/nested/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/relative/program.js  view on Meta::CPAN

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');

t/modules/1.0/relative/submodule/a.js  view on Meta::CPAN

exports.foo = require('./b').foo;

t/modules/1.0/relative/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/1.0/transitive/a.js  view on Meta::CPAN

exports.foo = require('b').foo;

t/modules/1.0/transitive/b.js  view on Meta::CPAN

exports.foo = require('c').foo;

t/modules/1.0/transitive/program.js  view on Meta::CPAN

var test = require('test');
test.assert(require('a').foo() == 1, 'transitive');
test.print('DONE', 'info');

t/modules/1.0/transitive/test.js  view on Meta::CPAN


exports.print = typeof print !== "undefined" ? print : function () {
    var system = require("system");
    var stdio = system.stdio;
    stdio.print.apply(stdio, arguments);
};

exports.assert = function (guard, message) {
    if (guard) {
        exports.print('PASS ' + message, 'pass');
    } else {
        exports.print('FAIL ' + message, 'fail');
    }

t/modules/exception.js  view on Meta::CPAN


// call bad module
var submodule = require('notStrict');



( run in 0.726 second using v1.01-cache-2.11-cpan-0d8aa00de5b )