Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
239 lines (227 sloc) 8.586 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Copyright 2010 - 2012, Chris Winberry <chris@winberry.net>. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Node.js HTML Parser</title>
<style type="text/css">
.testName {
font-weight: bold;
}
.pass {
color: #363;
}
.fail {
color: #633;
font-style: italic;
}
</style>
<script language="JavaScript">
if ((typeof JSON) != "object") {
var head = document.getElementsByTagName("head")[0];
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "json2.js";
head.insertBefore(script, head.firstChild)
}
</script>
<script language="JavaScript" src="lib/htmlparser.js"></script>
<script language="JavaScript" src="tests/testutils.js"></script>
<script language="JavaScript" src="tests/html.js"></script>
<script language="JavaScript" src="tests/parser.js"></script>
<script language="JavaScript" src="tests/rss.js"></script>
<!-- //TODO: dynamic loading of test files -->
</head>
<body style="font-size: small; font-family:Arial, Helvetica, sans-serif;">
<script language="JavaScript">
(function () {
function writeTest (name, result) {
document.write(
"<div>" +
"<span class='testName'>" + name + "</span>: " +
"<span class='" + (result ? 'pass' : 'fail') + "'>" + (result ? 'passed' : 'FAILED') + "</span>" +
"</div>"
);
}
var testResults = {};
Tautologistics.NodeHtmlParser.Tests.Utils.runBuilderTests(
Tautologistics.NodeHtmlParser.Tests.Html
, Tautologistics.NodeHtmlParser.Parser
, Tautologistics.NodeHtmlParser.HtmlBuilder
, null
, function (testName, testResult, actual, expected) {
// console.log("[" + testName + "]: " + (testResult ? "passed" : "FAILED"));
writeTest(testName, testResult);
}, function (elapsed, passed, failed) {
testResults['HTML builder'] = {
elapsed: elapsed
, passed: passed
, failed: failed
};
});
Tautologistics.NodeHtmlParser.Tests.Utils.runBuilderTests(
Tautologistics.NodeHtmlParser.Tests.Html
, Tautologistics.NodeHtmlParser.Parser
, Tautologistics.NodeHtmlParser.HtmlBuilder
, function (test) {
var newTest = {};
for (var key in test) {
if (!test.hasOwnProperty(key)) {
continue;
}
newTest[key] = (key === 'data') ?
test.data.join('').split('')
:
test[key]
;
}
return newTest;
}
, function (testName, testResult, actual, expected) {
// console.log("[" + testName + "]: " + (testResult ? "passed" : "FAILED"));
writeTest(testName, testResult);
}, function (elapsed, passed, failed) {
testResults['HTML builder (streamed)'] = {
elapsed: elapsed
, passed: passed
, failed: failed
};
});
Tautologistics.NodeHtmlParser.Tests.Utils.runBuilderTests(
Tautologistics.NodeHtmlParser.Tests.Rss
, Tautologistics.NodeHtmlParser.Parser
, Tautologistics.NodeHtmlParser.RssBuilder
, null
, function (testName, testResult, actual, expected) {
// console.log("[" + testName + "]: " + (testResult ? "passed" : "FAILED"));
writeTest(testName, testResult);
}, function (elapsed, passed, failed) {
testResults['RSS builder'] = {
elapsed: elapsed
, passed: passed
, failed: failed
};
});
Tautologistics.NodeHtmlParser.Tests.Utils.runBuilderTests(
Tautologistics.NodeHtmlParser.Tests.Rss
, Tautologistics.NodeHtmlParser.Parser
, Tautologistics.NodeHtmlParser.RssBuilder
, function (test) {
var newTest = {};
for (var key in test) {
if (!test.hasOwnProperty(key)) {
continue;
}
newTest[key] = (key === 'data') ?
test.data.join('').split('')
:
test[key]
;
}
return newTest;
}
, function (testName, testResult, actual, expected) {
// console.log("[" + testName + "]: " + (testResult ? "passed" : "FAILED"));
writeTest(testName, testResult);
}, function (elapsed, passed, failed) {
testResults['RSS builder (streamed)'] = {
elapsed: elapsed
, passed: passed
, failed: failed
};
});
Tautologistics.NodeHtmlParser.Tests.Utils.runParserTests(
Tautologistics.NodeHtmlParser.Tests.Parser
, Tautologistics.NodeHtmlParser.Parser
, null
, function (testName, testResult, actual, expected) {
// console.log("[" + testName + "]: " + (testResult ? "passed" : "FAILED"));
writeTest(testName, testResult);
}, function (elapsed, passed, failed) {
testResults['Parser'] = {
elapsed: elapsed
, passed: passed
, failed: failed
};
});
Tautologistics.NodeHtmlParser.Tests.Utils.runParserTests(
Tautologistics.NodeHtmlParser.Tests.Parser
, Tautologistics.NodeHtmlParser.Parser
, function (test) {
var newTest = {};
for (var key in test) {
if (!test.hasOwnProperty(key)) {
continue;
}
newTest[key] = (key === 'data') ?
test.data.join('').split('')
:
test[key]
;
}
return newTest;
}
, function (testName, testResult, actual, expected) {
// console.log("[" + testName + "]: " + (testResult ? "passed" : "FAILED"));
writeTest(testName, testResult);
}, function (elapsed, passed, failed) {
testResults['Parser (streamed)'] = {
elapsed: elapsed
, passed: passed
, failed: failed
};
});
document.write(
"<br>" +
'<h1>Test Results</h1>' +
'<hr>'
);
var passedTotal = 0;
var failedTotal = 0;
var elapsedTotal = 0;
for (var testName in testResults) {
if (!testResults.hasOwnProperty(testName)) {
continue;
}
var test = testResults[testName];
passedTotal += test.passed;
failedTotal += test.failed;
elapsedTotal += test.elapsed;
document.write(
"<div>" +
"<span class='testName'>" + testName + '</span>: ' +
"<span class='" + (test.failed === 0 ? 'pass' : 'fail') + "'>" +
test.passed + '/' + (test.passed + test.failed) +
' (' + Math.round(test.passed / (test.passed + test.failed) * 100) + '%) ' +
'[' + test.elapsed + 'ms]' +
"</span>" +
"</div>"
);
}
document.write(
'<hr>' +
'Total: ' + passedTotal + '/' + (passedTotal + failedTotal) +
' (' + Math.round(passedTotal / (passedTotal + failedTotal) * 100) + '%) ' +
'[' + elapsedTotal + 'ms]'
);
})();
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.