js/src/tests/js1_2/version120/regress-99663.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_2/version120/regress-99663.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,132 @@
     1.4 +// |reftest| skip -- obsolete test
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +
    1.11 +//-----------------------------------------------------------------------------
    1.12 +var UBound = 0;
    1.13 +var BUGNUMBER = 99663;
    1.14 +var summary = 'Regression test for Bugzilla bug 99663';
    1.15 +/*
    1.16 + * This testcase expects error messages containing
    1.17 + * the phrase 'read-only' or something similar -
    1.18 + */
    1.19 +var READONLY = /read\s*-?\s*only/;
    1.20 +var READONLY_TRUE = 'a "read-only" error';
    1.21 +var READONLY_FALSE = 'Error: ';
    1.22 +var FAILURE = 'NO ERROR WAS GENERATED!';
    1.23 +var status = '';
    1.24 +var actual = '';
    1.25 +var expect= '';
    1.26 +var statusitems = [];
    1.27 +var expectedvalues = [];
    1.28 +var actualvalues = [];
    1.29 +
    1.30 +
    1.31 +/*
    1.32 + * These MUST be compiled in JS1.2 or less for the test to work - see above
    1.33 + */
    1.34 +function f1()
    1.35 +{
    1.36 +  with (it)
    1.37 +  {
    1.38 +    for (rdonly in this);
    1.39 +  }
    1.40 +}
    1.41 +
    1.42 +
    1.43 +function f2()
    1.44 +{
    1.45 +  for (it.rdonly in this);
    1.46 +}
    1.47 +
    1.48 +
    1.49 +function f3(s)
    1.50 +{
    1.51 +  for (it[s] in this);
    1.52 +}
    1.53 +
    1.54 +
    1.55 +
    1.56 +/*
    1.57 + * Begin testing by capturing actual vs. expected values.
    1.58 + * Initialize to FAILURE; this will get reset if all goes well -
    1.59 + */
    1.60 +actual = FAILURE;
    1.61 +try
    1.62 +{
    1.63 +  f1();
    1.64 +}
    1.65 +catch(e)
    1.66 +{
    1.67 +  actual = readOnly(e.message);
    1.68 +}
    1.69 +expect= READONLY_TRUE;
    1.70 +status = 'Section 1 of test - got ' + actual;
    1.71 +addThis();
    1.72 +
    1.73 +
    1.74 +actual = FAILURE;
    1.75 +try
    1.76 +{
    1.77 +  f2();
    1.78 +}
    1.79 +catch(e)
    1.80 +{
    1.81 +  actual = readOnly(e.message);
    1.82 +}
    1.83 +expect= READONLY_TRUE;
    1.84 +status = 'Section 2 of test - got ' + actual;
    1.85 +addThis();
    1.86 +
    1.87 +
    1.88 +actual = FAILURE;
    1.89 +try
    1.90 +{
    1.91 +  f3('rdonly');
    1.92 +}
    1.93 +catch(e)
    1.94 +{
    1.95 +  actual = readOnly(e.message);
    1.96 +}
    1.97 +expect= READONLY_TRUE;
    1.98 +status = 'Section 3 of test - got ' + actual;
    1.99 +addThis();
   1.100 +
   1.101 +
   1.102 +
   1.103 +//-----------------------------------------------------------------------------
   1.104 +test();
   1.105 +//-----------------------------------------------------------------------------
   1.106 +
   1.107 +
   1.108 +
   1.109 +function readOnly(msg)
   1.110 +{
   1.111 +  if (msg.match(READONLY))
   1.112 +    return READONLY_TRUE;
   1.113 +  return READONLY_FALSE + msg;
   1.114 +}
   1.115 +
   1.116 +
   1.117 +function addThis()
   1.118 +{
   1.119 +  statusitems[UBound] = status;
   1.120 +  actualvalues[UBound] = actual;
   1.121 +  expectedvalues[UBound] = expect;
   1.122 +  UBound++;
   1.123 +}
   1.124 +
   1.125 +
   1.126 +function test()
   1.127 +{
   1.128 +  print ('Bug Number ' + bug);
   1.129 +  print ('STATUS: ' + summary);
   1.130 +
   1.131 +  for (var i=0; i<UBound; i++)
   1.132 +  {
   1.133 +    writeTestCaseResult(expectedvalues[i], actualvalues[i], statusitems[i]);
   1.134 +  }
   1.135 +}

mercurial