Skip to content

Commit

Permalink
Hard-code source for $ERROR and Test262Error
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Jul 21, 2015
1 parent 81244a5 commit 33c083c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 62 deletions.
26 changes: 0 additions & 26 deletions lib/helpers/sta.js

This file was deleted.

24 changes: 23 additions & 1 deletion lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var fs = require('fs');
var path = require('path');
var parseFile = require('test262-parser').parseFile;

var autoIncludes = ['sta.js', 'assert.js'];
var autoIncludes = ['assert.js'];

function Runner(opts) {
this.opts = opts
Expand Down Expand Up @@ -38,6 +38,10 @@ Runner.prototype.compile = function(test) {
test.contents += "\n;$DONE();\n"
}

test.contents = [
this.test262ErrorSrc, this.errorFnSrc, test.contents
].join(";\n");

this.deps.forEach(function(dep) {
test.contents = dep + "\n" + test.contents;
})
Expand Down Expand Up @@ -84,6 +88,24 @@ Runner.prototype.link = function(test) {
test.contents = includeContent + test.contents;
}

Runner.prototype.test262ErrorSrc = function() {
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};
}.toString().slice(14, -1);

Runner.prototype.errorFnSrc = function $ERROR(err) {
if(typeof err === "object" && err !== null && "name" in err)
throw err;
else throw new Test262Error(err);
}.toString();

var errorLogRe = /^test262\/error (.*)$/;
// Result is expected to have the following keys:
// errorString: Error of the form ErrorName: ErrorMessage. Optional.
Expand Down
3 changes: 1 addition & 2 deletions lib/runners/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ var doneFn = function $DONE(err) {

var batchDoneFn = function $DONE(err) {
if(err) {
if(typeof err === "object" && err !== null) {
err.name = err.name || "Test262Error";
if(typeof err === "object" && err !== null && "name" in err) {
if("stack" in err) $LOG("test262/error " + err.stack)
else $LOG("test262/error " + err.name + ": " + err.message)
}
Expand Down
6 changes: 3 additions & 3 deletions lib/runners/node-ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NodeRunner.prototype.execute = function(test, cb) {
var error;
var result = {log: []};

var context = vm.createContext({
var context = {
$DONE: function(err) {
error = err;
result.doneCalled = true;
Expand All @@ -22,10 +22,10 @@ NodeRunner.prototype.execute = function(test, cb) {
result.log.push(log);
},
process: process
});
};

try {
vm.runInContext(contents, context, {displayErrors: false});
vm.runInNewContext(contents, context, {displayErrors: false});
} catch(e) {
error = e;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/runners/nodehost.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var vm = require('vm');
process.stdin.resume();
process.stdin.on('data', function(test) {
var result = { log: [] }
var context = vm.createContext({
var context = {
$DONE: function(error) {
if(error) {
if(typeof error === 'object') {
Expand All @@ -22,10 +22,10 @@ process.stdin.on('data', function(test) {
console.log(log);
},
process: process
});
};

try {
vm.runInContext(test, context, {displayErrors: false});
vm.runInNewContext(test, context, {displayErrors: false});
} catch(e) {
context.$DONE(e);
}
Expand Down
1 change: 0 additions & 1 deletion test/test262alike/badHarness/sta.js

This file was deleted.

26 changes: 0 additions & 26 deletions test/test262alike/harness/sta.js

This file was deleted.

0 comments on commit 33c083c

Please sign in to comment.