Debian Codegraph @

js/src/tests/test262/language/statements/for-in/12.6.4-1.js

raw
1 // Copyright (c) 2012 Ecma International. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 es5id: 12.6.4-1
6 description: >
7 The for-in Statement - a property name must not be visited more
8 than once in any enumeration.
9 ---*/
10
11 var obj = { prop1: "abc", prop2: "bbc", prop3: "cnn" };
12
13 var countProp1 = 0;
14 var countProp2 = 0;
15 var countProp3 = 0;
16
17 for (var p in obj) {
18 if (obj.hasOwnProperty(p)) {
19 if (p === "prop1") {
20 countProp1++;
21 }
22 if (p === "prop2") {
23 countProp2++;
24 }
25 if (p === "prop3") {
26 countProp3++;
27 }
28 }
29 }
30
31 assert.sameValue(countProp1, 1, 'countProp1');
32 assert.sameValue(countProp2, 1, 'countProp2');
33 assert.sameValue(countProp3, 1, 'countProp3');
34
35 reportCompare(0, 0);