Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2614023004: Preparsing inner funcs: Update tests. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8538 matching lines...) Expand 10 before | Expand all | Expand 10 after
8549 const char* suffix = " })();"; 8549 const char* suffix = " })();";
8550 int prefix_len = Utf8LengthHelper(prefix); 8550 int prefix_len = Utf8LengthHelper(prefix);
8551 int suffix_len = Utf8LengthHelper(suffix); 8551 int suffix_len = Utf8LengthHelper(suffix);
8552 8552
8553 struct { 8553 struct {
8554 const char* source; 8554 const char* source;
8555 bool ctxt_allocate; 8555 bool ctxt_allocate;
8556 } inners[] = { 8556 } inners[] = {
8557 // Context allocating because we need to: 8557 // Context allocating because we need to:
8558 {"function inner() { my_var; }", true}, 8558 {"function inner() { my_var; }", true},
8559 {"function inner() { if (true) { let my_var; } my_var; }", true},
8559 {"function inner() { eval(\"foo\"); }", true}, 8560 {"function inner() { eval(\"foo\"); }", true},
8560 {"function inner() { function inner2() { my_var; } }", true}, 8561 {"function inner() { function inner2() { my_var; } }", true},
8561 {"function inner() { function inner2() { eval(\"foo\"); } }", true}, 8562 {"function inner() { function inner2() { eval(\"foo\"); } }", true},
8562 {"function inner() { var {my_var : a} = {my_var}; }", true}, 8563 {"function inner() { var {my_var : a} = {my_var}; }", true},
8563 {"function inner() { let {my_var : a} = {my_var}; }", true}, 8564 {"function inner() { let {my_var : a} = {my_var}; }", true},
8564 {"function inner() { const {my_var : a} = {my_var}; }", true}, 8565 {"function inner() { const {my_var : a} = {my_var}; }", true},
8565 {"function inner(a = my_var) { }", true}, 8566 {"function inner(a = my_var) { }", true},
8566 {"function inner() { function inner2(a = my_var) { } }", true}, 8567 {"function inner() { function inner2(a = my_var) { } }", true},
8567 {"function inner() { (a = my_var) => { } }", true}, 8568 {"function inner() { (a = my_var) => { } }", true},
8568 {"function inner({a} = {a: my_var}) { }", true}, 8569 {"function inner({a} = {a: my_var}) { }", true},
8569 {"function inner() { function inner2({a} = {a: my_var}) { } }", true}, 8570 {"function inner() { function inner2({a} = {a: my_var}) { } }", true},
8570 {"function inner() { ({a} = {a: my_var}) => { } }", true}, 8571 {"function inner() { ({a} = {a: my_var}) => { } }", true},
8571 {"function inner([a] = [my_var]) { }", true}, 8572 {"function inner([a] = [my_var]) { }", true},
8572 {"function inner() { function inner2([a] = [my_var]) { } }", true}, 8573 {"function inner() { function inner2([a] = [my_var]) { } }", true},
8573 {"function inner() { ([a] = [my_var]) => { } }", true}, 8574 {"function inner() { ([a] = [my_var]) => { } }", true},
8575 {"function inner() { try { } catch (my_var) { } my_var; }", true},
8576 {"function inner() { for (my_var in {}) { my_var; } }", true},
8577 {"function inner() { for (my_var in {}) { } }", true},
8578 {"function inner() { for (my_var of []) { my_var; } }", true},
8579 {"function inner() { for (my_var of []) { } }", true},
8580 {"function inner() { for ([a, my_var, b] in {}) { my_var; } }", true},
8581 {"function inner() { for ([a, my_var, b] of []) { my_var; } }", true},
8582 {"function inner() { for ({x: my_var} in {}) { my_var; } }", true},
8583 {"function inner() { for ({x: my_var} of []) { my_var; } }", true},
8584 {"function inner() { for ({my_var} in {}) { my_var; } }", true},
8585 {"function inner() { for ({my_var} of []) { my_var; } }", true},
8586 {"function inner() { for ({y, x: my_var} in {}) { my_var; } }", true},
8587 {"function inner() { for ({y, x: my_var} of []) { my_var; } }", true},
8588 {"function inner() { for ({a, my_var} in {}) { my_var; } }", true},
8589 {"function inner() { for ({a, my_var} of []) { my_var; } }", true},
8590 {"function inner() { for (let my_var in {}) { } my_var; }", true},
8591 {"function inner() { for (let my_var of []) { } my_var; }", true},
8592 {"function inner() { for (let [a, my_var, b] in {}) { } my_var; }", true},
8593 {"function inner() { for (let [a, my_var, b] of []) { } my_var; }", true},
8594 {"function inner() { for (let {x: my_var} in {}) { } my_var; }", true},
8595 {"function inner() { for (let {x: my_var} of []) { } my_var; }", true},
8596 {"function inner() { for (let {my_var} in {}) { } my_var; }", true},
8597 {"function inner() { for (let {my_var} of []) { } my_var; }", true},
8598 {"function inner() { for (let {y, x: my_var} in {}) { } my_var; }", true},
8599 {"function inner() { for (let {y, x: my_var} of []) { } my_var; }", true},
8600 {"function inner() { for (let {a, my_var} in {}) { } my_var; }", true},
8601 {"function inner() { for (let {a, my_var} of []) { } my_var; }", true},
8574 // No pessimistic context allocation: 8602 // No pessimistic context allocation:
8575 {"function inner() { var my_var; my_var; }", false}, 8603 {"function inner() { var my_var; my_var; }", false},
8576 {"function inner() { var my_var; }", false}, 8604 {"function inner() { var my_var; }", false},
8605 {"function inner() { if (true) { var my_var; } my_var; }", false},
8577 {"function inner() { let my_var; my_var; }", false}, 8606 {"function inner() { let my_var; my_var; }", false},
8578 {"function inner() { let my_var; }", false}, 8607 {"function inner() { let my_var; }", false},
8579 {"function inner() { const my_var = 0; my_var; }", false}, 8608 {"function inner() { const my_var = 0; my_var; }", false},
8580 {"function inner() { const my_var = 0; }", false}, 8609 {"function inner() { const my_var = 0; }", false},
8581 {"function inner() { var [a, my_var] = [1, 2]; my_var; }", false}, 8610 {"function inner() { var [a, my_var] = [1, 2]; my_var; }", false},
8582 {"function inner() { let [a, my_var] = [1, 2]; my_var; }", false}, 8611 {"function inner() { let [a, my_var] = [1, 2]; my_var; }", false},
8583 {"function inner() { const [a, my_var] = [1, 2]; my_var; }", false}, 8612 {"function inner() { const [a, my_var] = [1, 2]; my_var; }", false},
8584 {"function inner() { var {a: my_var} = {a: 3}; my_var; }", false}, 8613 {"function inner() { var {a: my_var} = {a: 3}; my_var; }", false},
8585 {"function inner() { let {a: my_var} = {a: 3}; my_var; }", false}, 8614 {"function inner() { let {a: my_var} = {a: 3}; my_var; }", false},
8586 {"function inner() { const {a: my_var} = {a: 3}; my_var; }", false}, 8615 {"function inner() { const {a: my_var} = {a: 3}; my_var; }", false},
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
8642 {"([a, my_var, b] = [1, 2, 3]) => my_var;", false}, 8671 {"([a, my_var, b] = [1, 2, 3]) => my_var;", false},
8643 {"([a, my_var, b] = [1, 2, 3]) => { }", false}, 8672 {"([a, my_var, b] = [1, 2, 3]) => { }", false},
8644 {"({x: my_var}) => my_var;", false}, 8673 {"({x: my_var}) => my_var;", false},
8645 {"({x: my_var}) => { }", false}, 8674 {"({x: my_var}) => { }", false},
8646 {"({x: my_var} = {x: 0}) => my_var;", false}, 8675 {"({x: my_var} = {x: 0}) => my_var;", false},
8647 {"({x: my_var} = {x: 0}) => { }", false}, 8676 {"({x: my_var} = {x: 0}) => { }", false},
8648 {"({my_var}) => my_var;", false}, 8677 {"({my_var}) => my_var;", false},
8649 {"({my_var}) => { }", false}, 8678 {"({my_var}) => { }", false},
8650 {"({my_var} = {my_var: 5}) => my_var;", false}, 8679 {"({my_var} = {my_var: 5}) => my_var;", false},
8651 {"({my_var} = {my_var: 5}) => { }", false}, 8680 {"({my_var} = {my_var: 5}) => { }", false},
8652 {"function inner() { try { } catch (my_var) { } }", false}, 8681 {"({a, my_var}) => my_var;", false},
8653 {"function inner() { class my_var {}; }", false}, 8682 {"({a, my_var}) => { }", false},
8683 {"({a, my_var} = {a: 0, my_var: 5}) => my_var;", false},
8684 {"({a, my_var} = {a: 0, my_var: 5}) => { }", false},
8685 {"({y, x: my_var}) => my_var;", false},
8686 {"({y, x: my_var}) => { }", false},
8687 {"({y, x: my_var} = {y: 0, x: 0}) => my_var;", false},
8688 {"({y, x: my_var} = {y: 0, x: 0}) => { }", false},
8654 {"function inner() { my_var => my_var; }", false}, 8689 {"function inner() { my_var => my_var; }", false},
8655 {"function inner() { my_var => { }}", false}, 8690 {"function inner() { my_var => { }}", false},
8656 {"function inner() { (my_var = 5) => my_var; }", false}, 8691 {"function inner() { (my_var = 5) => my_var; }", false},
8657 {"function inner() { (my_var = 5) => { }}", false}, 8692 {"function inner() { (my_var = 5) => { }}", false},
8658 {"function inner() { (...my_var) => my_var;}", false}, 8693 {"function inner() { (...my_var) => my_var;}", false},
8659 {"function inner() { (...my_var) => { }}", false}, 8694 {"function inner() { (...my_var) => { }}", false},
8660 {"function inner() { ([a, my_var, b]) => my_var;}", false}, 8695 {"function inner() { ([a, my_var, b]) => my_var;}", false},
8661 {"function inner() { ([a, my_var, b]) => { }}", false}, 8696 {"function inner() { ([a, my_var, b]) => { }}", false},
8662 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => my_var;}", false}, 8697 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => my_var;}", false},
8663 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => { }}", false}, 8698 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => { }}", false},
8664 {"function inner() { ({x: my_var}) => my_var;}", false}, 8699 {"function inner() { ({x: my_var}) => my_var;}", false},
8665 {"function inner() { ({x: my_var}) => { }}", false}, 8700 {"function inner() { ({x: my_var}) => { }}", false},
8666 {"function inner() { ({x: my_var} = {x: 0}) => my_var;}", false}, 8701 {"function inner() { ({x: my_var} = {x: 0}) => my_var;}", false},
8667 {"function inner() { ({x: my_var} = {x: 0}) => { }}", false}, 8702 {"function inner() { ({x: my_var} = {x: 0}) => { }}", false},
8668 {"function inner() { ({my_var}) => my_var;}", false}, 8703 {"function inner() { ({my_var}) => my_var;}", false},
8669 {"function inner() { ({my_var}) => { }}", false}, 8704 {"function inner() { ({my_var}) => { }}", false},
8670 {"function inner() { ({my_var} = {my_var: 5}) => my_var;}", false}, 8705 {"function inner() { ({my_var} = {my_var: 5}) => my_var;}", false},
8671 {"function inner() { ({my_var} = {my_var: 5}) => { }}", false}, 8706 {"function inner() { ({my_var} = {my_var: 5}) => { }}", false},
8707 {"function inner() { ({a, my_var}) => my_var;}", false},
8708 {"function inner() { ({a, my_var}) => { }}", false},
8709 {"function inner() { ({a, my_var} = {a: 0, my_var: 5}) => my_var;}",
8710 false},
8711 {"function inner() { ({a, my_var} = {a: 0, my_var: 5}) => { }}", false},
8712 {"function inner() { ({y, x: my_var}) => my_var;}", false},
8713 {"function inner() { ({y, x: my_var}) => { }}", false},
8714 {"function inner() { ({y, x: my_var} = {y: 0, x: 0}) => my_var;}", false},
8715 {"function inner() { ({y, x: my_var} = {y: 0, x: 0}) => { }}", false},
8672 // In the following cases we still context allocate pessimistically: 8716 // In the following cases we still context allocate pessimistically:
8673 {"function inner() { function my_var() {} my_var; }", true}, 8717 {"function inner() { function my_var() {} my_var; }", true},
8674 {"function inner() { if (true) { function my_var() {} } my_var; }", 8718 {"function inner() { if (true) { function my_var() {} } my_var; }",
8675 true}, 8719 true},
8676 {"function inner() { try { } catch (my_var) { my_var; } }", true}, 8720 {"function inner() { try { } catch (my_var) { my_var; } }", true},
8677 {"function inner() { for (my_var of {}) { my_var; } }", true}, 8721 {"function inner() { try { } catch ([a, my_var, b]) { my_var; } }", true},
8678 {"function inner() { for (my_var of {}) { } }", true}, 8722 {"function inner() { try { } catch ({x: my_var}) { my_var; } }", true},
8679 {"function inner() { for (my_var in []) { my_var; } }", true}, 8723 {"function inner() { try { } catch ({y, x: my_var}) { my_var; } }", true},
8680 {"function inner() { for (my_var in []) { } }", true}, 8724 {"function inner() { try { } catch ({my_var}) { my_var; } }", true},
8725 {"function inner() { for (let my_var = 0; my_var < 1; ++my_var) { my_var "
8726 "} }",
8727 true},
8728 {"function inner() { for (let a = 0, my_var = 0; my_var < 1; ++my_var) { "
8729 "my_var } }",
8730 true},
8731 {"function inner() { for (let my_var in {}) { my_var; } }", true},
8732 {"function inner() { for (let my_var in {}) { } }", true},
8733 {"function inner() { for (let my_var of []) { my_var; } }", true},
8734 {"function inner() { for (let my_var of []) { } }", true},
8735 {"function inner() { for (let [a, my_var, b] in {}) { my_var; } }", true},
8736 {"function inner() { for (let [a, my_var, b] of []) { my_var; } }", true},
8737 {"function inner() { for (let {x: my_var} in {}) { my_var; } }", true},
8738 {"function inner() { for (let {x: my_var} of []) { my_var; } }", true},
8739 {"function inner() { for (let {my_var} in {}) { my_var; } }", true},
8740 {"function inner() { for (let {my_var} of []) { my_var; } }", true},
8741 {"function inner() { for (let {y, x: my_var} in {}) { my_var; } }", true},
8742 {"function inner() { for (let {y, x: my_var} of []) { my_var; } }", true},
8743 {"function inner() { for (let {a, my_var} in {}) { my_var; } }", true},
8744 {"function inner() { for (let {a, my_var} of []) { my_var; } }", true},
8745 {"function inner() { for (var my_var in {}) { my_var; } }", true},
8746 {"function inner() { for (var my_var in {}) { } }", true},
8747 {"function inner() { for (var my_var of []) { my_var; } }", true},
8748 {"function inner() { for (var my_var of []) { } }", true},
8749 {"function inner() { for (var [a, my_var, b] in {}) { my_var; } }", true},
8750 {"function inner() { for (var [a, my_var, b] of []) { my_var; } }", true},
8751 {"function inner() { for (var {x: my_var} in {}) { my_var; } }", true},
8752 {"function inner() { for (var {x: my_var} of []) { my_var; } }", true},
8753 {"function inner() { for (var {my_var} in {}) { my_var; } }", true},
8754 {"function inner() { for (var {my_var} of []) { my_var; } }", true},
8755 {"function inner() { for (var {y, x: my_var} in {}) { my_var; } }", true},
8756 {"function inner() { for (var {y, x: my_var} of []) { my_var; } }", true},
8757 {"function inner() { for (var {a, my_var} in {}) { my_var; } }", true},
8758 {"function inner() { for (var {a, my_var} of []) { my_var; } }", true},
8759 {"function inner() { for (var my_var in {}) { } my_var; }", true},
8760 {"function inner() { for (var my_var of []) { } my_var; }", true},
8761 {"function inner() { for (var [a, my_var, b] in {}) { } my_var; }", true},
8762 {"function inner() { for (var [a, my_var, b] of []) { } my_var; }", true},
8763 {"function inner() { for (var {x: my_var} in {}) { } my_var; }", true},
8764 {"function inner() { for (var {x: my_var} of []) { } my_var; }", true},
8765 {"function inner() { for (var {my_var} in {}) { } my_var; }", true},
8766 {"function inner() { for (var {my_var} of []) { } my_var; }", true},
8767 {"function inner() { for (var {y, x: my_var} in {}) { } my_var; }", true},
8768 {"function inner() { for (var {y, x: my_var} of []) { } my_var; }", true},
8769 {"function inner() { for (var {a, my_var} in {}) { } my_var; }", true},
8770 {"function inner() { for (var {a, my_var} of []) { } my_var; }", true},
8681 {"function inner() { class my_var {}; my_var }", true}, 8771 {"function inner() { class my_var {}; my_var }", true},
8682 }; 8772 };
8683 8773
8684 for (unsigned i = 0; i < arraysize(inners); ++i) { 8774 for (unsigned i = 0; i < arraysize(inners); ++i) {
8685 const char* inner = inners[i].source; 8775 const char* inner = inners[i].source;
8686 int inner_len = Utf8LengthHelper(inner); 8776 int inner_len = Utf8LengthHelper(inner);
8687 int len = prefix_len + inner_len + suffix_len; 8777 int len = prefix_len + inner_len + suffix_len;
8688 i::ScopedVector<char> program(len + 1); 8778 i::ScopedVector<char> program(len + 1);
8689 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); 8779 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix);
8690 i::Handle<i::String> source = 8780 i::Handle<i::String> source =
(...skipping 13 matching lines...) Expand all
8704 DCHECK_NOT_NULL(scope); 8794 DCHECK_NOT_NULL(scope);
8705 DCHECK_NULL(scope->sibling()); 8795 DCHECK_NULL(scope->sibling());
8706 DCHECK(scope->is_function_scope()); 8796 DCHECK(scope->is_function_scope());
8707 const i::AstRawString* var_name = 8797 const i::AstRawString* var_name =
8708 info.ast_value_factory()->GetOneByteString("my_var"); 8798 info.ast_value_factory()->GetOneByteString("my_var");
8709 i::Variable* var = scope->Lookup(var_name); 8799 i::Variable* var = scope->Lookup(var_name);
8710 CHECK_EQ(inners[i].ctxt_allocate, 8800 CHECK_EQ(inners[i].ctxt_allocate,
8711 i::ScopeTestHelper::MustAllocateInContext(var)); 8801 i::ScopeTestHelper::MustAllocateInContext(var));
8712 } 8802 }
8713 } 8803 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698