| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 gTestfile = 'regress-68498-003.js'; |
| 21 | var BUGNUMBER = 68498; |
| 22 | var summary = 'Testing calling obj.eval(str)'; |
| 23 | var statprefix = '; currently at expect['; |
| 24 | var statsuffix = '] within test -'; |
| 25 | var actual = [ ]; |
| 26 | var expect = [ ]; |
| 27 | |
| 28 | |
| 29 | // Capture a reference to the global object - |
| 30 | var self = this; |
| 31 | |
| 32 | // This function is the heart of the test - |
| 33 | function f(s) {self.eval(s); return y;} |
| 34 | |
| 35 | |
| 36 | // Set the actual-results array - |
| 37 | actual[0] = f('var y = 43'); |
| 38 | actual[1] = 'y' in self && y; |
| 39 | actual[2] = delete y; |
| 40 | actual[3] = 'y' in self; |
| 41 | |
| 42 | // Set the expected-results array - |
| 43 | expect[0] = 43; |
| 44 | expect[1] = 43; |
| 45 | expect[2] = true; |
| 46 | expect[3] = false; |
| 47 | |
| 48 | |
| 49 | //------------------------------------------------------------------------------------------------- |
| 50 | test(); |
| 51 | //------------------------------------------------------------------------------------------------- |
| 52 | |
| 53 | |
| 54 | function test() |
| 55 | { |
| 56 | enterFunc ('test'); |
| 57 | printBugNumber(BUGNUMBER); |
| 58 | printStatus (summary); |
| 59 | |
| 60 | for (var i in expect) |
| 61 | { |
| 62 | reportCompare(expect[i], actual[i], getStatus(i)); |
| 63 | } |
| 64 | |
| 65 | exitFunc ('test'); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | function getStatus(i) |
| 70 | { |
| 71 | return (summary + statprefix + i + statsuffix); |
| 72 | } |