blob: 2fc43983031763f41219918fb0c94376c022f455 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests the parser for points attribute values.");
var polyElement = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
function parsePoints(str, result)
{
polyElement.setAttributeNS(null, "points", " ");
polyElement.setAttributeNS(null, "points", str);
debug("Test string: '" + str + "'");
var len = polyElement.points.numberOfItems;
var points = "";
for (var i = 0; i < len; ++i) {
var p = polyElement.points.getItem(i);
if (i > 0) points += " ";
points = points + p.x + " " + p.y;
}
if (points === result) {
testPassed("'" + points + "' is '" + result + "'");
} else {
testFailed("'" + str + "' should be '" + result + "', but is '" + points + "'");
}
debug("");
}
parsePoints(" ", "");
parsePoints("10 10", "10 10");
parsePoints("10,10", "10 10");
parsePoints("10, 10", "10 10");
parsePoints("10 10 20 20", "10 10 20 20");
parsePoints("10, 10 20 20", "10 10 20 20");
parsePoints("10, 10, 20 20", "10 10 20 20");
parsePoints("10, 10, 20, 20", "10 10 20 20");
parsePoints("10, 10 20, 20", "10 10 20 20");
parsePoints("10 10, 20, 20", "10 10 20 20");
parsePoints("10 10 20, 20", "10 10 20 20");
parsePoints("10+10", "10 10");
parsePoints("10-10", "10 -10");
parsePoints("10,+10", "10 10");
parsePoints("10,-10", "10 -10");
parsePoints(" 10,10", "10 10");
parsePoints("10,10 ", "10 10");
parsePoints("10, 10", "10 10");
parsePoints("10 ,10", "10 10");
parsePoints("10 , 10", "10 10");
parsePoints(" 10,10", "10 10");
parsePoints("10,10 ", "10 10");
parsePoints("10, 10", "10 10");
parsePoints("10 ,10", "10 10");
parsePoints("10 , 10", "10 10");
debug('Strings that fail to parse, and hence parse as "".');
debug('');
parsePoints("a", "");
parsePoints("10", "");
parsePoints("10,", "");
parsePoints("10,,", "");
parsePoints("10,,10", "");
parsePoints("10,10,", "10 10");
parsePoints("10,10a", "10 10");
parsePoints(",10", "");
parsePoints(",10,", "");
parsePoints(",10,,", "");
parsePoints(",10,10", "");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>