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

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

Issue 577973002: ES6: Implement generator method shorthand (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Cleanup based on code review Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/harmony/object-literals-method.js » ('j') | 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 3393 matching lines...) Expand 10 before | Expand all | Expand 10 after
3404 3404
3405 static const ParserFlag always_flags[] = {kAllowClasses}; 3405 static const ParserFlag always_flags[] = {kAllowClasses};
3406 RunParserSyncTest(context_data, statement_data, kError, NULL, 0, 3406 RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
3407 always_flags, arraysize(always_flags)); 3407 always_flags, arraysize(always_flags));
3408 } 3408 }
3409 3409
3410 3410
3411 TEST(NoErrorsMethodDefinition) { 3411 TEST(NoErrorsMethodDefinition) {
3412 const char* context_data[][2] = {{"({", "});"}, 3412 const char* context_data[][2] = {{"({", "});"},
3413 {"'use strict'; ({", "});"}, 3413 {"'use strict'; ({", "});"},
3414 {"({*", "});"},
3415 {"'use strict'; ({*", "});"},
3414 {NULL, NULL}}; 3416 {NULL, NULL}};
3415 3417
3416 const char* object_literal_body_data[] = { 3418 const char* object_literal_body_data[] = {
3417 "m() {}", 3419 "m() {}",
3418 "m(x) { return x; }", 3420 "m(x) { return x; }",
3419 "m(x, y) {}, n() {}", 3421 "m(x, y) {}, n() {}",
3420 "set(x, y) {}", 3422 "set(x, y) {}",
3421 "get(x, y) {}", 3423 "get(x, y) {}",
3422 NULL 3424 NULL
3423 }; 3425 };
3424 3426
3425 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; 3427 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
3426 RunParserSyncTest(context_data, object_literal_body_data, kSuccess, NULL, 0, 3428 RunParserSyncTest(context_data, object_literal_body_data, kSuccess, NULL, 0,
3427 always_flags, arraysize(always_flags)); 3429 always_flags, arraysize(always_flags));
3428 } 3430 }
3429 3431
3430 3432
3431 TEST(MethodDefinitionNames) { 3433 TEST(MethodDefinitionNames) {
3432 const char* context_data[][2] = {{"({", "(x, y) {}});"}, 3434 const char* context_data[][2] = {{"({", "(x, y) {}});"},
3433 {"'use strict'; ({", "(x, y) {}});"}, 3435 {"'use strict'; ({", "(x, y) {}});"},
3436 {"({*", "(x, y) {}});"},
3437 {"'use strict'; ({*", "(x, y) {}});"},
3434 {NULL, NULL}}; 3438 {NULL, NULL}};
3435 3439
3436 const char* name_data[] = { 3440 const char* name_data[] = {
3437 "m", 3441 "m",
3438 "'m'", 3442 "'m'",
3439 "\"m\"", 3443 "\"m\"",
3440 "\"m n\"", 3444 "\"m n\"",
3441 "true", 3445 "true",
3442 "false", 3446 "false",
3443 "null", 3447 "null",
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3498 3502
3499 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; 3503 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
3500 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, 3504 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0,
3501 always_flags, arraysize(always_flags)); 3505 always_flags, arraysize(always_flags));
3502 } 3506 }
3503 3507
3504 3508
3505 TEST(MethodDefinitionStrictFormalParamereters) { 3509 TEST(MethodDefinitionStrictFormalParamereters) {
3506 const char* context_data[][2] = {{"({method(", "){}});"}, 3510 const char* context_data[][2] = {{"({method(", "){}});"},
3507 {"'use strict'; ({method(", "){}});"}, 3511 {"'use strict'; ({method(", "){}});"},
3512 {"({*method(", "){}});"},
3513 {"'use strict'; ({*method(", "){}});"},
3508 {NULL, NULL}}; 3514 {NULL, NULL}};
3509 3515
3510 const char* params_data[] = { 3516 const char* params_data[] = {
3511 "x, x", 3517 "x, x",
3512 "x, y, x", 3518 "x, y, x",
3513 "eval", 3519 "eval",
3514 "arguments", 3520 "arguments",
3515 "var", 3521 "var",
3516 "const", 3522 "const",
3517 NULL 3523 NULL
(...skipping 15 matching lines...) Expand all
3533 "x: 1, x() {}", 3539 "x: 1, x() {}",
3534 "x() {}, x: 1", 3540 "x() {}, x: 1",
3535 "x() {}, get x() {}", 3541 "x() {}, get x() {}",
3536 "x() {}, set x(_) {}", 3542 "x() {}, set x(_) {}",
3537 "x() {}, x() {}", 3543 "x() {}, x() {}",
3538 "x() {}, y() {}, x() {}", 3544 "x() {}, y() {}, x() {}",
3539 "x() {}, \"x\"() {}", 3545 "x() {}, \"x\"() {}",
3540 "x() {}, 'x'() {}", 3546 "x() {}, 'x'() {}",
3541 "0() {}, '0'() {}", 3547 "0() {}, '0'() {}",
3542 "1.0() {}, 1: 1", 3548 "1.0() {}, 1: 1",
3549
3550 "x: 1, *x() {}",
3551 "*x() {}, x: 1",
3552 "*x() {}, get x() {}",
3553 "*x() {}, set x(_) {}",
3554 "*x() {}, *x() {}",
3555 "*x() {}, y() {}, *x() {}",
3556 "*x() {}, *\"x\"() {}",
3557 "*x() {}, *'x'() {}",
3558 "*0() {}, *'0'() {}",
3559 "*1.0() {}, 1: 1",
3560
3543 NULL 3561 NULL
3544 }; 3562 };
3545 3563
3546 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals}; 3564 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
3547 RunParserSyncTest(context_data, params_data, kError, NULL, 0, 3565 RunParserSyncTest(context_data, params_data, kError, NULL, 0,
3548 always_flags, arraysize(always_flags)); 3566 always_flags, arraysize(always_flags));
3549 } 3567 }
3550 3568
3551 3569
3552 TEST(NoErrorsClassExpression) { 3570 TEST(ClassExpressionNoErrors) {
3553 const char* context_data[][2] = {{"(", ");"}, 3571 const char* context_data[][2] = {{"(", ");"},
3554 {"var C = ", ";"}, 3572 {"var C = ", ";"},
3555 {"bar, ", ";"}, 3573 {"bar, ", ";"},
3556 {NULL, NULL}}; 3574 {NULL, NULL}};
3557 const char* class_data[] = { 3575 const char* class_data[] = {
3558 "class {}", 3576 "class {}",
3559 "class name {}", 3577 "class name {}",
3560 "class extends F {}", 3578 "class extends F {}",
3561 "class name extends F {}", 3579 "class name extends F {}",
3562 "class extends (F, G) {}", 3580 "class extends (F, G) {}",
3563 "class name extends (F, G) {}", 3581 "class name extends (F, G) {}",
3564 "class extends class {} {}", 3582 "class extends class {} {}",
3565 "class name extends class {} {}", 3583 "class name extends class {} {}",
3566 "class extends class base {} {}", 3584 "class extends class base {} {}",
3567 "class name extends class base {} {}", 3585 "class name extends class base {} {}",
3568 NULL}; 3586 NULL};
3569 3587
3570 static const ParserFlag always_flags[] = {kAllowClasses}; 3588 static const ParserFlag always_flags[] = {kAllowClasses};
3571 RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0, 3589 RunParserSyncTest(context_data, class_data, kSuccess, NULL, 0,
3572 always_flags, arraysize(always_flags)); 3590 always_flags, arraysize(always_flags));
3573 } 3591 }
3574 3592
3575 3593
3576 TEST(NoErrorsClassDeclaration) { 3594 TEST(ClassDeclarationNoErrors) {
3577 const char* context_data[][2] = {{"", ""}, 3595 const char* context_data[][2] = {{"", ""},
3578 {"{", "}"}, 3596 {"{", "}"},
3579 {"if (true) {", "}"}, 3597 {"if (true) {", "}"},
3580 {NULL, NULL}}; 3598 {NULL, NULL}};
3581 const char* statement_data[] = { 3599 const char* statement_data[] = {
3582 "class name {}", 3600 "class name {}",
3583 "class name extends F {}", 3601 "class name extends F {}",
3584 "class name extends (F, G) {}", 3602 "class name extends (F, G) {}",
3585 "class name extends class {} {}", 3603 "class name extends class {} {}",
3586 "class name extends class base {} {}", 3604 "class name extends class base {} {}",
3587 NULL}; 3605 NULL};
3588 3606
3589 static const ParserFlag always_flags[] = {kAllowClasses}; 3607 static const ParserFlag always_flags[] = {kAllowClasses};
3590 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 3608 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
3591 always_flags, arraysize(always_flags)); 3609 always_flags, arraysize(always_flags));
3592 } 3610 }
3593 3611
3594 3612
3595 TEST(NoErrorsClassBody) { 3613 TEST(ClassBodyNoErrors) {
3596 // Tests that parser and preparser accept valid class syntax. 3614 // Tests that parser and preparser accept valid class syntax.
3597 const char* context_data[][2] = {{"(class {", "});"}, 3615 const char* context_data[][2] = {{"(class {", "});"},
3598 {"(class extends Base {", "});"}, 3616 {"(class extends Base {", "});"},
3599 {"class C {", "}"}, 3617 {"class C {", "}"},
3600 {"class C extends Base {", "}"}, 3618 {"class C extends Base {", "}"},
3601 {NULL, NULL}}; 3619 {NULL, NULL}};
3602 const char* class_body_data[] = { 3620 const char* class_body_data[] = {
3603 ";", 3621 ";",
3604 ";;", 3622 ";;",
3605 "m() {}", 3623 "m() {}",
3606 "m() {};", 3624 "m() {};",
3607 ";m() {}", 3625 "; m() {}",
3608 "m() {}; n(x) {}", 3626 "m() {}; n(x) {}",
3609 "get x() {}", 3627 "get x() {}",
3610 "set x(v) {}", 3628 "set x(v) {}",
3611 "get() {}", 3629 "get() {}",
3612 "set() {}", 3630 "set() {}",
3631 "*g() {}",
3632 "*g() {};",
3633 "; *g() {}",
3634 "*g() {}; *h(x) {}",
3613 "static() {}", 3635 "static() {}",
3614 "static m() {}", 3636 "static m() {}",
3615 "static get x() {}", 3637 "static get x() {}",
3616 "static set x(v) {}", 3638 "static set x(v) {}",
3617 "static get() {}", 3639 "static get() {}",
3618 "static set() {}", 3640 "static set() {}",
3619 "static static() {}", 3641 "static static() {}",
3620 "static get static() {}", 3642 "static get static() {}",
3621 "static set static(v) {}", 3643 "static set static(v) {}",
3644 "*static() {}",
3645 "*get() {}",
3646 "*set() {}",
3647 "static *g() {}",
3622 NULL}; 3648 NULL};
3623 3649
3624 static const ParserFlag always_flags[] = { 3650 static const ParserFlag always_flags[] = {
3625 kAllowClasses, 3651 kAllowClasses,
3626 kAllowHarmonyObjectLiterals 3652 kAllowHarmonyObjectLiterals
3627 }; 3653 };
3628 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, 3654 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0,
3629 always_flags, arraysize(always_flags)); 3655 always_flags, arraysize(always_flags));
3630 } 3656 }
3631 3657
3632 3658
3633 TEST(MethodDefinitionstrictFormalParamereters) { 3659 TEST(ClassPropertyNameNoErrors) {
3634 const char* context_data[][2] = {{"({method(", "){}});"},
3635 {NULL, NULL}};
3636
3637 const char* params_data[] = {
3638 "x, x",
3639 "x, y, x",
3640 "eval",
3641 "arguments",
3642 "var",
3643 "const",
3644 NULL
3645 };
3646
3647 static const ParserFlag always_flags[] = {kAllowHarmonyObjectLiterals};
3648 RunParserSyncTest(context_data, params_data, kError, NULL, 0,
3649 always_flags, arraysize(always_flags));
3650 }
3651
3652
3653 TEST(NoErrorsClassPropertyName) {
3654 const char* context_data[][2] = {{"(class {", "() {}});"}, 3660 const char* context_data[][2] = {{"(class {", "() {}});"},
3655 {"(class { get ", "() {}});"}, 3661 {"(class { get ", "() {}});"},
3656 {"(class { set ", "(v) {}});"}, 3662 {"(class { set ", "(v) {}});"},
3657 {"(class { static ", "() {}});"}, 3663 {"(class { static ", "() {}});"},
3658 {"(class { static get ", "() {}});"}, 3664 {"(class { static get ", "() {}});"},
3659 {"(class { static set ", "(v) {}});"}, 3665 {"(class { static set ", "(v) {}});"},
3666 {"(class { *", "() {}});"},
3667 {"(class { static *", "() {}});"},
3660 {"class C {", "() {}}"}, 3668 {"class C {", "() {}}"},
3661 {"class C { get ", "() {}}"}, 3669 {"class C { get ", "() {}}"},
3662 {"class C { set ", "(v) {}}"}, 3670 {"class C { set ", "(v) {}}"},
3663 {"class C { static ", "() {}}"}, 3671 {"class C { static ", "() {}}"},
3664 {"class C { static get ", "() {}}"}, 3672 {"class C { static get ", "() {}}"},
3665 {"class C { static set ", "(v) {}}"}, 3673 {"class C { static set ", "(v) {}}"},
3674 {"class C { *", "() {}}"},
3675 {"class C { static *", "() {}}"},
3666 {NULL, NULL}}; 3676 {NULL, NULL}};
3667 const char* name_data[] = { 3677 const char* name_data[] = {
3668 "42", 3678 "42",
3669 "42.5", 3679 "42.5",
3670 "42e2", 3680 "42e2",
3671 "42e+2", 3681 "42e+2",
3672 "42e-2", 3682 "42e-2",
3673 "null", 3683 "null",
3674 "false", 3684 "false",
3675 "true", 3685 "true",
(...skipping 21 matching lines...) Expand all
3697 3707
3698 static const ParserFlag always_flags[] = { 3708 static const ParserFlag always_flags[] = {
3699 kAllowClasses, 3709 kAllowClasses,
3700 kAllowHarmonyObjectLiterals 3710 kAllowHarmonyObjectLiterals
3701 }; 3711 };
3702 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0, 3712 RunParserSyncTest(context_data, name_data, kSuccess, NULL, 0,
3703 always_flags, arraysize(always_flags)); 3713 always_flags, arraysize(always_flags));
3704 } 3714 }
3705 3715
3706 3716
3707 TEST(ErrorsClassExpression) { 3717 TEST(ClassExpressionErrors) {
3708 const char* context_data[][2] = {{"(", ");"}, 3718 const char* context_data[][2] = {{"(", ");"},
3709 {"var C = ", ";"}, 3719 {"var C = ", ";"},
3710 {"bar, ", ";"}, 3720 {"bar, ", ";"},
3711 {NULL, NULL}}; 3721 {NULL, NULL}};
3712 const char* class_data[] = { 3722 const char* class_data[] = {
3713 "class", 3723 "class",
3714 "class name", 3724 "class name",
3715 "class name extends", 3725 "class name extends",
3716 "class extends", 3726 "class extends",
3717 "class {", 3727 "class {",
(...skipping 10 matching lines...) Expand all
3728 3738
3729 static const ParserFlag always_flags[] = { 3739 static const ParserFlag always_flags[] = {
3730 kAllowClasses, 3740 kAllowClasses,
3731 kAllowHarmonyObjectLiterals 3741 kAllowHarmonyObjectLiterals
3732 }; 3742 };
3733 RunParserSyncTest(context_data, class_data, kError, NULL, 0, 3743 RunParserSyncTest(context_data, class_data, kError, NULL, 0,
3734 always_flags, arraysize(always_flags)); 3744 always_flags, arraysize(always_flags));
3735 } 3745 }
3736 3746
3737 3747
3738 TEST(ErrorsClassDeclaration) { 3748 TEST(ClassDeclarationErrors) {
3739 const char* context_data[][2] = {{"", ""}, 3749 const char* context_data[][2] = {{"", ""},
3740 {"{", "}"}, 3750 {"{", "}"},
3741 {"if (true) {", "}"}, 3751 {"if (true) {", "}"},
3742 {NULL, NULL}}; 3752 {NULL, NULL}};
3743 const char* class_data[] = { 3753 const char* class_data[] = {
3744 "class", 3754 "class",
3745 "class name", 3755 "class name",
3746 "class name extends", 3756 "class name extends",
3747 "class extends", 3757 "class extends",
3748 "class name {", 3758 "class name {",
3749 "class name { m }", 3759 "class name { m }",
3750 "class name { m; n }", 3760 "class name { m; n }",
3751 "class name { m: 1 }", 3761 "class name { m: 1 }",
3752 "class name { m(); n() }", 3762 "class name { m(); n() }",
3753 "class name { get m }", 3763 "class name { get x }",
3754 "class name { get m() }", 3764 "class name { get x() }",
3755 "class name { set m() {) }", // missing required param 3765 "class name { set x() {) }", // missing required param
3756 "class {}", // Name is required for declaration 3766 "class {}", // Name is required for declaration
3757 "class extends base {}", 3767 "class extends base {}",
3768 "class name { *",
3769 "class name { * }",
3770 "class name { *; }",
3771 "class name { *get x() {} }",
3772 "class name { *set x(_) {} }",
3773 "class name { *static m() {} }",
3758 NULL}; 3774 NULL};
3759 3775
3760 static const ParserFlag always_flags[] = { 3776 static const ParserFlag always_flags[] = {
3761 kAllowClasses, 3777 kAllowClasses,
3762 kAllowHarmonyNumericLiterals 3778 kAllowHarmonyNumericLiterals
3763 }; 3779 };
3764 RunParserSyncTest(context_data, class_data, kError, NULL, 0, 3780 RunParserSyncTest(context_data, class_data, kError, NULL, 0,
3765 always_flags, arraysize(always_flags)); 3781 always_flags, arraysize(always_flags));
3766 } 3782 }
3767 3783
3768 3784
3769 TEST(ErrorsClassName) { 3785 TEST(ClassNameErrors) {
3770 const char* context_data[][2] = {{"class ", "{}"}, 3786 const char* context_data[][2] = {{"class ", "{}"},
3771 {"(class ", "{});"}, 3787 {"(class ", "{});"},
3772 {"'use strict'; class ", "{}"}, 3788 {"'use strict'; class ", "{}"},
3773 {"'use strict'; (class ", "{});"}, 3789 {"'use strict'; (class ", "{});"},
3774 {NULL, NULL}}; 3790 {NULL, NULL}};
3775 const char* class_name[] = { 3791 const char* class_name[] = {
3776 "arguments", 3792 "arguments",
3777 "eval", 3793 "eval",
3778 "implements", 3794 "implements",
3779 "interface", 3795 "interface",
3780 "let", 3796 "let",
3781 "package", 3797 "package",
3782 "private", 3798 "private",
3783 "protected", 3799 "protected",
3784 "public", 3800 "public",
3785 "static", 3801 "static",
3786 "var", 3802 "var",
3787 "yield", 3803 "yield",
3788 NULL}; 3804 NULL};
3789 3805
3790 static const ParserFlag always_flags[] = { 3806 static const ParserFlag always_flags[] = {
3791 kAllowClasses, 3807 kAllowClasses,
3792 kAllowHarmonyObjectLiterals 3808 kAllowHarmonyObjectLiterals
3793 }; 3809 };
3794 RunParserSyncTest(context_data, class_name, kError, NULL, 0, 3810 RunParserSyncTest(context_data, class_name, kError, NULL, 0,
3795 always_flags, arraysize(always_flags)); 3811 always_flags, arraysize(always_flags));
3796 } 3812 }
3797 3813
3798 3814
3799 TEST(ErrorsClassGetterParamName) { 3815 TEST(ClassGetterParamNameErrors) {
3800 const char* context_data[][2] = { 3816 const char* context_data[][2] = {
3801 {"class C { get name(", ") {} }"}, 3817 {"class C { get name(", ") {} }"},
3802 {"(class { get name(", ") {} });"}, 3818 {"(class { get name(", ") {} });"},
3803 {"'use strict'; class C { get name(", ") {} }"}, 3819 {"'use strict'; class C { get name(", ") {} }"},
3804 {"'use strict'; (class { get name(", ") {} })"}, 3820 {"'use strict'; (class { get name(", ") {} })"},
3805 {NULL, NULL} 3821 {NULL, NULL}
3806 }; 3822 };
3807 3823
3808 const char* class_name[] = { 3824 const char* class_name[] = {
3809 "arguments", 3825 "arguments",
(...skipping 12 matching lines...) Expand all
3822 3838
3823 static const ParserFlag always_flags[] = { 3839 static const ParserFlag always_flags[] = {
3824 kAllowClasses, 3840 kAllowClasses,
3825 kAllowHarmonyObjectLiterals 3841 kAllowHarmonyObjectLiterals
3826 }; 3842 };
3827 RunParserSyncTest(context_data, class_name, kError, NULL, 0, 3843 RunParserSyncTest(context_data, class_name, kError, NULL, 0,
3828 always_flags, arraysize(always_flags)); 3844 always_flags, arraysize(always_flags));
3829 } 3845 }
3830 3846
3831 3847
3832 TEST(ErrorsClassStaticPrototype) { 3848 TEST(ClassStaticPrototypeErrors) {
3833 const char* context_data[][2] = {{"class C {", "}"}, 3849 const char* context_data[][2] = {{"class C {", "}"},
3834 {"(class {", "});"}, 3850 {"(class {", "});"},
3835 {NULL, NULL}}; 3851 {NULL, NULL}};
3836 3852
3837 const char* class_body_data[] = { 3853 const char* class_body_data[] = {
3838 "static prototype() {}", 3854 "static prototype() {}",
3839 "static get prototype() {}", 3855 "static get prototype() {}",
3840 "static set prototype(_) {}", 3856 "static set prototype(_) {}",
3857 "static *prototype() {}",
3841 NULL}; 3858 NULL};
3842 3859
3843 static const ParserFlag always_flags[] = { 3860 static const ParserFlag always_flags[] = {
3844 kAllowClasses, 3861 kAllowClasses,
3845 kAllowHarmonyObjectLiterals 3862 kAllowHarmonyObjectLiterals
3846 }; 3863 };
3847 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 3864 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
3848 always_flags, arraysize(always_flags)); 3865 always_flags, arraysize(always_flags));
3849 } 3866 }
3850 3867
3851 3868
3852 TEST(ErrorsClassSpecialConstructor) { 3869 TEST(ClassSpecialConstructorErrors) {
3853 const char* context_data[][2] = {{"class C {", "}"}, 3870 const char* context_data[][2] = {{"class C {", "}"},
3854 {"(class {", "});"}, 3871 {"(class {", "});"},
3855 {NULL, NULL}}; 3872 {NULL, NULL}};
3856 3873
3857 const char* class_body_data[] = { 3874 const char* class_body_data[] = {
3858 "get constructor() {}", 3875 "get constructor() {}",
3859 "get constructor(_) {}", 3876 "get constructor(_) {}",
3877 "*constructor() {}",
arv (Not doing code reviews) 2014/09/18 15:59:02 Andy, non static generator constructor is tested h
3860 NULL}; 3878 NULL};
3861 3879
3862 static const ParserFlag always_flags[] = { 3880 static const ParserFlag always_flags[] = {
3863 kAllowClasses, 3881 kAllowClasses,
3864 kAllowHarmonyObjectLiterals 3882 kAllowHarmonyObjectLiterals
3865 }; 3883 };
3866 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 3884 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
3867 always_flags, arraysize(always_flags)); 3885 always_flags, arraysize(always_flags));
3868 } 3886 }
3869 3887
3870 3888
3871 TEST(NoErrorsClassConstructor) { 3889 TEST(ClassConstructorNoErrors) {
3872 const char* context_data[][2] = {{"class C {", "}"}, 3890 const char* context_data[][2] = {{"class C {", "}"},
3873 {"(class {", "});"}, 3891 {"(class {", "});"},
3874 {NULL, NULL}}; 3892 {NULL, NULL}};
3875 3893
3876 const char* class_body_data[] = { 3894 const char* class_body_data[] = {
3877 "constructor() {}", 3895 "constructor() {}",
3878 "static constructor() {}", 3896 "static constructor() {}",
3879 "static get constructor() {}", 3897 "static get constructor() {}",
3880 "static set constructor(_) {}", 3898 "static set constructor(_) {}",
3899 "static *constructor() {}",
3881 NULL}; 3900 NULL};
3882 3901
3883 static const ParserFlag always_flags[] = { 3902 static const ParserFlag always_flags[] = {
3884 kAllowClasses, 3903 kAllowClasses,
3885 kAllowHarmonyObjectLiterals 3904 kAllowHarmonyObjectLiterals
3886 }; 3905 };
3887 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, 3906 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0,
3888 always_flags, arraysize(always_flags)); 3907 always_flags, arraysize(always_flags));
3889 } 3908 }
3890 3909
3891 3910
3892 TEST(ErrorsClassMultipleConstructor) { 3911 TEST(ClassMultipleConstructorErrors) {
3893 // We currently do not allow any duplicate properties in class bodies. This 3912 // We currently do not allow any duplicate properties in class bodies. This
3894 // test ensures that when we change that we still throw on duplicate 3913 // test ensures that when we change that we still throw on duplicate
3895 // constructors. 3914 // constructors.
3896 const char* context_data[][2] = {{"class C {", "}"}, 3915 const char* context_data[][2] = {{"class C {", "}"},
3897 {"(class {", "});"}, 3916 {"(class {", "});"},
3898 {NULL, NULL}}; 3917 {NULL, NULL}};
3899 3918
3900 const char* class_body_data[] = { 3919 const char* class_body_data[] = {
3901 "constructor() {}; constructor() {}", 3920 "constructor() {}; constructor() {}",
3902 NULL}; 3921 NULL};
3903 3922
3904 static const ParserFlag always_flags[] = { 3923 static const ParserFlag always_flags[] = {
3905 kAllowClasses, 3924 kAllowClasses,
3906 kAllowHarmonyObjectLiterals 3925 kAllowHarmonyObjectLiterals
3907 }; 3926 };
3908 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 3927 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
3909 always_flags, arraysize(always_flags)); 3928 always_flags, arraysize(always_flags));
3910 } 3929 }
3911 3930
3912 3931
3913 // TODO(arv): We should allow duplicate property names. 3932 // TODO(arv): We should allow duplicate property names.
3914 // https://code.google.com/p/v8/issues/detail?id=3570 3933 // https://code.google.com/p/v8/issues/detail?id=3570
3915 DISABLED_TEST(NoErrorsClassMultiplePropertyNames) { 3934 DISABLED_TEST(ClassMultiplePropertyNamesNoErrors) {
3916 const char* context_data[][2] = {{"class C {", "}"}, 3935 const char* context_data[][2] = {{"class C {", "}"},
3917 {"(class {", "});"}, 3936 {"(class {", "});"},
3918 {NULL, NULL}}; 3937 {NULL, NULL}};
3919 3938
3920 const char* class_body_data[] = { 3939 const char* class_body_data[] = {
3921 "constructor() {}; static constructor() {}", 3940 "constructor() {}; static constructor() {}",
3922 "m() {}; static m() {}", 3941 "m() {}; static m() {}",
3923 "m() {}; m() {}", 3942 "m() {}; m() {}",
3924 NULL}; 3943 NULL};
3925 3944
3926 static const ParserFlag always_flags[] = { 3945 static const ParserFlag always_flags[] = {
3927 kAllowClasses, 3946 kAllowClasses,
3928 kAllowHarmonyObjectLiterals 3947 kAllowHarmonyObjectLiterals
3929 }; 3948 };
3930 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0, 3949 RunParserSyncTest(context_data, class_body_data, kSuccess, NULL, 0,
3931 always_flags, arraysize(always_flags)); 3950 always_flags, arraysize(always_flags));
3932 } 3951 }
3933 3952
3934 3953
3935 TEST(ErrorsClassesAreStrict) { 3954 TEST(ClassesAreStrictErrors) {
3936 const char* context_data[][2] = {{"", ""}, 3955 const char* context_data[][2] = {{"", ""},
3937 {"(", ");"}, 3956 {"(", ");"},
3938 {NULL, NULL}}; 3957 {NULL, NULL}};
3939 3958
3940 const char* class_body_data[] = { 3959 const char* class_body_data[] = {
3941 "class C { method() { with ({}) {} } }", 3960 "class C { method() { with ({}) {} } }",
3942 "class C extends function() { with ({}) {} } {}", 3961 "class C extends function() { with ({}) {} } {}",
3962 "class C { *method() { with ({}) {} } }",
3943 NULL}; 3963 NULL};
3944 3964
3945 static const ParserFlag always_flags[] = { 3965 static const ParserFlag always_flags[] = {
3946 kAllowClasses, 3966 kAllowClasses,
3947 kAllowHarmonyObjectLiterals 3967 kAllowHarmonyObjectLiterals
3948 }; 3968 };
3949 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0, 3969 RunParserSyncTest(context_data, class_body_data, kError, NULL, 0,
3950 always_flags, arraysize(always_flags)); 3970 always_flags, arraysize(always_flags));
3951 } 3971 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/harmony/object-literals-method.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698