Test File Directory Hierarchy

With in the TestCases directory individual tests are organized into subdirectories corresponding to chapters (top level section numbers) of the ECMAScript 5 Specification.
For Example:
TestCases
      chapter11
      chapter12
      chapter13

Test File Naming Conventions


Individual test file names have the following format:

sectionNumber[@nnn][-algorithmStepNumber|-ggrammarProductionNumber]-testNumber[-s][-x].js

Where:
sectionNumber: is the section number of the ECMAScript 5 Specification that this test is primarily concerned with.
@n: is optional and used if a section contains more than one algorithm. n is the ordinal number of the algorithm within the section.
algorithmStepNumber: is the step number within the algorithm that the rest relates to. 0 is used for tests that relate to non-algorithmic portions of the specification.
ggrammarProduction:   is a ordinal number (starting from 1) of a grammar production defined in the section. If is used for parsing tests.
testNumber: is present if there is more than one testcase for a particular algorithm step or non-algorithm specification section.
-s: is an optional suffix that identifies that the test is only applies to strict mode
-x: is an optional suffix that identifies that the test intentionally contains something that should case a syntax error. Such tests are expected to not load correctly and if they do it load it is a test failure. The test function should not return true.

Test File Structure

Each testcase must be a single .js file. A template of a testcase file can be found at: TestCases/testTemplate.js
A testcase is made up of the following parts (1) License header, (2) test registration call (3) test case object literal and looks like:

/// Copyright (c) <<year>> <<copyright owner>>. 
/// 
/// Redistribution and use in source and binary forms, with or without modification, are permitted provided
/// that the following conditions are met: 
///    * Redistributions of source code must retain the above copyright notice, this list of conditions and
///      the following disclaimer. 
///    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 
///      the following disclaimer in the documentation and/or other materials provided with the distribution.  
///    * Neither the name of <<copyright owner>> nor the names of its contributors may be used to
///      endorse or promote products derived from this software without specific prior written permission.
/// 
/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
/// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
/// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
/// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
/// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
/// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
/// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 

/* be sure to put the current <<year>> and <<copyright owner>> information into the above header */
 

ES5Harness.registerTest( {
id: "sectionNumber[@nnn][-algorithmStepNumber]-testNumber[-s][x]",  //put a unique test id here

path: "TestCases/testTemplate.js",    //the directory path of this test starting at TestCases

description: 'Insert text descripting the test here',

test: function testcase() {
  //Add test code here, return true if test passes
 }

precondition: function precond() {
 //Add code to test any preconditions that must be establish in order to run this test.
 //Return true if it is ok to run the test.
 //This property may be completely omitted in which case the test will always be run.
 return true;
 }

});


The license header is the copyright notice and New BSD license text. Be sure to fill in the actual year and name of the copyright holder.
The test registration is a JavaScript function call of the form:
   ES5Harness.registerTest( testObject);
ES5Harness is the global name of the test harness and registerTest is the method that is used to register tests. The argument is an object that defines an individual test. Normally the argument testObject is an object literal.

A test case object has the following properties:

A text case object may also define other properties. 

The test case file may also contain additional global code and declarations.  However, this is not recommended unless necessary for creating a test relating to such globals.