-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin testing harness: Add support for keeping heap between executions
This will permit us to run the test262 prelude in a separate context from the testcase itself. This was a bug in the original JSRef, see issue #9: resource-reasoning/jscert_dev#9
- Loading branch information
1 parent
6bc4e94
commit 7743528
Showing
3 changed files
with
44 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
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,32 @@ | ||
"use strict"; | ||
|
||
var esprima = require('esprima'); | ||
var esprimaToAST = require('../esprima-to-ast.js').esprimaToAST; | ||
var JsInterpreter = require('../generator/tests/jsref/assembly.js'); | ||
|
||
// Stub logging functions | ||
['ctx_empty', 'ctx_push', 'log_event'].forEach(f => global[f] = function(){}) | ||
|
||
var parse = function(source) { | ||
return esprimaToAST(esprima.parse(source, {loc: true, range: true}), source); | ||
} | ||
|
||
var run = function(program) { | ||
return JsInterpreter.run_javascript(program); | ||
}; | ||
|
||
// Functions to run multiple programs in the same heap | ||
// Useful for correctly loading the test262 prelude before the testcase | ||
var run_multiple = function(programs) { | ||
if(programs.length < 1) { throw "No programs" } | ||
var firstResult = run(programs.shift()); | ||
return programs.reduce(JsInterpreter.run_javascript_from_result, firstResult); | ||
}; | ||
|
||
var parse_and_run_multiple = function(sources) { | ||
var programs = sources.map(parse); | ||
return run_multiple(programs); | ||
} | ||
|
||
console.dir(parse_and_run_multiple(["var x = 10", "x+1"]), {depth: 6, colors: true}); | ||
console.dir(parse_and_run_multiple(["throw 10", "x+1"]), {depth: 6, colors: true}); |