js/src/tests/js1_5/Exceptions/regress-123002.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/Exceptions/regress-123002.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     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 + *
    1.11 + * Date:    01 Feb 2002
    1.12 + * SUMMARY: Testing Error.length
    1.13 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=123002
    1.14 + *
    1.15 + * NOTE: Error.length should equal the length of FormalParameterList of the
    1.16 + * Error constructor. This is currently 1 in Rhino, 3 in SpiderMonkey.
    1.17 + *
    1.18 + * The difference is due to http://bugzilla.mozilla.org/show_bug.cgi?id=50447.
    1.19 + * As a result of that bug, SpiderMonkey has extended ECMA to allow two new
    1.20 + * parameters to Error constructors:
    1.21 + *
    1.22 + * Rhino:        new Error (message)
    1.23 + * SpiderMonkey: new Error (message, fileName, lineNumber)
    1.24 + *
    1.25 + * NOTE: since we have hard-coded the length expectations, this testcase will
    1.26 + * have to be changed if the Error FormalParameterList is ever changed again.
    1.27 + *
    1.28 + * To do this, just change the two LENGTH constants below -
    1.29 + */
    1.30 +//-----------------------------------------------------------------------------
    1.31 +var UBound = 0;
    1.32 +var BUGNUMBER = 123002;
    1.33 +var summary = 'Testing Error.length';
    1.34 +var QUOTE = '"';
    1.35 +var status = '';
    1.36 +var statusitems = [];
    1.37 +var actual = '';
    1.38 +var actualvalues = [];
    1.39 +var expect= '';
    1.40 +var expectedvalues = [];
    1.41 +
    1.42 +
    1.43 +var LENGTH_EXPECTED = 1;
    1.44 +
    1.45 +/*
    1.46 + * The various NativeError objects; see ECMA-262 Edition 3, Section 15.11.6
    1.47 + */
    1.48 +var errObjects = [new Error(), new EvalError(), new RangeError(),
    1.49 +		  new ReferenceError(), new SyntaxError(), new TypeError(), new URIError()];
    1.50 +
    1.51 +
    1.52 +for (var i in errObjects)
    1.53 +{
    1.54 +  var err = errObjects[i];
    1.55 +  status = inSection(quoteThis(err.name));
    1.56 +  actual = Error.length;
    1.57 +  expect = LENGTH_EXPECTED;
    1.58 +  addThis();
    1.59 +}
    1.60 +
    1.61 +
    1.62 +
    1.63 +//-----------------------------------------------------------------------------
    1.64 +test();
    1.65 +//-----------------------------------------------------------------------------
    1.66 +
    1.67 +
    1.68 +
    1.69 +function addThis()
    1.70 +{
    1.71 +  statusitems[UBound] = status;
    1.72 +  actualvalues[UBound] = actual;
    1.73 +  expectedvalues[UBound] = expect;
    1.74 +  UBound++;
    1.75 +}
    1.76 +
    1.77 +
    1.78 +function test()
    1.79 +{
    1.80 +  enterFunc('test');
    1.81 +  printBugNumber(BUGNUMBER);
    1.82 +  printStatus(summary);
    1.83 +
    1.84 +  for (var i=0; i<UBound; i++)
    1.85 +  {
    1.86 +    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    1.87 +  }
    1.88 +
    1.89 +  exitFunc ('test');
    1.90 +}
    1.91 +
    1.92 +
    1.93 +function quoteThis(text)
    1.94 +{
    1.95 +  return QUOTE + text + QUOTE;
    1.96 +}

mercurial