node/test/mjsunit/test-process-simple.js

29 lines
572 B
JavaScript
Raw Normal View History

2009-06-21 19:57:23 +08:00
include("mjsunit.js");
var cat = new node.Process("cat");
var response = "";
var exit_status = -1;
2009-06-29 19:18:30 +08:00
cat.addListener("output", function (chunk) {
2009-06-21 20:07:52 +08:00
if (chunk) {
response += chunk;
if (response === "hello world") cat.close();
}
2009-06-28 02:40:43 +08:00
});
2009-06-29 19:18:30 +08:00
cat.addListener("error", function (chunk) {
2009-06-21 19:57:23 +08:00
assertEquals(null, chunk);
2009-06-28 02:40:43 +08:00
});
2009-06-29 19:18:30 +08:00
cat.addListener("exit", function (status) { exit_status = status; });
2009-06-21 19:57:23 +08:00
function onLoad () {
cat.write("hello");
cat.write(" ");
cat.write("world");
}
function onExit () {
assertEquals(0, exit_status);
assertEquals("hello world", response);
}