Chromium Code Reviews| Index: test/cctest/test-global-object.cc |
| diff --git a/test/mjsunit/regress/regress-2499.js b/test/cctest/test-global-object.cc |
| similarity index 65% |
| copy from test/mjsunit/regress/regress-2499.js |
| copy to test/cctest/test-global-object.cc |
| index 52aad874db6fcdc89f5ee1ae4db45304e64b0e77..049b53d117b61f7b918fca9e6e368aca6520ebb7 100644 |
| --- a/test/mjsunit/regress/regress-2499.js |
| +++ b/test/cctest/test-global-object.cc |
| @@ -25,16 +25,29 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// Flags: --allow-natives-syntax |
| +#include "v8.h" |
| -function foo(word, nBits) { |
| - return (word[1] >>> nBits) | (word[0] << (32 - nBits)); |
| -} |
| +#include "cctest.h" |
| -word = [0x1001, 0]; |
| +using namespace v8; |
| -var expected = foo(word, 1); |
| -foo(word, 1); |
| -%OptimizeFunctionOnNextCall(foo); |
| -var optimized = foo(word, 1); |
| -assertEquals(expected, optimized) |
| +// This test fails if properties on the prototype of the global object appear |
| +// as declared globals. |
| +TEST(StrictUndeclaredGlobalVariable) { |
| + HandleScope scope; |
| + v8::Local<v8::String> var_name = v8_str("x"); |
| + v8::Local<v8::String> result_name = v8_str("z"); |
| + LocalContext context; |
| + v8::Local<v8::Script> script = |
| + v8_compile("\"use strict\";" |
| + "var z;" |
| + "try { x = 42; z = 10; } catch (e) { z = 20; };"); |
|
Jakob Kummerow
2013/01/23 15:51:25
Would be nice to assert that we're getting the rig
Toon Verwaest
2013/01/23 16:03:53
Done.
|
| + v8::Handle<v8::Object> proto = v8::Object::New(); |
| + v8::Handle<v8::Object> global = |
| + context->Global()->GetPrototype().As<v8::Object>(); |
| + proto->Set(var_name, v8_num(100)); |
| + global->SetPrototype(proto); |
| + script->Run(); |
| + v8::Local<v8::Value> result = context->Global()->Get(result_name); |
| + CHECK_EQ(20, result->Int32Value()); |
| +} |