1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 File Name: 15.1.2.1-1.js
42 ECMA Section: 15.1.2.1 eval(x)
44 if x is not a string object, return x.
46 Author: christine@netscape.com
47 Date: 16 september 1997
49 var SECTION = "15.1.2.1-1";
50 var VERSION = "ECMA_1";
51 var TITLE = "eval(x)";
52 var BUGNUMBER = "none";
56 writeHeaderToLog( SECTION + " "+ TITLE);
58 new TestCase( SECTION, "eval.length", 1, eval.length );
59 new TestCase( SECTION, "delete eval.length", false, delete eval.length );
60 new TestCase( SECTION, "var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS", "", eval("var PROPS = ''; for ( p in eval ) { PROPS += p }; PROPS") );
61 new TestCase( SECTION, "eval.length = null; eval.length", 1, eval( "eval.length = null; eval.length") );
62 // new TestCase( SECTION, "eval.__proto__", Function.prototype, eval.__proto__ );
64 // test cases where argument is not a string. should return the argument.
66 new TestCase( SECTION, "eval()", void 0, eval() );
67 new TestCase( SECTION, "eval(void 0)", void 0, eval( void 0) );
68 new TestCase( SECTION, "eval(null)", null, eval( null ) );
69 new TestCase( SECTION, "eval(true)", true, eval( true ) );
70 new TestCase( SECTION, "eval(false)", false, eval( false ) );
72 new TestCase( SECTION, "typeof eval(new String('Infinity/-0')", "object", typeof eval(new String('Infinity/-0')) );
74 new TestCase( SECTION, "eval([1,2,3,4,5,6])", "1,2,3,4,5,6", ""+eval([1,2,3,4,5,6]) );
75 new TestCase( SECTION, "eval(new Array(0,1,2,3)", "1,2,3", ""+ eval(new Array(1,2,3)) );
76 new TestCase( SECTION, "eval(1)", 1, eval(1) );
77 new TestCase( SECTION, "eval(0)", 0, eval(0) );
78 new TestCase( SECTION, "eval(-1)", -1, eval(-1) );
79 new TestCase( SECTION, "eval(Number.NaN)", Number.NaN, eval(Number.NaN) );
80 new TestCase( SECTION, "eval(Number.MIN_VALUE)", 5e-308, eval(Number.MIN_VALUE) );
81 new TestCase( SECTION, "eval(-Number.MIN_VALUE)", -5e-308, eval(-Number.MIN_VALUE) );
82 new TestCase( SECTION, "eval(Number.POSITIVE_INFINITY)", Number.POSITIVE_INFINITY, eval(Number.POSITIVE_INFINITY) );
83 new TestCase( SECTION, "eval(Number.NEGATIVE_INFINITY)", Number.NEGATIVE_INFINITY, eval(Number.NEGATIVE_INFINITY) );
84 new TestCase( SECTION, "eval( 4294967296 )", 4294967296, eval(4294967296) );
85 new TestCase( SECTION, "eval( 2147483648 )", 2147483648, eval(2147483648) );