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 7819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7830 static const ParserFlag always_flags[] = {kAllowTypes}; | 7830 static const ParserFlag always_flags[] = {kAllowTypes}; |
7831 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, | 7831 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, |
7832 always_flags, arraysize(always_flags)); | 7832 always_flags, arraysize(always_flags)); |
7833 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, | 7833 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, |
7834 always_flags, arraysize(always_flags)); | 7834 always_flags, arraysize(always_flags)); |
7835 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, | 7835 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, |
7836 always_flags, arraysize(always_flags)); | 7836 always_flags, arraysize(always_flags)); |
7837 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, | 7837 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, |
7838 always_flags, arraysize(always_flags)); | 7838 always_flags, arraysize(always_flags)); |
7839 } | 7839 } |
| 7840 |
| 7841 TEST(TypedModeTypeAliases) { |
| 7842 const char* untyped_context_data[][2] = {{"", ""}, {NULL, NULL}}; |
| 7843 const char* typed_context_data[][2] = {{"'use types'; ", ""}, {NULL, NULL}}; |
| 7844 |
| 7845 const char* correct_data[] = { |
| 7846 "type NumArray = number[]", |
| 7847 "type Fun = (x: number) => number", |
| 7848 "type Tree<A> = A | Tree<A>[]", |
| 7849 NULL |
| 7850 }; |
| 7851 |
| 7852 const char* error_data[] = { |
| 7853 "type Err<> = number", |
| 7854 "type Err", |
| 7855 "type Err =", |
| 7856 "type Err = ()", |
| 7857 NULL |
| 7858 }; |
| 7859 |
| 7860 const char* type_as_identifier_data[] = { |
| 7861 "type", |
| 7862 "type = number+1", |
| 7863 "type(1, 2, 3)", |
| 7864 "type\n42", |
| 7865 NULL |
| 7866 }; |
| 7867 |
| 7868 static const ParserFlag always_flags[] = {kAllowTypes}; |
| 7869 RunParserSyncTest(untyped_context_data, correct_data, kError, NULL, 0, |
| 7870 always_flags, arraysize(always_flags)); |
| 7871 RunParserSyncTest(typed_context_data, correct_data, kSuccess, NULL, 0, |
| 7872 always_flags, arraysize(always_flags)); |
| 7873 RunParserSyncTest(untyped_context_data, error_data, kError, NULL, 0, |
| 7874 always_flags, arraysize(always_flags)); |
| 7875 RunParserSyncTest(typed_context_data, error_data, kError, NULL, 0, |
| 7876 always_flags, arraysize(always_flags)); |
| 7877 RunParserSyncTest(untyped_context_data, type_as_identifier_data, kSuccess, |
| 7878 NULL, 0, always_flags, arraysize(always_flags)); |
| 7879 RunParserSyncTest(typed_context_data, type_as_identifier_data, kSuccess, |
| 7880 NULL, 0, always_flags, arraysize(always_flags)); |
| 7881 } |
OLD | NEW |