JSGen is a JavaScript Program Generator. It generalizes program generation techniques used in another tool JEST which is a N+1-version Differential Testing of both JavaScript engines and specifications.
We explain how to install JSGen with necessary environment settings from the
scratch. Before installation, please download JDK 8 and
sbt.
$ git clone https://github.com/f52985/jsgen.gitInsert the following commands to ~/.bashrc (or ~/.zshrc):
# for JSGen
export JSGEN_HOME="<path to JSGen>" # IMPORTANT!!!
export PATH="$JSGEN_HOME/bin:$PATH" # for executables `jsgen` and etc.
source $JSGEN_HOME/jsgen-auto-completion # for auto completionThe <path to JSGen> should be the absolute path of JSGen repository.
$ cd jsgen && git submodule init && git submodule update && sbt assemblyExtract and generate a model from ECMAScript 2021 (ES12 / es2021):
$ jsgen gen-model -extract:version=es2021
# ========================================
# extract phase
# ----------------------------------------
# version: es2021
# parsing spec.html... (10,476 ms)
# ========================================
# gen-model phase
# ----------------------------------------
# generating models... (240 ms)Create the following JavaScript file sample.js:
// sample.js
var x = 1 + 2;
print(x);Parse sample.js:
$ jsgen parse sample.js
# ========================================
# parse phase
# ----------------------------------------
# var x = 1 + 2 ; print ( x ) ;Evaluate sample.js:
$ jsgen eval sample.js -silent
# 3.0Show detail path and final results during evaluation of sample.js:
$ jsgen eval sample.js -debugYou can run the artifact with the following command:
$ jsgen <sub-command> <option>*with the following sub-commands:
helpshows the help message.extractextracts ECMAScript model fromecma262/spec.html.gen-modelgenerates ECMAScript models.compile-replperforms REPL for printing compile result of particular step.gen-testgenerates tests with the current implementation as the oracle.parseparses a JavaScript file using the generated parser.loadloads a JavaScript AST to the initial IR states.evalevaluates a JavaScript file using generated interpreter.filter-metaextracts and filters out metadata of test262 tests.parse-irparses an IR file.load-irloads an IR AST to the initial IR states.eval-irevaluates an IR file.repl-irperforms REPL for IR instructions.build-cfgbuilds control flow graph (CFG).
and global options:
-silentdoes not show final results.-debugturns on the debug mode.-interactiveturns on the interactive mode.-no-bugfixuses semantics including specification bugs.-timedisplays the duration time.