This project is read-only.

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
           11.1
           11.4
                  11.4.1
      chapter12
           12.10
      chapter13

Test File Naming Conventions


Individual test files have the following format:

sectionNumber[@n][-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 ordinal number of the algorithm within the section.
algorithmStepNumber: is the step number within the algorithm that the rest relates to. It maybe excluded for tests that relate to non-algorithmic sections of the specification. 0 is used to reference the non-algorithmic part of sections that include both algorithmic and non-algorithmetic content.
ggrammarProductionNumber: is an ordinal number (starting from 1) of a grammar production defined in the section. It is used for parsing related 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 -s 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 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 &quot;AS IS&quot; 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 your personal <<year>> and <<copyright owner>> information into the above header */
 

ES5Harness.registerTest( {
id: "sectionNumber[@nnn][-algorithmStepNumber]-testNumber[-s]",  //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 testObjectis an object literal.

A test case object has the following properties:
  • id: A string containing the name of this test file using the above naming conventions. The file extension is not included in the id.
  • path: A string containing the relative directory path of this test starting at TestCases.
  • description: A string describing the purpose of this test.&nbsp; It is used to generate test reports.
  • test: A function that performs the actual test. The test harness will call this function to execute the test.&nbsp; It must return true if the test passes. Any other return value indicates a failed test. The test function is called as a method with its this value set to its defining test case object.
  • precondition: (Optional) A function that is called before the test function to see if it is ok to run the test.&nbsp; If all preconditions necessary to run the test are established it should return true. If it returns , the test will not be run.&nbsp; The precondition function is called as a method with its this value set to its defining test case object. This property is optional. If it is not present, the test function will always be executed.

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 global access.

Last edited Aug 12, 2009 at 9:14 PM by allenwb, version 12

Comments

No comments yet.