js/src/tests/js1_5/extensions/regress-231518.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_5/extensions/regress-231518.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,101 @@
     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 +var BUGNUMBER = 231518;
    1.11 +var summary = 'decompiler must quote keywords and non-identifier property names';
    1.12 +var actual = '';
    1.13 +var expect = 'no error';
    1.14 +var status;
    1.15 +var object;
    1.16 +var result;
    1.17 +
    1.18 +printBugNumber(BUGNUMBER);
    1.19 +printStatus (summary);
    1.20 +
    1.21 +
    1.22 +if (typeof uneval != 'undefined')
    1.23 +{
    1.24 +  status = inSection(1) + ' eval(uneval({"if": false}))';
    1.25 +
    1.26 +  try
    1.27 +  {
    1.28 +    object = {'if': false };
    1.29 +    result = uneval(object);
    1.30 +    printStatus('uneval returns ' + result);
    1.31 +    eval(result);
    1.32 +    actual = 'no error';
    1.33 +  }
    1.34 +  catch(e)
    1.35 +  {
    1.36 +    actual = 'error';
    1.37 +  }
    1.38 + 
    1.39 +  reportCompare(expect, actual, status);
    1.40 +
    1.41 +  status = inSection(2) + ' eval(uneval({"if": "then"}))';
    1.42 +
    1.43 +  try
    1.44 +  {
    1.45 +    object = {'if': "then" };
    1.46 +    result = uneval(object);
    1.47 +    printStatus('uneval returns ' + result);
    1.48 +    eval(result);
    1.49 +    actual = 'no error';
    1.50 +  }
    1.51 +  catch(e)
    1.52 +  {
    1.53 +    actual = 'error';
    1.54 +  }
    1.55 + 
    1.56 +  reportCompare(expect, actual, status);
    1.57 +
    1.58 +  status = inSection(3) + ' eval(uneval(f))';
    1.59 +
    1.60 +  try
    1.61 +  {
    1.62 +    result = uneval(f);
    1.63 +    printStatus('uneval returns ' + result);
    1.64 +    eval(result);
    1.65 +    actual = 'no error';
    1.66 +  }
    1.67 +  catch(e)
    1.68 +  {
    1.69 +    actual = 'error';
    1.70 +  }
    1.71 + 
    1.72 +  reportCompare(expect, actual, status);
    1.73 +
    1.74 +  status = inSection(2) + ' eval(uneval(g))';
    1.75 +
    1.76 +  try
    1.77 +  {
    1.78 +    result = uneval(g);
    1.79 +    printStatus('uneval returns ' + result);
    1.80 +    eval(result);
    1.81 +    actual = 'no error';
    1.82 +  }
    1.83 +  catch(e)
    1.84 +  {
    1.85 +    actual = 'error';
    1.86 +  }
    1.87 + 
    1.88 +  reportCompare(expect, actual, status);
    1.89 +}
    1.90 +
    1.91 +function f()
    1.92 +{
    1.93 +  var obj = new Object();
    1.94 +
    1.95 +  obj['name']      = 'Just a name';
    1.96 +  obj['if']        = false;
    1.97 +  obj['some text'] = 'correct';
    1.98 +}
    1.99 +
   1.100 +function g()
   1.101 +{
   1.102 +  return {'if': "then"};
   1.103 +}
   1.104 +

mercurial