Chromium Code Reviews| 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 5590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5601 }; | 5601 }; |
| 5602 RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags, | 5602 RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags, |
| 5603 arraysize(always_flags)); | 5603 arraysize(always_flags)); |
| 5604 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | 5604 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, |
| 5605 arraysize(always_flags)); | 5605 arraysize(always_flags)); |
| 5606 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | 5606 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, |
| 5607 arraysize(always_flags)); | 5607 arraysize(always_flags)); |
| 5608 } | 5608 } |
| 5609 | 5609 |
| 5610 | 5610 |
| 5611 TEST(StrongConstructorReturns) { | |
| 5612 const char* sloppy_context_data[][2] = {{"", ""}, {NULL}}; | |
| 5613 const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}}; | |
| 5614 const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}}; | |
| 5615 | |
| 5616 const char* data[] = { | |
| 5617 "class C extends Object { constructor() { super(); return {}; } }", | |
| 5618 "class C extends Object { constructor() { super(); { return {}; } } }", | |
| 5619 "class C extends Object { constructor() { super(); if (1) return {}; } }", | |
| 5620 "class C extends Object { constructor() { return; super(); } }", | |
| 5621 "class C extends Object { constructor() { { return; } super(); } }", | |
| 5622 "class C extends Object { constructor() { if (0) return; super(); } }", | |
| 5623 NULL}; | |
| 5624 | |
| 5625 static const ParserFlag always_flags[] = { | |
| 5626 kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals | |
| 5627 }; | |
| 5628 RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags, | |
| 5629 arraysize(always_flags)); | |
| 5630 RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, | |
| 5631 arraysize(always_flags)); | |
| 5632 RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, | |
|
Dmitry Lomov (no reviews)
2015/03/19 13:59:41
Please add positive tests for strong mode:
'const
rossberg
2015/03/19 16:02:57
We don't have any 'positive' strong mode tests at
| |
| 5633 arraysize(always_flags)); | |
| 5634 } | |
| 5635 | |
| 5636 | |
| 5611 TEST(ArrowFunctionASIErrors) { | 5637 TEST(ArrowFunctionASIErrors) { |
| 5612 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, | 5638 const char* context_data[][2] = {{"'use strict';", ""}, {"", ""}, |
| 5613 {NULL, NULL}}; | 5639 {NULL, NULL}}; |
| 5614 | 5640 |
| 5615 const char* data[] = { | 5641 const char* data[] = { |
| 5616 "(a\n=> a)(1)", | 5642 "(a\n=> a)(1)", |
| 5617 "(a/*\n*/=> a)(1)", | 5643 "(a/*\n*/=> a)(1)", |
| 5618 "((a)\n=> a)(1)", | 5644 "((a)\n=> a)(1)", |
| 5619 "((a)/*\n*/=> a)(1)", | 5645 "((a)/*\n*/=> a)(1)", |
| 5620 "((a, b)\n=> a + b)(1, 2)", | 5646 "((a, b)\n=> a + b)(1, 2)", |
| 5621 "((a, b)/*\n*/=> a + b)(1, 2)", | 5647 "((a, b)/*\n*/=> a + b)(1, 2)", |
| 5622 NULL}; | 5648 NULL}; |
| 5623 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; | 5649 static const ParserFlag always_flags[] = {kAllowHarmonyArrowFunctions}; |
| 5624 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 5650 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 5625 arraysize(always_flags)); | 5651 arraysize(always_flags)); |
| 5626 } | 5652 } |
| OLD | NEW |