Browse files

script.runIn*Context not throwing errors properly.

  • Loading branch information...
1 parent 7d0252e commit f1a4f17897c420295dafd703dda3abe0a50fc4ed @ry ry committed Jun 19, 2010
View
2 src/node_script.cc
@@ -166,7 +166,7 @@ Handle<Value> node::Script::EvalMachine(const Arguments& args) {
}
}
if (result.IsEmpty()) {
- result = ThrowException(try_catch.Exception());
+ return try_catch.ReThrow();
} else if (cFlag == newContext) {
// success! copy changes back onto the sandbox object.
keys = context->Global()->GetPropertyNames();
View
2 test/message/testcfg.py
@@ -63,7 +63,7 @@ def IsFailureOutput(self, output):
pattern = '^%s$' % pattern
patterns.append(pattern)
# Compare actual output with the expected
- raw_lines = output.stdout.split('\n')
+ raw_lines = (output.stdout + output.stderr).split('\n')
outlines = [ s for s in raw_lines if not self.IgnoreLine(s) ]
if len(outlines) != len(patterns):
return True
View
11 test/message/undefined_reference_in_new_context.js
@@ -0,0 +1,11 @@
+require('../common');
+
+error('before');
+
+var Script = process.binding('evals').Script;
+
+// undefined reference
+script = new Script('foo.bar = 5;');
+script.runInNewContext();
+
+error('after');
View
14 test/message/undefined_reference_in_new_context.out
@@ -0,0 +1,14 @@
+before
+
+
+/Users/ryan/projects/node/test/message/undefined_reference_in_new_context.js:9
+script.runInNewContext();
+ ^
+ReferenceError: foo is not defined
+ at evalmachine.<anonymous>:1:1
+ at Object.<anonymous> (/Users/ryan/projects/node/test/message/undefined_reference_in_new_context.js:9:8)
+ at Module._compile (module:384:23)
+ at Module._loadScriptSync (module:393:8)
+ at Module.loadSync (module:296:10)
+ at Object.runMain (module:447:22)
+ at node.js:208:10
View
16 test/simple/test-script-new.js
@@ -15,6 +15,22 @@ assert.throws(function() {
script.runInNewContext();
});
+
+
+debug('undefined reference');
+var error;
+script = new Script('foo.bar = 5;');
+try {
+ script.runInNewContext();
+} catch (e) {
+ error = e;
+}
+assert.ok(error);
+assert.ok(error.message.indexOf('not defined') >= 0);
+
+debug('error.message: ' + error.message);
+
+
hello = 5;
script = new Script('hello = 2');
script.runInNewContext();

0 comments on commit f1a4f17

Please sign in to comment.