Add test-process-simple.js
authorRyan <ry@tinyclouds.org>
Sun, 21 Jun 2009 11:57:23 +0000 (13:57 +0200)
committerRyan <ry@tinyclouds.org>
Sun, 21 Jun 2009 12:02:01 +0000 (14:02 +0200)
test/test-process-simple.js [new file with mode: 0644]

diff --git a/test/test-process-simple.js b/test/test-process-simple.js
new file mode 100644 (file)
index 0000000..b2babfc
--- /dev/null
@@ -0,0 +1,26 @@
+include("mjsunit.js");
+
+var cat = new node.Process("cat");
+
+var response = "";
+var exit_status = -1;
+
+cat.onOutput = function (chunk) {
+  if (chunk) response += chunk;
+  if (response === "hello world") cat.close();
+};
+cat.onError = function (chunk) {
+  assertEquals(null, chunk);
+};
+cat.onExit = function (status) { exit_status = status; };
+
+function onLoad () {
+  cat.write("hello");
+  cat.write(" ");
+  cat.write("world");
+}
+
+function onExit () {
+  assertEquals(0, exit_status);
+  assertEquals("hello world", response);
+}