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

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

Issue 766673003: Make the ParserSync test faster (and re-enable it). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1512 } 1512 }
1513 for (size_t flag_index = 0; flag_index < always_false_flags_length; 1513 for (size_t flag_index = 0; flag_index < always_false_flags_length;
1514 ++flag_index) { 1514 ++flag_index) {
1515 flags.Remove(always_false_flags[flag_index]); 1515 flags.Remove(always_false_flags[flag_index]);
1516 } 1516 }
1517 TestParserSyncWithFlags(str, flags, result); 1517 TestParserSyncWithFlags(str, flags, result);
1518 } 1518 }
1519 } 1519 }
1520 1520
1521 1521
1522 // TODO(marja) This needs to be turned into a fuzzing test, trying all those 1522 TEST(ParserSync) {
1523 // combinations below takes at least 2 orders of magnitude too long.
1524 DISABLED_TEST(ParserSync) {
1525 const char* context_data[][2] = { 1523 const char* context_data[][2] = {
1526 { "", "" }, 1524 { "", "" },
1527 { "{", "}" }, 1525 { "{", "}" },
1528 { "if (true) ", " else {}" }, 1526 { "if (true) ", " else {}" },
1529 { "if (true) {} else ", "" }, 1527 { "if (true) {} else ", "" },
1530 { "if (true) ", "" }, 1528 { "if (true) ", "" },
1531 { "do ", " while (false)" }, 1529 { "do ", " while (false)" },
1532 { "while (false) ", "" }, 1530 { "while (false) ", "" },
1533 { "for (;;) ", "" }, 1531 { "for (;;) ", "" },
1534 { "with ({})", "" }, 1532 { "with ({})", "" },
1535 { "switch (12) { case 12: ", "}" }, 1533 { "switch (12) { case 12: ", "}" },
1536 { "switch (12) { default: ", "}" }, 1534 { "switch (12) { default: ", "}" },
1537 { "switch (12) { ", "case 12: }" }, 1535 { "switch (12) { ", "case 12: }" },
1538 { "label2: ", "" }, 1536 { "label2: ", "" },
1539 { NULL, NULL } 1537 { NULL, NULL }
1540 }; 1538 };
1541 1539
1542 const char* statement_data[] = { 1540 const char* statement_data[] = {
1543 "{}", 1541 "{}",
1544 "var x", 1542 "var x",
1545 "var x = 1", 1543 "var x = 1",
1546 "const x", 1544 "const x",
1547 "const x = 1", 1545 "const x = 1",
1548 ";", 1546 ";",
1549 "12", 1547 "12",
1550 "if (false) {} else ;", 1548 "if (false) {} else ;",
1551 "if (false) {} else {}", 1549 "if (false) {} else {}",
1552 "if (false) {} else 12", 1550 "if (false) {} else 12",
1553 "if (false) ;" 1551 "if (false) ;",
1554 "if (false) {}", 1552 "if (false) {}",
1555 "if (false) 12", 1553 "if (false) 12",
1556 "do {} while (false)", 1554 "do {} while (false)",
1557 "for (;;) ;", 1555 "for (;;) ;",
1558 "for (;;) {}", 1556 "for (;;) {}",
1559 "for (;;) 12", 1557 "for (;;) 12",
1560 "continue", 1558 "continue",
1561 "continue label", 1559 "continue label",
1562 "continue\nlabel", 1560 "continue\nlabel",
1563 "break", 1561 "break",
1564 "break label", 1562 "break label",
1565 "break\nlabel", 1563 "break\nlabel",
1566 // TODO(marja): activate once parsing 'return' is merged into ParserBase. 1564 // TODO(marja): activate once parsing 'return' is merged into ParserBase.
1567 // "return", 1565 // "return",
1568 // "return 12", 1566 // "return 12",
1569 // "return\n12", 1567 // "return\n12",
1570 "with ({}) ;", 1568 "with ({}) ;",
1571 "with ({}) {}", 1569 "with ({}) {}",
1572 "with ({}) 12", 1570 "with ({}) 12",
1573 "switch ({}) { default: }" 1571 "switch ({}) { default: }",
1574 "label3: " 1572 "label3: ",
1575 "throw", 1573 "throw",
1576 "throw 12", 1574 "throw 12",
1577 "throw\n12", 1575 "throw\n12",
1578 "try {} catch(e) {}", 1576 "try {} catch(e) {}",
1579 "try {} finally {}", 1577 "try {} finally {}",
1580 "try {} catch(e) {} finally {}", 1578 "try {} catch(e) {} finally {}",
1581 "debugger", 1579 "debugger",
1582 NULL 1580 NULL
1583 }; 1581 };
1584 1582
1585 const char* termination_data[] = { 1583 const char* termination_data[] = {
1586 "", 1584 "",
1587 ";", 1585 ";",
1588 "\n", 1586 "\n",
1589 ";\n", 1587 ";\n",
1590 "\n;", 1588 "\n;",
1591 NULL 1589 NULL
1592 }; 1590 };
1593 1591
1594 v8::HandleScope handles(CcTest::isolate()); 1592 v8::HandleScope handles(CcTest::isolate());
1595 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 1593 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
1596 v8::Context::Scope context_scope(context); 1594 v8::Context::Scope context_scope(context);
1597 1595
1598 CcTest::i_isolate()->stack_guard()->SetStackLimit( 1596 CcTest::i_isolate()->stack_guard()->SetStackLimit(
1599 i::GetCurrentStackPosition() - 128 * 1024); 1597 i::GetCurrentStackPosition() - 128 * 1024);
1600 1598
1601 static const ParserFlag flags1[] = {
1602 kAllowHarmonyArrowFunctions,
1603 kAllowHarmonyClasses,
1604 kAllowHarmonyNumericLiterals,
1605 kAllowHarmonyObjectLiterals,
1606 kAllowHarmonyScoping,
1607 kAllowHarmonyModules,
1608 kAllowHarmonySloppy,
1609 kAllowLazy,
1610 };
1611
1612 for (int i = 0; context_data[i][0] != NULL; ++i) { 1599 for (int i = 0; context_data[i][0] != NULL; ++i) {
1613 for (int j = 0; statement_data[j] != NULL; ++j) { 1600 for (int j = 0; statement_data[j] != NULL; ++j) {
1614 for (int k = 0; termination_data[k] != NULL; ++k) { 1601 for (int k = 0; termination_data[k] != NULL; ++k) {
1615 int kPrefixLen = i::StrLength(context_data[i][0]); 1602 int kPrefixLen = i::StrLength(context_data[i][0]);
1616 int kStatementLen = i::StrLength(statement_data[j]); 1603 int kStatementLen = i::StrLength(statement_data[j]);
1617 int kTerminationLen = i::StrLength(termination_data[k]); 1604 int kTerminationLen = i::StrLength(termination_data[k]);
1618 int kSuffixLen = i::StrLength(context_data[i][1]); 1605 int kSuffixLen = i::StrLength(context_data[i][1]);
1619 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen 1606 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen
1620 + kSuffixLen + i::StrLength("label: for (;;) { }"); 1607 + kSuffixLen + i::StrLength("label: for (;;) { }");
1621 1608
1622 // Plug the source code pieces together. 1609 // Plug the source code pieces together.
1623 i::ScopedVector<char> program(kProgramSize + 1); 1610 i::ScopedVector<char> program(kProgramSize + 1);
1624 int length = i::SNPrintF(program, 1611 int length = i::SNPrintF(program,
1625 "label: for (;;) { %s%s%s%s }", 1612 "label: for (;;) { %s%s%s%s }",
1626 context_data[i][0], 1613 context_data[i][0],
1627 statement_data[j], 1614 statement_data[j],
1628 termination_data[k], 1615 termination_data[k],
1629 context_data[i][1]); 1616 context_data[i][1]);
1630 CHECK(length == kProgramSize); 1617 CHECK(length == kProgramSize);
1631 TestParserSync(program.start(), flags1, arraysize(flags1)); 1618 TestParserSync(program.start(), NULL, 0);
1632 } 1619 }
1633 } 1620 }
1634 } 1621 }
1635 1622
1636 // Neither Harmony numeric literals nor our natives syntax have any 1623 // Neither Harmony numeric literals nor our natives syntax have any
1637 // interaction with the flags above, so test these separately to reduce 1624 // interaction with the flags above, so test these separately to reduce
1638 // the combinatorial explosion. 1625 // the combinatorial explosion.
1639 static const ParserFlag flags2[] = { kAllowHarmonyNumericLiterals }; 1626 static const ParserFlag flags2[] = { kAllowHarmonyNumericLiterals };
1640 TestParserSync("0o1234", flags2, arraysize(flags2)); 1627 TestParserSync("0o1234", flags2, arraysize(flags2));
1641 TestParserSync("0b1011", flags2, arraysize(flags2)); 1628 TestParserSync("0b1011", flags2, arraysize(flags2));
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after
4514 always_false_flags, arraysize(always_false_flags)); 4501 always_false_flags, arraysize(always_false_flags));
4515 4502
4516 const char* good_data[] = { 4503 const char* good_data[] = {
4517 "let = 1;", 4504 "let = 1;",
4518 "for(let = 1;;){}", 4505 "for(let = 1;;){}",
4519 NULL}; 4506 NULL};
4520 RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0, 4507 RunParserSyncTest(context_data, good_data, kSuccess, NULL, 0,
4521 always_true_flags, arraysize(always_true_flags), 4508 always_true_flags, arraysize(always_true_flags),
4522 always_false_flags, arraysize(always_false_flags)); 4509 always_false_flags, arraysize(always_false_flags));
4523 } 4510 }
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