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 7849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7860 static const ParserFlag always_flags[] = {kAllowTypes}; | 7860 static const ParserFlag always_flags[] = {kAllowTypes}; |
| 7861 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, | 7861 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, |
| 7862 always_flags, arraysize(always_flags)); | 7862 always_flags, arraysize(always_flags)); |
| 7863 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, | 7863 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, |
| 7864 always_flags, arraysize(always_flags)); | 7864 always_flags, arraysize(always_flags)); |
| 7865 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, | 7865 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, |
| 7866 always_flags, arraysize(always_flags)); | 7866 always_flags, arraysize(always_flags)); |
| 7867 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, | 7867 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, |
| 7868 always_flags, arraysize(always_flags)); | 7868 always_flags, arraysize(always_flags)); |
| 7869 } | 7869 } |
| 7870 | |
| 7871 TEST(TypedModeClassDeclarations) { | |
| 7872 const char* untyped_context_data[][2] = {{"", ""}, {NULL, NULL}}; | |
| 7873 const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}}; | |
| 7874 | |
| 7875 const char* correct_data[] = { | |
| 7876 "class C { f(x: number) : boolean { return x == 42; } }", | |
| 7877 "class D extends C { g<A>(x: A[]) : A { return x[0]; } }", | |
| 7878 "class E extends D implements I, J {}", | |
| 7879 "class F<A> extends D implements I<A>, J<number, A> {}", | |
| 7880 "class C { x; y=42; z: number; w: number = 17; }", | |
| 7881 "class C { [x: string]; }", | |
| 7882 "class C { [x: number]; }", | |
| 7883 "class C { [x: string] : boolean; }", | |
| 7884 "class C { [x: number] : boolean; }", | |
| 7885 NULL | |
| 7886 }; | |
| 7887 | |
| 7888 const char* error_data[] = { | |
| 7889 "class C { f(x: number) : () {} }", | |
| 7890 "class D implements () {}", | |
| 7891 "class E implements number[] {}", | |
| 7892 "class F implements I<> {}", | |
|
rossberg
2016/04/18 11:03:08
class implements {}
class C implements {}
class im
nickie
2016/04/19 14:55:30
Done.
| |
| 7893 "class E<> {}", | |
| 7894 "class C { x: (); }", | |
| 7895 "class C { [42]; }", | |
| 7896 "class C { [42] : number; }", | |
| 7897 "class C { [x: any]; }", | |
| 7898 "class C { [x: any] : any; }", | |
| 7899 "class C { static [x: number]; }", | |
| 7900 NULL | |
| 7901 }; | |
| 7902 | |
| 7903 static const ParserFlag always_flags[] = {kAllowTypes}; | |
| 7904 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, | |
| 7905 always_flags, arraysize(always_flags)); | |
| 7906 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, | |
| 7907 always_flags, arraysize(always_flags)); | |
| 7908 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, | |
| 7909 always_flags, arraysize(always_flags)); | |
| 7910 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, | |
| 7911 always_flags, arraysize(always_flags)); | |
| 7912 } | |
| OLD | NEW |