| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
gTestfile = '13.4.4.10.js'; |
| 8 |
|
| 9 |
var nTest = 0; |
| 10 |
|
| 11 |
START("13.4.4.10 - XML contains()"); |
| 12 |
|
| 13 |
TEST(++nTest, true, XML.prototype.hasOwnProperty("contains")); |
| 14 |
|
| 15 |
emps = |
| 16 |
<employees> |
| 17 |
<employee id="0"><name>Jim</name><age>25</age></employee> |
| 18 |
<employee id="1"><name>Joe</name><age>20</age></employee> |
| 19 |
</employees>; |
| 20 |
|
| 21 |
TEST(++nTest, true, emps.contains(emps)); |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
expect = 'gods.contains(\'Kibo\')==false && (gods==\'Kibo\')==false'; |
| 26 |
|
| 27 |
var gods = <gods> |
| 28 |
<god>Kibo</god> |
| 29 |
<god>Xibo</god> |
| 30 |
</gods>; |
| 31 |
|
| 32 |
printStatus('XML markup is:\r\n' + gods.toXMLString()); |
| 33 |
|
| 34 |
var string = 'Kibo'; |
| 35 |
actual = 'gods.contains(\'' + string + '\')==' + gods.contains(string); |
| 36 |
actual += ' && '; |
| 37 |
actual += '(gods==\'' + string + '\')==' + (gods == string); |
| 38 |
|
| 39 |
TEST(++nTest, expect, actual); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
function containsTest(xmlObject, value) |
| 44 |
{ |
| 45 |
var comparison = (xmlObject == value); |
| 46 |
var containsCheck = xmlObject.contains(value); |
| 47 |
var result = (comparison == containsCheck); |
| 48 |
|
| 49 |
printStatus('Comparing ' + xmlObject.nodeKind() + |
| 50 |
' against ' + (typeof value) + ':'); |
| 51 |
|
| 52 |
printStatus('==: ' + comparison + '; contains: ' + containsCheck + |
| 53 |
'; check ' + (result ? 'passed' : 'failed')); |
| 54 |
return result; |
| 55 |
} |
| 56 |
|
| 57 |
actual = containsTest(new XML('Kibo'), 'Kibo'); |
| 58 |
TEST(++nTest, true, actual); |
| 59 |
|
| 60 |
actual = containsTest(<god>Kibo</god>, 'Kibo'); |
| 61 |
TEST(++nTest, true, actual); |
| 62 |
|
| 63 |
END(); |