OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3518 | 3518 |
3519 TEST(MaybeAssignedTopLevel) { | 3519 TEST(MaybeAssignedTopLevel) { |
3520 i::Isolate* isolate = CcTest::i_isolate(); | 3520 i::Isolate* isolate = CcTest::i_isolate(); |
3521 i::HandleScope scope(isolate); | 3521 i::HandleScope scope(isolate); |
3522 LocalContext env; | 3522 LocalContext env; |
3523 i::Factory* factory = isolate->factory(); | 3523 i::Factory* factory = isolate->factory(); |
3524 | 3524 |
3525 const char* prefixes[] = { | 3525 const char* prefixes[] = { |
3526 "let foo; ", "let foo = 0; ", | 3526 "let foo; ", "let foo = 0; ", |
3527 "let [foo] = [1]; ", "let {foo} = {foo: 2}; ", | 3527 "let [foo] = [1]; ", "let {foo} = {foo: 2}; ", |
3528 "let {foo=3} = {}; ", | 3528 "let {foo=3} = {}; ", "function foo() {}; ", |
| 3529 "var foo; ", "var foo = 0; ", |
| 3530 "var [foo] = [1]; ", "var {foo} = {foo: 2}; ", |
| 3531 "var {foo=3} = {}; ", "function* foo() {}; ", |
3529 }; | 3532 }; |
3530 const char* sources[] = { | 3533 const char* sources[] = { |
3531 "function bar() {foo = 42}; ext(bar); ext(foo)", | 3534 "function bar() {foo = 42}; ext(bar); ext(foo)", |
3532 "ext(function() {foo++}); ext(foo)", | 3535 "ext(function() {foo++}); ext(foo)", |
3533 "bar = () => --foo; ext(bar); ext(foo)", | 3536 "bar = () => --foo; ext(bar); ext(foo)", |
3534 "function* bar() {eval(ext)}; ext(bar); ext(foo)", | 3537 "function* bar() {eval(ext)}; ext(bar); ext(foo)", |
3535 }; | 3538 }; |
3536 | 3539 |
3537 for (unsigned i = 0; i < arraysize(prefixes); ++i) { | 3540 for (unsigned i = 0; i < arraysize(prefixes); ++i) { |
3538 const char* prefix = prefixes[i]; | 3541 const char* prefix = prefixes[i]; |
(...skipping 5429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8968 DCHECK_NULL(scope->sibling()); | 8971 DCHECK_NULL(scope->sibling()); |
8969 DCHECK(scope->is_function_scope()); | 8972 DCHECK(scope->is_function_scope()); |
8970 const i::AstRawString* var_name = | 8973 const i::AstRawString* var_name = |
8971 info.ast_value_factory()->GetOneByteString("my_var"); | 8974 info.ast_value_factory()->GetOneByteString("my_var"); |
8972 i::Variable* var = scope->Lookup(var_name); | 8975 i::Variable* var = scope->Lookup(var_name); |
8973 CHECK_EQ(inners[i].ctxt_allocate, | 8976 CHECK_EQ(inners[i].ctxt_allocate, |
8974 i::ScopeTestHelper::MustAllocateInContext(var)); | 8977 i::ScopeTestHelper::MustAllocateInContext(var)); |
8975 } | 8978 } |
8976 } | 8979 } |
8977 } | 8980 } |
OLD | NEW |