js/src/tests/ecma_3/Object/class-004.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_3/Object/class-004.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,105 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/*
    1.10 + * Date: 14 Mar 2001
    1.11 + *
    1.12 + * SUMMARY: Testing [[Class]] property of native error constructors.
    1.13 + * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property.
    1.14 + *
    1.15 + * See ECMA-262 Edition 3, Section 15.11.6 for the native error types.
    1.16 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868
    1.17 + *
    1.18 + * Same as class-003.js - but testing the constructors here, not
    1.19 + * object instances.  Therefore we expect the [[Class]] property to
    1.20 + * equal 'Function' in each case.
    1.21 + *
    1.22 + * The getJSClass() function we use is in a utility file, e.g. "shell.js"
    1.23 + */
    1.24 +//-----------------------------------------------------------------------------
    1.25 +var i = 0;
    1.26 +var UBound = 0;
    1.27 +var BUGNUMBER = 56868;
    1.28 +var summary = 'Testing the internal [[Class]] property of native error constructors';
    1.29 +var statprefix = 'Current constructor is: ';
    1.30 +var status = ''; var statusList = [ ];
    1.31 +var actual = ''; var actualvalue = [ ];
    1.32 +var expect= ''; var expectedvalue = [ ];
    1.33 +
    1.34 +/*
    1.35 + * We set the expect variable each time only for readability.
    1.36 + * We expect 'Function' every time; see discussion above -
    1.37 + */
    1.38 +status = 'Error';
    1.39 +actual = getJSClass(Error);
    1.40 +expect = 'Function';
    1.41 +addThis();
    1.42 +
    1.43 +status = 'EvalError';
    1.44 +actual = getJSClass(EvalError);
    1.45 +expect = 'Function';
    1.46 +addThis();
    1.47 +
    1.48 +status = 'RangeError';
    1.49 +actual = getJSClass(RangeError);
    1.50 +expect = 'Function';
    1.51 +addThis();
    1.52 +
    1.53 +status = 'ReferenceError';
    1.54 +actual = getJSClass(ReferenceError);
    1.55 +expect = 'Function';
    1.56 +addThis();
    1.57 +
    1.58 +status = 'SyntaxError';
    1.59 +actual = getJSClass(SyntaxError);
    1.60 +expect = 'Function';
    1.61 +addThis();
    1.62 +
    1.63 +status = 'TypeError';
    1.64 +actual = getJSClass(TypeError);
    1.65 +expect = 'Function';
    1.66 +addThis();
    1.67 +
    1.68 +status = 'URIError';
    1.69 +actual = getJSClass(URIError);
    1.70 +expect = 'Function';
    1.71 +addThis();
    1.72 +
    1.73 +
    1.74 +
    1.75 +//---------------------------------------------------------------------------------
    1.76 +test();
    1.77 +//---------------------------------------------------------------------------------
    1.78 +
    1.79 +
    1.80 +
    1.81 +function addThis()
    1.82 +{
    1.83 +  statusList[UBound] = status;
    1.84 +  actualvalue[UBound] = actual;
    1.85 +  expectedvalue[UBound] = expect;
    1.86 +  UBound++;
    1.87 +}
    1.88 +
    1.89 +
    1.90 +function test()
    1.91 +{
    1.92 +  enterFunc ('test');
    1.93 +  printBugNumber(BUGNUMBER);
    1.94 +  printStatus (summary);
    1.95 +
    1.96 +  for (i = 0; i < UBound; i++)
    1.97 +  {
    1.98 +    reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
    1.99 +  }
   1.100 +
   1.101 +  exitFunc ('test');
   1.102 +}
   1.103 +
   1.104 +
   1.105 +function getStatus(i)
   1.106 +{
   1.107 +  return statprefix + statusList[i];
   1.108 +}

mercurial