Skip to content

Commit

Permalink
Merge branch 'master' into kriskowal
Browse files Browse the repository at this point in the history
Conflicts:
	catalog-2.json
	sources.json
  • Loading branch information
Tom Robinson committed Mar 2, 2010
2 parents 0e42a8b + b1dce3f commit 146266c
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 3 deletions.
78 changes: 77 additions & 1 deletion catalog-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@
"version": [
"0",
"1",
"2"
"3"
],
"descriptorUrl": "http://github.com/280north/jake/raw/master/package.json",
"packageUrl": "http://github.com/280north/jake/zipball/master",
Expand Down Expand Up @@ -2782,6 +2782,82 @@
"archive": "zip"
},
"version": []
},
"jdbc": {
"name": "jdbc",
"contributors": [
{
"name": "Tom Robinson",
"url": "http://tlrobinson.net/",
"email": "[email protected]"
}
],
"descriptorUrl": "http://github.com/tlrobinson/commonjs-jdbc/raw/master/package.json",
"packageUrl": "http://github.com/tlrobinson/commonjs-jdbc/zipball/master",
"packageArchive": "zip",
"source": {
"type": "github",
"user": "tlrobinson",
"name": "commonjs-jdbc",
"packageName": "jdbc",
"descriptorUrl": "http://github.com/tlrobinson/commonjs-jdbc/raw/master/package.json",
"url": "http://github.com/tlrobinson/commonjs-jdbc/zipball/master",
"archive": "zip"
},
"dependencies": [],
"version": []
},
"mysql-jdbc": {
"name": "mysql-jdbc",
"dependencies": [
"jdbc"
],
"contributors": [
{
"name": "Tom Robinson",
"url": "http://tlrobinson.net/",
"email": "[email protected]"
}
],
"descriptorUrl": "http://github.com/tlrobinson/commonjs-mysql-jdbc/raw/master/package.json",
"packageUrl": "http://github.com/tlrobinson/commonjs-mysql-jdbc/zipball/master",
"packageArchive": "zip",
"source": {
"type": "github",
"user": "tlrobinson",
"name": "commonjs-mysql-jdbc",
"packageName": "mysql-jdbc",
"descriptorUrl": "http://github.com/tlrobinson/commonjs-mysql-jdbc/raw/master/package.json",
"url": "http://github.com/tlrobinson/commonjs-mysql-jdbc/zipball/master",
"archive": "zip"
},
"version": []
},
"sqlite-jdbc": {
"name": "sqlite-jdbc",
"dependencies": [
"jdbc"
],
"contributors": [
{
"name": "Tom Robinson",
"url": "http://tlrobinson.net/",
"email": "[email protected]"
}
],
"descriptorUrl": "http://github.com/tlrobinson/commonjs-sqlite-jdbc/raw/master/package.json",
"packageUrl": "http://github.com/tlrobinson/commonjs-sqlite-jdbc/zipball/master",
"packageArchive": "zip",
"source": {
"type": "github",
"user": "tlrobinson",
"name": "commonjs-sqlite-jdbc",
"packageName": "sqlite-jdbc",
"descriptorUrl": "http://github.com/tlrobinson/commonjs-sqlite-jdbc/raw/master/package.json",
"url": "http://github.com/tlrobinson/commonjs-sqlite-jdbc/zipball/master",
"archive": "zip"
},
"version": []
}
}
}
2 changes: 1 addition & 1 deletion lib/narwhal.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ exports.ensureEngine = function(engines) {
if (engines[i] === SYSTEM.engine)
return;

SYSTEM.stderr.print('Warning: '+FILE.basename(SYSTEM.args[0])+' is incompatible with "'+SYSTEM.engine+'" engine. '+
SYSTEM.stderr.print('Notice: '+FILE.basename(SYSTEM.args[0])+' is incompatible with "'+SYSTEM.engine+'" engine. '+
'Automatically running with "'+engines[0]+'" engine instead.');

OS.exit(OS.system("NARWHAL_ENGINE_HOME='' NARWHAL_ENGINE='"+engines[0]+"' "+
Expand Down
1 change: 0 additions & 1 deletion lib/narwhal/tusk/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ exports.install = function (options, names) {
var zipFile = tusk.getZipsDirectory().join(UUID.uuid()+".zip");
var zipData = http.read(name, 'b');
zipFile.write(zipData, 'b');
cleanupPaths.push(zipFile);

return zipFile.toString();
}
Expand Down
15 changes: 15 additions & 0 deletions sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,21 @@
"reform": {
"type": "github",
"user": "fitzgen"
},
"jdbc": {
"type": "github",
"user": "tlrobinson",
"name": "commonjs-jdbc"
},
"mysql-jdbc": {
"type": "github",
"user": "tlrobinson",
"name": "commonjs-mysql-jdbc"
},
"sqlite-jdbc": {
"type": "github",
"user": "tlrobinson",
"name": "commonjs-sqlite-jdbc"
}
}
}
81 changes: 81 additions & 0 deletions tests/interpreter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
var ASSERT = require("test/assert");

var Context = require("interpreter").Context;

exports.testContextGlobalAssignment = function() {
var c = new Context();

ASSERT.isTrue(typeof global.foo === "undefined");
ASSERT.isTrue(!c.global.foo);

var testObj = {};

c.global.foo = testObj;

ASSERT.isTrue(typeof global.foo === "undefined");
ASSERT.eq(testObj, c.global.foo);
ASSERT.eq(testObj, c.eval("foo"));
ASSERT.eq(testObj, (new c.Function("return foo;"))());
}

exports.testContextEval = function() {
var c = new Context();

ASSERT.isTrue(typeof global.foo === "undefined");
ASSERT.isTrue(!c.global.foo);

c.eval("foo = 1234;");

ASSERT.isTrue(typeof global.foo === "undefined");
ASSERT.eq(1234, c.global.foo);
ASSERT.eq(1234, c.eval("foo"));
ASSERT.eq(1234, (new c.Function("return foo;"))());
}

exports.testContextFunction = function() {
var c = new Context();

ASSERT.isTrue(typeof global.foo === "undefined");
ASSERT.isTrue(!c.global.foo);

var testObj = {};

(new c.Function("bar", "foo = bar;"))(testObj);

ASSERT.isTrue(typeof global.foo === "undefined");
ASSERT.eq(testObj, c.global.foo);
ASSERT.eq(testObj, c.eval("foo"));
ASSERT.eq(testObj, (new c.Function("return foo;"))());
}

exports.testContextGlobal = function() {
var c = new Context();

ASSERT.eq(c.eval("(function(){ return this; })()"), c.global);

ASSERT.eq(c.eval("this"), c.global);

ASSERT.isTrue(c.eval("(function(){ return this; })() === this"));

ASSERT.isTrue(global !== c.global, "Context global should be unique.");
}

exports.testContextPrimordials = function() {
var c = new Context();

var globalNames = [
"Array", "Boolean", "Date", "Error", "EvalError", "Function",
"Math", "Number", "Object", "RangeError", "ReferenceError",
"RegExp", "String", "SyntaxError", "TypeError", "URIError",
"decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent",
"eval", "isFinite", "isNaN", "parseFloat", "parseInt",
];

globalNames.forEach(function(globalName) {
ASSERT.isTrue(!!c.global[globalName], globalName + " global should exist");
ASSERT.isTrue(c.global[globalName] !== global[globalName], globalName + " global should be different than parent Context's");
});
}

if (require.main == module)
require("os").exit(require("test/runner").run(exports));
54 changes: 54 additions & 0 deletions tests/os/parse-fuzzer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var OS = require("os");
var ASSERT = require("assert");
var UTIL = require("UTIL");
var stream = require("term").stream;

var random = false;
var tokens = ["x", "'", '"', " "];

function shellParse(argString) {
var p = OS.popen(["sh", "-c", 'for i in "$@"; do echo "$i"; done', "--"].map(OS.enquote).join(" ") + " " + argString);
var result = p.stdout.read().split("\n").slice(0,-1);
if (p.wait())
throw result;
return result;
}

var testIndex = -1;
function buildTestString() {

if (random) {
var components = [];
var n = Math.round(Math.random()*10);
while (components.length < n)
components.push(tokens[Math.floor(Math.random()*tokens.length)]);
return components.join("");
}
else {
var index = testIndex++;
if (index < 0)
return "";
// convert to a base tokens.length number and replace each digit with corresponding token
return index.toString(tokens.length).replace(/./g, function(x) {
return tokens[parseInt(x, tokens.length)];
});
}
}

while (true) {
var argString = buildTestString();

try {
var expectedArgs = shellParse(argString);
} catch (e) {
// TODO: test invalid behavior matches?
continue;
}

var actualArgs = OS.parse(argString);

var pass = UTIL.eq(expectedArgs, actualArgs);

stream.print("[" + testIndex + "] " + (pass ? "\0green(PASS\0)" : "\0red(FAIL\0)") +
": string=["+argString+"] expected=["+expectedArgs+"] actual=["+actualArgs+"]");
}

0 comments on commit 146266c

Please sign in to comment.