|
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 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 enterFunc ('test'); |
|
56 printBugNumber(BUGNUMBER); |
|
57 printStatus (summary); |
|
58 |
|
59 for (var i in expect) |
|
60 { |
|
61 reportCompare(expect[i], actual[i], getStatus(i)); |
|
62 } |
|
63 |
|
64 exitFunc ('test'); |
|
65 } |
|
66 |
|
67 |
|
68 function getStatus(i) |
|
69 { |
|
70 return (summary + statprefix + i + statsuffix); |
|
71 } |