aboutsummaryrefslogtreecommitdiff
path: root/test/message
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-07-28 14:00:27 -0700
committerisaacs <i@izs.me>2012-07-30 08:21:39 -0700
commitb3cf3f35fcf192c717e7a393fb984bf6f879d0cc (patch)
tree2272eb5e82f700ffd83afe2b167aab50d085f75a /test/message
parent72bc4dcda4cfa99ed064419e40d104bd1b2e0e25 (diff)
downloadandroid-node-v8-b3cf3f35fcf192c717e7a393fb984bf6f879d0cc.tar.gz
android-node-v8-b3cf3f35fcf192c717e7a393fb984bf6f879d0cc.tar.bz2
android-node-v8-b3cf3f35fcf192c717e7a393fb984bf6f879d0cc.zip
Report errors properly from --eval and stdin
Diffstat (limited to 'test/message')
-rw-r--r--test/message/eval_messages.js53
-rw-r--r--test/message/eval_messages.out58
2 files changed, 111 insertions, 0 deletions
diff --git a/test/message/eval_messages.js b/test/message/eval_messages.js
new file mode 100644
index 0000000000..d03c0eb1b1
--- /dev/null
+++ b/test/message/eval_messages.js
@@ -0,0 +1,53 @@
+
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// 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.
+
+var common = require('../common');
+var assert = require('assert');
+
+var spawn = require('child_process').spawn;
+
+function run(cmd, strict, cb) {
+ var args = [];
+ if (strict) args.push('--use_strict');
+ args.push('-pe', cmd);
+ var child = spawn(process.execPath, args);
+ child.stdout.pipe(process.stdout);
+ child.stderr.pipe(process.stdout);
+ child.on('close', cb);
+}
+
+var queue =
+ [ 'with(this){__filename}',
+ '42',
+ 'throw new Error("hello")',
+ 'var x = 100; y = x;',
+ 'var ______________________________________________; throw 10' ];
+
+function go() {
+ var c = queue.shift();
+ if (!c) return console.log('done');
+ run(c, false, function() {
+ run(c, true, go);
+ });
+}
+
+go();
diff --git a/test/message/eval_messages.out b/test/message/eval_messages.out
new file mode 100644
index 0000000000..f56bbdbddb
--- /dev/null
+++ b/test/message/eval_messages.out
@@ -0,0 +1,58 @@
+[eval]
+
+[eval]:1
+with(this){__filename}
+^^^^
+SyntaxError: Strict mode code may not include a with statement
+ at Object.<anonymous> ([eval]-wrapper:6:22)
+ at Module._compile (module.js:449:26)
+ at evalScript (node.js:282:25)
+ at startup (node.js:76:7)
+ at node.js:623:3
+42
+42
+
+[eval]:1
+throw new Error("hello")
+ ^
+Error: hello
+ at [eval]:1:7
+ at Object.<anonymous> ([eval]-wrapper:6:22)
+ at Module._compile (module.js:449:26)
+ at evalScript (node.js:282:25)
+ at startup (node.js:76:7)
+ at node.js:623:3
+
+[eval]:1
+throw new Error("hello")
+ ^
+Error: hello
+ at [eval]:1:7
+ at Object.<anonymous> ([eval]-wrapper:6:22)
+ at Module._compile (module.js:449:26)
+ at evalScript (node.js:282:25)
+ at startup (node.js:76:7)
+ at node.js:623:3
+100
+
+[eval]:1
+var x = 100; y = x;
+ ^
+ReferenceError: y is not defined
+ at [eval]:1:16
+ at Object.<anonymous> ([eval]-wrapper:6:22)
+ at Module._compile (module.js:449:26)
+ at evalScript (node.js:282:25)
+ at startup (node.js:76:7)
+ at node.js:623:3
+
+[eval]:1
+var ______________________________________________; throw 10
+ ^
+10
+
+[eval]:1
+var ______________________________________________; throw 10
+ ^
+10
+done