JSConTest: Contract-Driven Testing and Path Effect Inference for JavaScript

By: Phillip Heidegger, Peter Thiemann


Program understanding is a major obstacle during program maintenance. In an object-oriented language, understanding an operation requires understanding its type and its effect on the object network. The effect is particularly important for scripting languages where there is neither class structure that restricts the shape of an object nor any other kind of access control. We have designed and implemented JSConTest, a tool that provides a facility to annotate JavaScript programs with type and effect contracts and to create random tests out of the contracts. Run-time monitoring for contracts is implemented with a program transformation. The effect of an operation is described by access permissions, which abstract sets of access paths along which the operation reads or writes object properties. Type contracts can also be used to drive guided random testing of the program. JSConTest contains an algorithm for computing access permissions from a set of access paths obtained by running the program. The main ingredient of the algorithm is a novel heuristic that produces precise and concise results without user interaction. It has been applied to a range of examples with encouraging results.


Contracts, effects, scripting languages, access permissions, inference, JavaScript

Cite as:

Phillip Heidegger, Peter Thiemann, “JSConTest: Contract-Driven Testing and Path Effect Inference for JavaScript”, Journal of Object Technology, Volume 11, no. 1 (April 2012), pp. 6:1-29, doi:10.5381/jot.2012.11.1.a6.

PDF | DOI | BiBTeX | Tweet this | Post to CiteULike | Share on LinkedIn

The JOT Journal   |   ISSN 1660-1769   |   DOI 10.5381/jot   |   AITO   |   Open Access   |    Contact