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

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

Issue 1002253002: [strong] Check super constructor calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo Created 5 years, 9 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
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 5548 matching lines...) Expand 10 before | Expand all | Expand 10 after
5559 }; 5559 };
5560 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags, 5560 RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, always_flags,
5561 arraysize(always_flags)); 5561 arraysize(always_flags));
5562 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, 5562 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5563 arraysize(always_flags)); 5563 arraysize(always_flags));
5564 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, 5564 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5565 arraysize(always_flags)); 5565 arraysize(always_flags));
5566 } 5566 }
5567 5567
5568 5568
5569 TEST(StrongSuperCalls) {
5570 const char* sloppy_context_data[][2] = {{"", ""}, {NULL}};
5571 const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}};
5572 const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}};
5573
5574 const char* data[] = {
5575 "class C extends Object { constructor() {} }",
5576 "class C extends Object { constructor() { (super()); } }",
5577 "class C extends Object { constructor() { (() => super())(); } }",
5578 "class C extends Object { constructor() { { super(); } } }",
5579 "class C extends Object { constructor() { if (1) super(); } }",
5580 "class C extends Object { constructor() { super(), super(); } }",
5581 "class C extends Object { constructor() { super(); super(); } }",
5582 "class C extends Object { constructor() { super(); (super()); } }",
5583 "class C extends Object { constructor() { super(); { super() } } }",
5584 NULL};
5585
5586 static const ParserFlag always_flags[] = {
5587 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals,
5588 kAllowHarmonyArrowFunctions
5589 };
5590 RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags,
5591 arraysize(always_flags));
5592 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags,
5593 arraysize(always_flags));
5594 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags,
5595 arraysize(always_flags));
5596 }
5597
5598
5569 TEST(ArrowFunctionASIErrors) { 5599 TEST(ArrowFunctionASIErrors) {
5570 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, 5600 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""},
5571 {NULL, NULL}}; 5601 {NULL, NULL}};
5572 5602
5573 const char* data[] = { 5603 const char* data[] = {
5574 "(a\n=> a)(1)", 5604 "(a\n=> a)(1)",
5575 "(a/*\n*/=> a)(1)", 5605 "(a/*\n*/=> a)(1)",
5576 "((a)\n=> a)(1)", 5606 "((a)\n=> a)(1)",
5577 "((a)/*\n*/=> a)(1)", 5607 "((a)/*\n*/=> a)(1)",
5578 "((a, b)\n=> a + b)(1, 2)", 5608 "((a, b)\n=> a + b)(1, 2)",
5579 "((a, b)/*\n*/=> a + b)(1, 2)", 5609 "((a, b)/*\n*/=> a + b)(1, 2)",
5580 NULL}; 5610 NULL};
5581 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; 5611 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions};
5582 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 5612 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
5583 arraysize(always_flags)); 5613 arraysize(always_flags));
5584 } 5614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698