| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
gTestfile = '11.2.1.js'; |
| 8 |
|
| 9 |
START("11.2.1 - Property Accessors"); |
| 10 |
|
| 11 |
order = |
| 12 |
<order id="123456" timestamp="Mon Mar 10 2003 16:03:25 GMT-0800 (PST)"> |
| 13 |
<customer> |
| 14 |
<firstname>John</firstname> |
| 15 |
<lastname>Doe</lastname> |
| 16 |
</customer> |
| 17 |
<item> |
| 18 |
<description>Big Screen Television</description> |
| 19 |
<price>1299.99</price> |
| 20 |
<quantity>1</quantity> |
| 21 |
</item> |
| 22 |
</order>; |
| 23 |
|
| 24 |
correct = |
| 25 |
<customer> |
| 26 |
<firstname>John</firstname> |
| 27 |
<lastname>Doe</lastname> |
| 28 |
</customer>; |
| 29 |
|
| 30 |
TEST(1, correct, order.customer); |
| 31 |
TEST_XML(2, 123456, order.@id); |
| 32 |
|
| 33 |
correct = |
| 34 |
<item> |
| 35 |
<description>Big Screen Television</description> |
| 36 |
<price>1299.99</price> |
| 37 |
<quantity>1</quantity> |
| 38 |
</item> |
| 39 |
|
| 40 |
TEST(3, correct, order.children()[1]); |
| 41 |
|
| 42 |
correct = |
| 43 |
<customer> |
| 44 |
<firstname>John</firstname> |
| 45 |
<lastname>Doe</lastname> |
| 46 |
</customer> + |
| 47 |
<item> |
| 48 |
<description>Big Screen Television</description> |
| 49 |
<price>1299.99</price> |
| 50 |
<quantity>1</quantity> |
| 51 |
</item>; |
| 52 |
|
| 53 |
|
| 54 |
TEST(4, correct, order.*); |
| 55 |
|
| 56 |
correct = new XMLList(); |
| 57 |
correct += new XML("123456"); |
| 58 |
correct += new XML("Mon Mar 10 2003 16:03:25 GMT-0800 (PST)"); |
| 59 |
TEST(5, correct, order.@*); |
| 60 |
|
| 61 |
order = <order> |
| 62 |
<customer> |
| 63 |
<firstname>John</firstname> |
| 64 |
<lastname>Doe</lastname> |
| 65 |
</customer> |
| 66 |
<item id="3456"> |
| 67 |
<description>Big Screen Television</description> |
| 68 |
<price>1299.99</price> |
| 69 |
<quantity>1</quantity> |
| 70 |
</item> |
| 71 |
<item id="56789"> |
| 72 |
<description>DVD Player</description> |
| 73 |
<price>399.99</price> |
| 74 |
<quantity>1</quantity> |
| 75 |
</item> |
| 76 |
</order>; |
| 77 |
|
| 78 |
correct = |
| 79 |
<description>Big Screen Television</description> + |
| 80 |
<description>DVD Player</description>; |
| 81 |
|
| 82 |
TEST(6, correct, order.item.description); |
| 83 |
|
| 84 |
correct = new XMLList(); |
| 85 |
correct += new XML("3456"); |
| 86 |
correct += new XML("56789"); |
| 87 |
TEST(7, correct, order.item.@id); |
| 88 |
|
| 89 |
correct = |
| 90 |
<item id="56789"> |
| 91 |
<description>DVD Player</description> |
| 92 |
<price>399.99</price> |
| 93 |
<quantity>1</quantity> |
| 94 |
</item> |
| 95 |
|
| 96 |
TEST(8, correct, order.item[1]); |
| 97 |
|
| 98 |
correct = |
| 99 |
<description>Big Screen Television</description> + |
| 100 |
<price>1299.99</price> + |
| 101 |
<quantity>1</quantity> + |
| 102 |
<description>DVD Player</description> + |
| 103 |
<price>399.99</price> + |
| 104 |
<quantity>1</quantity>; |
| 105 |
|
| 106 |
TEST(9, correct, order.item.*); |
| 107 |
|
| 108 |
correct= |
| 109 |
<price>1299.99</price>; |
| 110 |
|
| 111 |
TEST(10, correct, order.item.*[1]); |
| 112 |
|
| 113 |
|
| 114 |
order = <order> |
| 115 |
<customer> |
| 116 |
<firstname>John</firstname> |
| 117 |
<lastname>Doe</lastname> |
| 118 |
</customer> |
| 119 |
<item id="3456"> |
| 120 |
<description>Big Screen Television</description> |
| 121 |
<price>1299.99</price> |
| 122 |
<quantity>1</quantity> |
| 123 |
</item> |
| 124 |
<item id="56789"> |
| 125 |
<description>DVD Player</description> |
| 126 |
<price>399.99</price> |
| 127 |
<quantity>1</quantity> |
| 128 |
</item> |
| 129 |
</order>; |
| 130 |
|
| 131 |
|
| 132 |
TEST(11, order, order[0]); |
| 133 |
|
| 134 |
|
| 135 |
TEST(12, undefined, order[1]); |
| 136 |
|
| 137 |
END(); |