3 Star 1 Fork 0

Gitee 极速下载/node-htmlparser

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/tautologistics/node-htmlparser
克隆/下载
runtests.html 8.38 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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/node-htmlparser.git
git@gitee.com:mirrors/node-htmlparser.git
mirrors
node-htmlparser
node-htmlparser
master

搜索帮助