Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/scope-001.js

raw symbols SCIP
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 var gTestfile = 'scope-001.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = '53268';
9 var status = 'Testing scope after changing obj.__proto__';
10 var expect= '';
11 var actual = '';
12 var obj = {};
13 const five = 5;
14
15
16 //-----------------------------------------------------------------------------
17 test();
18 //-----------------------------------------------------------------------------
19
20
21 function test()
22 {
23 enterFunc ("test");
24 printBugNumber(BUGNUMBER);
25 printStatus (status);
26
27
28 status= 'Step 1: setting obj.__proto__ = global object';
29 obj.__proto__ = this;
30
31 actual = obj.five;
32 expect=5;
33 reportCompare (expect, actual, status);
34
35 obj.five=1;
36 actual = obj.five;
37 expect=5;
38 reportCompare (expect, actual, status);
39
40
41
42 status= 'Step 2: setting obj.__proto__ = null';
43 obj.__proto__ = null;
44
45 actual = obj.five;
46 expect=undefined;
47 reportCompare (expect, actual, status);
48
49 obj.five=2;
50 actual = obj.five;
51 expect=2;
52 reportCompare (expect, actual, status);
53
54
55
56 status= 'Step 3: setting obj.__proto__ to global object again';
57 obj.__proto__ = this;
58
59 actual = obj.five;
60 expect=2; //<--- (FROM STEP 2 ABOVE)
61 reportCompare (expect, actual, status);
62
63 obj.five=3;
64 actual = obj.five;
65 expect=3;
66 reportCompare (expect, actual, status);
67
68
69
70 status= 'Step 4: setting obj.__proto__ to null again';
71 obj.__proto__ = null;
72
73 actual = obj.five;
74 expect=3; //<--- (FROM STEP 3 ABOVE)
75 reportCompare (expect, actual, status);
76
77 obj.five=4;
78 actual = obj.five;
79 expect=4;
80 reportCompare (expect, actual, status);
81
82
83 exitFunc ("test");
84 }