forked from 280north/narwhal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into kriskowal
Conflicts: catalog-2.json sources.json
- Loading branch information
Showing
6 changed files
with
228 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
|
@@ -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": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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+"]"); | ||
} |