Debian Codegraph @

rhino/testsrc/tests/ecma_3/Statements/12.6.3.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 = '12.6.3.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 292731;
9 var summary = 'for-in should not call valueOf method';
10 var actual = '';
11 var expect = '';
12 var i;
13
14 printBugNumber(BUGNUMBER);
15 printStatus (summary);
16
17 function MyObject()
18 {
19 }
20
21 MyObject.prototype.valueOf = function()
22 {
23 actual += 'MyObject.prototype.valueOf called. ';
24 }
25
26 var myobject = new MyObject();
27
28 var myfunction = new function()
29 {
30 this.valueOf = function()
31 {
32 actual += 'this.valueOf called. ';
33 }
34 }
35
36 actual = '';
37 for (i in myobject)
38 {
39 //calls valueOf
40 }
41 reportCompare(expect, actual, 'for-in custom object');
42
43 actual = '';
44 for (i in myfunction)
45 {
46 //calls valueOf
47 }
48 reportCompare(expect, actual, 'for-in function expression');