Correct scope of operator calls

- Enhance reflection module to indicate inheritance
  - Add ability to catch errors thrown from a eval
    inside of a script
This commit is contained in:
Jason Turner
2012-05-24 19:25:29 -06:00
parent f65e095e4d
commit 4233d21e5b
5 changed files with 42 additions and 17 deletions

View File

@@ -1,14 +1,8 @@
def `+`(x, y)
{
print(i);
load_module("reflection")
try {
eval("def `+`(x, y) \n { \n print(i); \n } \n \n var i = 10; \n \"1\" + 1;\n")
assert_false(true); // we should never get here
} catch (e) {
assert_equal("Error: \"Can not find object: i\" ", e.what());
}
auto i = 10;
// It should fail because `+` should not be able to see the i
"1" + 1;
assert_false(true);

View File

@@ -5,7 +5,7 @@ def assert_equal(x, y)
// Passes
} else {
// Fails
print("assert_equal failure: got " + to_string(y) + " expected " + to_string(x));
print("assert_equal failure: got '" + to_string(y) + "' expected '" + to_string(x) + "'");
exit(-1);
}
}