The PurrPackage JavaScript API

The document is unfinished TODO

JSON Format for coverage data

Most of the details on the JavaScript API are described in this documentation. We will assume that you are familiar with this, and will describe here some auxiliary information that is added around this, and even added to this when it is loaded into the browser.

Supplied examples

The standard reports that come with PurrPackage are easy enough to understand, especially the plain.html and policyPlain.html reports. The reports use 3 tools beyond basic JavaScript:

  1. Dojo. The plain reports use Dojo in very simple ways, while the fancier reports depend heavily on Dojo widgets and styling.
  2. Trimpath templates. This is a simple template engine that I find handy for describing the coverage tables. The standard reports store the templates in hidded textarea elements in the HTML itself.
  3. Sortable, a garden variety table sorting library.

Additions to the JSON data

After the JSON data is loaded by the standard reports, we used javascript to create a "parent" attribute that links from child to parent.

Coverage Policy Features

Link here to a description of the coverage policy DSL

When policies are applied, the objects from the JSON data get an additional "testResults" property, whose value is object with the following properties and methods:

passed(): boolean
True means that all the requirements of the coverage policy satisfied by this node?
allChildrenPassed: boolean
True means that all of the descendent nodes met all of their requirements.
passedWithChildren(): boolean
The boolean "and" of the previous two properties.
results: array
An array of objects, one for each requirement of the policy for this type of node, each with the following properties and methods:
exceptionRule
Each requirement also has a list of exception clauses (expressed with "exceptIf" or "orIf") that apply when a test is met; these clauses may or may not have alternate criteria. This value is the integer index of the exception clause that was applied; 0 means the main rule was applied.
result
An object that represents the result of the test, with the following properties:
  • passed: boolean, was this requirment met?
  • message(): A sentence describing the test and the result.
  • item: A back reference to the item to which the Test was applied.
  • test: A back reference to the Test that was applied. The Test is the parameter to the "mustSatisfy" or "inWhichCase" clauses in the Coverage Policy DSL.

Other data

We should explain, but don't:

jsErrors
Global variable of an array for things that go wrong loading the page. For example, loading, parsing, and applying coverage policy configuration.
summaryData
The JSON object loaded from the Json Report.
coverageData
Global variable pointing to the root coverage data node. Same as summaryData.data.
helpers.js
Helpers for loading and rendering the data

Advanced featuers

Predicate calculus