This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mb:43e80296-eff7-40a9-9da9-f1fc52c02fc0
- Loading branch information
Showing
5 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
var sys = require("sys"); | ||
require("http").createServer(function (_,res) { | ||
sys.debug("connect"); | ||
require("http").createServer(function (req,res) { | ||
sys.debug("from http server: connect"); | ||
res.sendHeader(200, {}); | ||
res.sendBody("hi"); | ||
for (var i in req.headers) { | ||
res.sendBody("\nHEADER "+i+": "+req.headers[i]+"\n"); | ||
} | ||
res.finish(); | ||
}).listen(8000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
|
||
var sys = require("sys"); | ||
function d (m, o) { | ||
sys.debug("\n----\n"+m + ": " + JSON.stringify(o, null, 2)+"\n----\n"); | ||
sys.debug(m); | ||
return; | ||
sys.debug("\n----\n"+m + ": " + sys.inspect(o)+"\n----\n"); | ||
} | ||
// d("before",module); | ||
|
||
module.setExports("this is ok"); | ||
module.exports = ("this is ok"); | ||
|
||
|
||
require("./b"); | ||
// d("after",module); | ||
d("after",module); | ||
try { | ||
module.setExports("but this isn't"); | ||
module.exports = ("but this isn't"); | ||
} catch (ex) { | ||
sys.debug("got an error trying to setExport: "+ex.message); | ||
} | ||
|
||
// d("done",module); | ||
d("done",module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
require("url"); | ||
|
||
var Promise = require("events").Promise, | ||
sys = require("sys"); | ||
|
||
Promise.prototype.test = function (fn) { | ||
return this.addCallback(function () { process.nextTick(fn) }); | ||
return this.addCallback(fn); | ||
}; | ||
|
||
function foo () { | ||
require("url"); | ||
var p = new Promise(); | ||
process.nextTick(function () { p.emitSuccess() }); | ||
return p; | ||
}; | ||
|
||
sys.debug("start"); | ||
foo().test(function () { | ||
sys.debug("cb 1"); | ||
sys.puts("1"); | ||
foo().addCallback(function () { | ||
sys.puts("callback 1") | ||
}); | ||
sys.debug("after attach 1"); | ||
foo().test(function () { | ||
sys.debug("cb 2"); | ||
sys.puts("2"); | ||
foo().addCallback(function () { | ||
sys.puts("callback 2") | ||
}); | ||
sys.puts("3"); | ||
foo().addCallback(function () { | ||
sys.puts("callback 3") | ||
}); | ||
sys.puts("4"); | ||
foo().addCallback(function () { | ||
sys.puts("callback 4") | ||
}); | ||
sys.puts("5"); | ||
foo().addCallback(function () { | ||
sys.puts("callback 5") | ||
}); | ||
sys.puts("6"); | ||
foo().addCallback(function () { | ||
sys.puts("callback 6") | ||
}); | ||
sys.debug("after attach 2"); | ||
|
||
// expect start, after attach 1, after attach 2, cb 1, cb 2 |