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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // Source containing functions that might be lazily compiled and all types | 213 // Source containing functions that might be lazily compiled and all types |
214 // of symbols (string, propertyName, regexp). | 214 // of symbols (string, propertyName, regexp). |
215 const char* source = | 215 const char* source = |
216 "var x = 42;" | 216 "var x = 42;" |
217 "function foo(a) { return function nolazy(b) { return a + b; } }" | 217 "function foo(a) { return function nolazy(b) { return a + b; } }" |
218 "function bar(a) { if (a) return function lazy(b) { return b; } }" | 218 "function bar(a) { if (a) return function lazy(b) { return b; } }" |
219 "var z = {'string': 'string literal', bareword: 'propertyName', " | 219 "var z = {'string': 'string literal', bareword: 'propertyName', " |
220 " 42: 'number literal', for: 'keyword as propertyName', " | 220 " 42: 'number literal', for: 'keyword as propertyName', " |
221 " f\\u006fr: 'keyword propertyname with escape'};" | 221 " f\\u006fr: 'keyword propertyname with escape'};" |
222 "var v = /RegExp Literal/;" | 222 "var v = /RegExp Literal/;" |
223 "var w = /RegExp Literal\\u0020With Escape/gin;" | 223 "var w = /RegExp Literal\\u0020With Escape/gi;" |
224 "var y = { get getter() { return 42; }, " | 224 "var y = { get getter() { return 42; }, " |
225 " set setter(v) { this.value = v; }};" | 225 " set setter(v) { this.value = v; }};" |
226 "var f = a => function (b) { return a + b; };" | 226 "var f = a => function (b) { return a + b; };" |
227 "var g = a => b => a + b;"; | 227 "var g = a => b => a + b;"; |
228 int source_length = i::StrLength(source); | 228 int source_length = i::StrLength(source); |
229 | 229 |
230 // ScriptResource will be deleted when the corresponding String is GCd. | 230 // ScriptResource will be deleted when the corresponding String is GCd. |
231 v8::ScriptCompiler::Source script_source( | 231 v8::ScriptCompiler::Source script_source( |
232 v8::String::NewExternalOneByte(isolate, | 232 v8::String::NewExternalOneByte(isolate, |
233 new ScriptResource(source, source_length)) | 233 new ScriptResource(source, source_length)) |
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2788 | 2788 |
2789 TEST(NoErrorsRegexpLiteral) { | 2789 TEST(NoErrorsRegexpLiteral) { |
2790 const char* context_data[][2] = { | 2790 const char* context_data[][2] = { |
2791 {"var r = ", ""}, | 2791 {"var r = ", ""}, |
2792 { NULL, NULL } | 2792 { NULL, NULL } |
2793 }; | 2793 }; |
2794 | 2794 |
2795 const char* statement_data[] = { | 2795 const char* statement_data[] = { |
2796 "/foo/", | 2796 "/foo/", |
2797 "/foo/g", | 2797 "/foo/g", |
2798 "/foo/whatever", // This is an error but not detected by the parser. | |
2799 NULL | 2798 NULL |
2800 }; | 2799 }; |
2801 | 2800 |
2802 RunParserSyncTest(context_data, statement_data, kSuccess); | 2801 RunParserSyncTest(context_data, statement_data, kSuccess); |
2803 } | 2802 } |
2804 | 2803 |
2805 | 2804 |
2806 TEST(NoErrorsNewExpression) { | 2805 TEST(NoErrorsNewExpression) { |
2807 const char* context_data[][2] = { | 2806 const char* context_data[][2] = { |
2808 {"", ""}, | 2807 {"", ""}, |
(...skipping 4671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7480 "var publ\\u0069c = 1;", | 7479 "var publ\\u0069c = 1;", |
7481 "var { publ\\u0069c } = {};", | 7480 "var { publ\\u0069c } = {};", |
7482 NULL}; | 7481 NULL}; |
7483 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, | 7482 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, |
7484 always_flags, arraysize(always_flags)); | 7483 always_flags, arraysize(always_flags)); |
7485 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7484 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
7486 always_flags, arraysize(always_flags)); | 7485 always_flags, arraysize(always_flags)); |
7487 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7486 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
7488 always_flags, arraysize(always_flags)); | 7487 always_flags, arraysize(always_flags)); |
7489 } | 7488 } |
OLD | NEW |