<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="console"></div>

<script>

doc = (new DOMParser).parseFromString("<root num0='0' num2='2' num4='4'><egg1>egg1</egg1><egg2>egg2</egg2></root>", "application/xml");

shouldBe('doc.evaluate("3.14 < -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("3.14 <= -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("3.14 > -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("3.14 >= 3.14", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("number(\'NaN\') < -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("number(\'NaN\') <= -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("number(\'NaN\') > -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("number(\'NaN\') >= 3.14", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/root/@num2 <= /root/@num2", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/root/@num2 >= /root/@num2", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/root/@num0 <= /root/@num2", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/root/@num0 >= /root/@num2", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/root/@num4 <= /root/@num2", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/root/@num4 >= /root/@num2", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');

shouldBe('doc.evaluate("\'3.14\' = \'3.14\'", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("\'3.14\' = \'Hi\'", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("\'3.14\' != -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("number(\'NaN\') = \'Hi\'", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("number(\'NaN\') != -4", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("number(\'NaN\')  = number(\'NaN\')", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("number(\'NaN\') != number(\'NaN\')", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/empty  = true()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/empty != true()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/empty  = false()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/empty != false()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/empty  = /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/empty != /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/root/*[1]  = /empty", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/root/*[1] != /empty", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("/root/*[1]  = /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("/root/*[1] != /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("\'egg1\'  = /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("\'egg1\' != /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("\'egg2\'  = /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("\'egg2\' != /root/*[1]", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("\'egg1\'  = /root/*", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
// Yeah, non-intuitive, but true acc to XPath spec 3.4
shouldBe('doc.evaluate("\'egg1\' != /root/*", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');

shouldBe('doc.evaluate("true() and true()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("true() and false()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("false() and true()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("false() and false()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');
shouldBe('doc.evaluate("true() or false()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("false() or true()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("true() or true()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'true');
shouldBe('doc.evaluate("false() or false()", doc, null, XPathResult.BOOLEAN_TYPE, null).booleanValue', 'false');

</script>
<script src="../../../../resources/js-test-post.js"></script>
</body>
</html>
