|
1 // Copyright 2009 the Sputnik authors. All rights reserved. |
|
2 // This code is governed by the BSD license found in the LICENSE file. |
|
3 |
|
4 /** |
|
5 * An Object is an unordered collection of properties |
|
6 * |
|
7 * @path ch08/8.6/S8.6_A4_T1.js |
|
8 * @description Simple using a few custom properties |
|
9 */ |
|
10 |
|
11 /////////////////////////////////////////////////////// |
|
12 // CHECK#1 |
|
13 var obj = {bar:true, some:1, foo:"a"}; |
|
14 |
|
15 var count=0; |
|
16 |
|
17 for (property in obj) count++; |
|
18 |
|
19 if (count !== 3){ |
|
20 $ERROR('#1: obj = {bar:true, some:1, foo:"a"}; count=0; for (property in obj) count++; count === 3. Actual: ' + (count)); |
|
21 } |
|
22 // |
|
23 //////////////////////////////////////////////////////// |
|
24 |
|
25 /////////////////////////////////////////////////////// |
|
26 // CHECK#2 |
|
27 var obj_ = {bar:true}; |
|
28 obj_.some = 1; |
|
29 obj_.foo = "a"; |
|
30 |
|
31 count=0; |
|
32 |
|
33 for (property in obj_) count++; |
|
34 |
|
35 if (count !== 3){ |
|
36 $ERROR('#2: obj_ = {bar:true}; obj_.some = 1; obj_.foo = "a"; count=0; for (property in obj_) count++; count === 3. Actual: ' + (count)); |
|
37 } |
|
38 // |
|
39 //////////////////////////////////////////////////////// |
|
40 |
|
41 /////////////////////////////////////////////////////// |
|
42 // CHECK#3 |
|
43 var obj__ = new Object(); |
|
44 obj__.bar = true; |
|
45 obj__.some = 1; |
|
46 obj__.foo = "a"; |
|
47 |
|
48 count=0; |
|
49 |
|
50 for (property in obj__) count++; |
|
51 |
|
52 if (count !== 3){ |
|
53 $ERROR('#3: obj__ = new Object(); obj__.bar = true; obj__.some = 1; obj__.foo = "a"; for (property in obj__) count++; count === 3. Actual: ' + (count)); |
|
54 } |
|
55 // |
|
56 //////////////////////////////////////////////////////// |
|
57 |