Skip to content

Commit

Permalink
Inject sta.js as provided by Test262
Browse files Browse the repository at this point in the history
The Test262 project "interpreting" guidelines include the following
requirement:

> ### Test262-Defined Bindings
>
> The contents of the following files must be evaluated in the test realm's
> global scope prior to test execution:
>
> 1. `harness/assert.js`
> 2. `harness/sta.js`

Satisfy this requirement by loading the provided file and injecting it
into the test contents.
  • Loading branch information
jugglinmike authored and rwaldron committed Jan 19, 2018
1 parent 3abeae8 commit e1d2b3c
Show file tree
Hide file tree
Showing 63 changed files with 540 additions and 550 deletions.
5 changes: 2 additions & 3 deletions lib/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
const fs = require('fs');
const path = require('path');
const parseFile = require('test262-parser').parseFile;
const deps = fs.readFileSync(__dirname + '/compilerdeps.js');

module.exports = function compile(test, options) {
options = options || {};
Expand All @@ -28,20 +27,20 @@ module.exports = function compile(test, options) {
if (test.attrs.flags.onlyStrict) {
preludeContents += '"use strict";\n';
}
preludeContents += deps;

const helpers = test.attrs.includes;
helpers.push('assert.js');
helpers.push('sta.js');

if (test.attrs.flags.async) {
helpers.push('doneprintHandle.js');
}

for (let i = 0; i < helpers.length; i++) {
preludeContents += '\n';
preludeContents += fs.readFileSync(
path.join(options.includesDir, helpers[i])
);
preludeContents += '\n';
}

test.contents = preludeContents + test.contents;
Expand Down
17 changes: 0 additions & 17 deletions lib/compilerdeps.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

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

// This is assert.js

'It has some contents';
Expand All @@ -34,6 +16,19 @@ whitespace: ;

void "end of assert.js";

function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};

function $DONE(){
if(!arguments[0])
print('Test262:AsyncTestComplete');
Expand All @@ -42,6 +37,7 @@ function $DONE(){
}



setTimeout(function() {
$DONE(new RangeError());
}, 1000);
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
"use strict";
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

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

// This is assert.js

'It has some contents';
Expand All @@ -35,6 +17,19 @@ whitespace: ;

void "end of assert.js";

function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};

function $DONE(){
if(!arguments[0])
print('Test262:AsyncTestComplete');
Expand All @@ -43,6 +38,7 @@ function $DONE(){
}



setTimeout(function() {
$DONE(new RangeError());
}, 1000);
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

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

// This is assert.js

'It has some contents';
Expand All @@ -34,6 +16,19 @@ whitespace: ;

void "end of assert.js";

function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};

function $DONE(){
if(!arguments[0])
print('Test262:AsyncTestComplete');
Expand All @@ -42,6 +37,7 @@ function $DONE(){
}



var p = new Promise(function(resolve) {
resolve();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
"use strict";
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

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

// This is assert.js

'It has some contents';
Expand All @@ -35,6 +17,19 @@ whitespace: ;

void "end of assert.js";

function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};

function $DONE(){
if(!arguments[0])
print('Test262:AsyncTestComplete');
Expand All @@ -43,6 +38,7 @@ function $DONE(){
}



var p = new Promise(function(resolve) {
resolve();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

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

// This is assert.js

'It has some contents';
Expand All @@ -34,6 +16,20 @@ whitespace: ;

void "end of assert.js";

function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};


var strict;
try { x = 1; strict = false;} catch(e) { strict = true }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
"use strict";
function Test262Error(message) {
if (message) this.message = message;
}

Test262Error.prototype.name = "Test262Error";

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

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

// This is assert.js

'It has some contents';
Expand All @@ -35,6 +17,20 @@ whitespace: ;

void "end of assert.js";

function Test262Error(message) {
this.message = message || "";
}

Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

var $ERROR;
$ERROR = function $ERROR(message) {
throw new Test262Error(message);
};


var strict;
try { x = 1; strict = false;} catch(e) { strict = true }

Expand Down
Loading

0 comments on commit e1d2b3c

Please sign in to comment.