2010-03-09 07:06:29 +08:00
|
|
|
require("../common.js");
|
2009-09-28 18:36:36 +08:00
|
|
|
http = require("/http.js");
|
2009-06-21 22:40:08 +08:00
|
|
|
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log("hello world");
|
2009-08-25 02:25:24 +08:00
|
|
|
|
2009-06-21 22:40:08 +08:00
|
|
|
var body = "exports.A = function() { return 'A';}";
|
2009-09-28 18:36:36 +08:00
|
|
|
var server = http.createServer(function (req, res) {
|
2010-06-24 08:40:51 +08:00
|
|
|
console.log("req?");
|
2009-08-25 02:25:24 +08:00
|
|
|
res.sendHeader(200, {
|
|
|
|
"Content-Length": body.length,
|
|
|
|
"Content-Type": "text/plain"
|
|
|
|
});
|
2009-06-21 22:40:08 +08:00
|
|
|
res.sendBody(body);
|
|
|
|
res.finish();
|
|
|
|
});
|
2010-07-16 02:47:25 +08:00
|
|
|
server.listen(common.PORT);
|
2009-06-21 22:40:08 +08:00
|
|
|
|
2009-06-29 01:05:58 +08:00
|
|
|
var errors = 0;
|
|
|
|
var successes = 0;
|
|
|
|
|
2010-07-16 02:47:25 +08:00
|
|
|
var promise = process.cat("http://localhost:"+common.PORT, "utf8");
|
2009-06-29 01:05:58 +08:00
|
|
|
|
2009-08-27 00:22:00 +08:00
|
|
|
promise.addCallback(function (content) {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(body, content);
|
2009-08-27 00:22:00 +08:00
|
|
|
server.close();
|
|
|
|
successes += 1;
|
|
|
|
});
|
2009-06-29 01:05:58 +08:00
|
|
|
|
2009-08-27 00:22:00 +08:00
|
|
|
promise.addErrback(function () {
|
|
|
|
errors += 1;
|
|
|
|
});
|
|
|
|
|
2009-10-30 06:59:35 +08:00
|
|
|
var dirname = process.path.dirname(__filename);
|
|
|
|
var fixtures = process.path.join(dirname, "fixtures");
|
|
|
|
var x = process.path.join(fixtures, "x.txt");
|
2009-08-27 00:22:00 +08:00
|
|
|
|
2009-10-30 06:59:35 +08:00
|
|
|
promise = process.cat(x, "utf8");
|
2009-08-27 00:22:00 +08:00
|
|
|
|
|
|
|
promise.addCallback(function (content) {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal("xyz", content.replace(/[\r\n]/, ''));
|
2009-08-27 00:22:00 +08:00
|
|
|
successes += 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
promise.addErrback(function () {
|
|
|
|
errors += 1;
|
|
|
|
});
|
2009-06-29 01:05:58 +08:00
|
|
|
|
2009-08-27 00:51:04 +08:00
|
|
|
process.addListener("exit", function () {
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(2, successes);
|
|
|
|
assert.equal(0, errors);
|
2009-08-27 00:51:04 +08:00
|
|
|
});
|