| 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 3779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3790 NULL}; | 3790 NULL}; |
| 3791 | 3791 |
| 3792 static const ParserFlag always_flags[] = { | 3792 static const ParserFlag always_flags[] = { |
| 3793 kAllowHarmonyClasses, kAllowHarmonySloppy}; | 3793 kAllowHarmonyClasses, kAllowHarmonySloppy}; |
| 3794 RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0, | 3794 RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0, |
| 3795 always_flags, arraysize(always_flags)); | 3795 always_flags, arraysize(always_flags)); |
| 3796 } | 3796 } |
| 3797 | 3797 |
| 3798 | 3798 |
| 3799 TEST(ClassDeclarationNoErrors) { | 3799 TEST(ClassDeclarationNoErrors) { |
| 3800 const char* context_data[][2] = {{"", ""}, | 3800 const char* context_data[][2] = {{"'use strict'; ", ""}, |
| 3801 {"{", "}"}, | 3801 {"'use strict'; {", "}"}, |
| 3802 {"if (true) {", "}"}, | 3802 {"'use strict'; if (true) {", "}"}, |
| 3803 {NULL, NULL}}; | 3803 {NULL, NULL}}; |
| 3804 const char* statement_data[] = { | 3804 const char* statement_data[] = { |
| 3805 "class name {}", | 3805 "class name {}", |
| 3806 "class name extends F {}", | 3806 "class name extends F {}", |
| 3807 "class name extends (F, G) {}", | 3807 "class name extends (F, G) {}", |
| 3808 "class name extends class {} {}", | 3808 "class name extends class {} {}", |
| 3809 "class name extends class base {} {}", | 3809 "class name extends class base {} {}", |
| 3810 NULL}; | 3810 NULL}; |
| 3811 | 3811 |
| 3812 static const ParserFlag always_flags[] = { | 3812 static const ParserFlag always_flags[] = { |
| 3813 kAllowHarmonyClasses, kAllowHarmonySloppy}; | 3813 kAllowHarmonyClasses, kAllowHarmonyScoping}; |
| 3814 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 3814 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
| 3815 always_flags, arraysize(always_flags)); | 3815 always_flags, arraysize(always_flags)); |
| 3816 } | 3816 } |
| 3817 | 3817 |
| 3818 | 3818 |
| 3819 TEST(ClassBodyNoErrors) { | 3819 TEST(ClassBodyNoErrors) { |
| 3820 // Tests that parser and preparser accept valid class syntax. | 3820 // Tests that parser and preparser accept valid class syntax. |
| 3821 const char* context_data[][2] = {{"(class {", "});"}, | 3821 const char* context_data[][2] = {{"(class {", "});"}, |
| 3822 {"(class extends Base {", "});"}, | 3822 {"(class extends Base {", "});"}, |
| 3823 {"class C {", "}"}, | 3823 {"class C {", "}"}, |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4661 | 4661 |
| 4662 static const ParserFlag always_flags[] = { | 4662 static const ParserFlag always_flags[] = { |
| 4663 kAllowHarmonyClasses, | 4663 kAllowHarmonyClasses, |
| 4664 kAllowHarmonyComputedPropertyNames, | 4664 kAllowHarmonyComputedPropertyNames, |
| 4665 kAllowHarmonyObjectLiterals, | 4665 kAllowHarmonyObjectLiterals, |
| 4666 kAllowHarmonySloppy, | 4666 kAllowHarmonySloppy, |
| 4667 }; | 4667 }; |
| 4668 RunParserSyncTest(context_data, error_data, kError, NULL, 0, | 4668 RunParserSyncTest(context_data, error_data, kError, NULL, 0, |
| 4669 always_flags, arraysize(always_flags)); | 4669 always_flags, arraysize(always_flags)); |
| 4670 } | 4670 } |
| 4671 |
| 4672 |
| 4673 TEST(DeclarationsError) { |
| 4674 const char* context_data[][2] = {{"'use strict'; if (true)", ""}, |
| 4675 {"'use strict'; if (false) {} else", ""}, |
| 4676 {"'use strict'; while (false)", ""}, |
| 4677 {"'use strict'; for (;;)", ""}, |
| 4678 {"'use strict'; for (x in y)", ""}, |
| 4679 {"'use strict'; do ", " while (false)"}, |
| 4680 {NULL, NULL}}; |
| 4681 |
| 4682 const char* statement_data[] = { |
| 4683 "let x = 1;", |
| 4684 "const x = 1;", |
| 4685 "class C {}", |
| 4686 NULL}; |
| 4687 |
| 4688 static const ParserFlag always_flags[] = { |
| 4689 kAllowHarmonyClasses, kAllowHarmonyScoping |
| 4690 }; |
| 4691 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, |
| 4692 always_flags, arraysize(always_flags)); |
| 4693 } |
| OLD | NEW |