| 1 |
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ |
| 2 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 |
|
| 6 |
/* |
| 7 |
* Date: 15 Feb 2001 |
| 8 |
* |
| 9 |
* SUMMARY: calling obj.eval(str) |
| 10 |
* |
| 11 |
* See http://bugzilla.mozilla.org/show_bug.cgi?id=68498 |
| 12 |
* See http://bugzilla.mozilla.org/showattachment.cgi?attach_id=25251 |
| 13 |
* |
| 14 |
* Brendan: |
| 15 |
* |
| 16 |
* "Backward compatibility: support calling obj.eval(str), which evaluates |
| 17 |
* str using obj as the scope chain and variable object." |
| 18 |
*/ |
| 19 |
//----------------------------------------------------------------------------- |
| 20 |
var BUGNUMBER = 68498; |
| 21 |
var summary = 'Testing calling obj.eval(str)'; |
| 22 |
var statprefix = '; currently at expect['; |
| 23 |
var statsuffix = '] within test -'; |
| 24 |
var actual = [ ]; |
| 25 |
var expect = [ ]; |
| 26 |
|
| 27 |
|
| 28 |
// Capture a reference to the global object - |
| 29 |
var self = this; |
| 30 |
|
| 31 |
// This function is the heart of the test - |
| 32 |
function f(s) {self.eval(s); return y;} |
| 33 |
|
| 34 |
|
| 35 |
// Set the actual-results array - |
| 36 |
actual[0] = f('var y = 43'); |
| 37 |
actual[1] = 'y' in self && y; |
| 38 |
actual[2] = delete y; |
| 39 |
actual[3] = 'y' in self; |
| 40 |
|
| 41 |
// Set the expected-results array - |
| 42 |
expect[0] = 43; |
| 43 |
expect[1] = 43; |
| 44 |
expect[2] = true; |
| 45 |
expect[3] = false; |
| 46 |
|
| 47 |
|
| 48 |
//------------------------------------------------------------------------------------------------- |
| 49 |
test(); |
| 50 |
//------------------------------------------------------------------------------------------------- |
| 51 |
|
| 52 |
|
| 53 |
function test() |
| 54 |
{ |
| 55 |
printBugNumber(BUGNUMBER); |
| 56 |
printStatus (summary); |
| 57 |
|
| 58 |
for (var i in expect) |
| 59 |
{ |
| 60 |
reportCompare(expect[i], actual[i], getStatus(i)); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
function getStatus(i) |
| 66 |
{ |
| 67 |
return (summary + statprefix + i + statsuffix); |
| 68 |
} |