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 4891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4902 const char* data[] = { | 4902 const char* data[] = { |
| 4903 "for(const x = 1; ; ) {}", | 4903 "for(const x = 1; ; ) {}", |
| 4904 "for(const x = 1, y = 2;;){}", | 4904 "for(const x = 1, y = 2;;){}", |
| 4905 "for(const x in [1,2,3]) {}", | 4905 "for(const x in [1,2,3]) {}", |
| 4906 "for(const x of [1,2,3]) {}", | 4906 "for(const x of [1,2,3]) {}", |
| 4907 NULL}; | 4907 NULL}; |
| 4908 RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0); | 4908 RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0); |
| 4909 } | 4909 } |
| 4910 | 4910 |
| 4911 | 4911 |
| 4912 TEST(StatementParsingInForIn) { | |
| 4913 const char* context_data[][2] = {{"'use strict';", ""}, | |
|
adamk
2016/01/20 00:35:57
Can you add non-strict cases too? Seems like the m
mike3
2016/01/20 17:55:40
I've omitted strict mode because I was following t
adamk
2016/01/20 19:31:17
Outside strict mode, v8 will parse lexical declara
mike3
2016/01/20 19:54:08
Thanks for the pointer! (It's been a while since I
| |
| 4914 {"function foo(){ 'use strict';", "}"}, | |
| 4915 {NULL, NULL}}; | |
| 4916 | |
| 4917 const char* data[] = {"for(x in {}, {}) {}", "for(var x in {}, {}) {}", | |
| 4918 "for(let x in {}, {}) {}", "for(const x in {}, {}) {}", | |
| 4919 NULL}; | |
| 4920 RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0); | |
|
adamk
2016/01/20 00:35:57
You can leave off the last 4 arguments here (they
mike3
2016/01/20 17:55:40
Acknowledged.
| |
| 4921 } | |
| 4922 | |
| 4923 | |
| 4912 TEST(ConstParsingInForInError) { | 4924 TEST(ConstParsingInForInError) { |
| 4913 const char* context_data[][2] = {{"'use strict';", ""}, | 4925 const char* context_data[][2] = {{"'use strict';", ""}, |
| 4914 {"function foo(){ 'use strict';", "}"}, | 4926 {"function foo(){ 'use strict';", "}"}, |
| 4915 {NULL, NULL}}; | 4927 {NULL, NULL}}; |
| 4916 | 4928 |
| 4917 const char* data[] = { | 4929 const char* data[] = { |
| 4918 "for(const x,y = 1; ; ) {}", | 4930 "for(const x,y = 1; ; ) {}", |
| 4919 "for(const x = 4 in [1,2,3]) {}", | 4931 "for(const x = 4 in [1,2,3]) {}", |
| 4920 "for(const x = 4, y in [1,2,3]) {}", | 4932 "for(const x = 4, y in [1,2,3]) {}", |
| 4921 "for(const x = 4 of [1,2,3]) {}", | 4933 "for(const x = 4 of [1,2,3]) {}", |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5075 const char* data[] = { | 5087 const char* data[] = { |
| 5076 "for (var of [1, 2, 3]) {}", | 5088 "for (var of [1, 2, 3]) {}", |
| 5077 "for (const of [1, 2, 3]) {}", | 5089 "for (const of [1, 2, 3]) {}", |
| 5078 NULL}; | 5090 NULL}; |
| 5079 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; | 5091 static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
| 5080 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, | 5092 RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
| 5081 arraysize(always_flags)); | 5093 arraysize(always_flags)); |
| 5082 } | 5094 } |
| 5083 | 5095 |
| 5084 | 5096 |
| 5097 TEST(ForOfInOperator) { | |
| 5098 const char* context_data[][2] = {{"'use strict';", ""}, | |
| 5099 {"function foo(){ 'use strict';", "}"}, | |
| 5100 {NULL, NULL}}; | |
| 5101 | |
| 5102 const char* data[] = { | |
| 5103 "for(x of 'foo' in {}) {}", "for(var x of 'foo' in {}) {}", | |
| 5104 "for(let x of 'foo' in {}) {}", "for(const x of 'foo' in {}) {}", NULL}; | |
| 5105 RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0); | |
| 5106 } | |
| 5107 | |
| 5108 | |
| 5109 TEST(ForOfYieldIdentifier) { | |
| 5110 const char* context_data[][2] = {{NULL, NULL}}; | |
|
adamk
2016/01/20 00:35:57
This won't actually run any tests, since you haven
mike3
2016/01/20 17:55:40
Acknowledged.
| |
| 5111 | |
| 5112 const char* data[] = {"for(x of yield) {}", "for(var x of yield) {}", | |
|
adamk
2016/01/20 00:38:09
Also curious why you added tests for yield, that s
mike3
2016/01/20 17:55:40
I was thinking it would be good to be thorough, si
adamk
2016/01/20 19:31:17
It's fine to leave them in, thanks for the explana
| |
| 5113 "for(let x of yield) {}", "for(const x of yield) {}", | |
| 5114 NULL}; | |
| 5115 RunParserSyncTest(context_data, data, kSuccess, nullptr, 0, nullptr, 0); | |
| 5116 } | |
| 5117 | |
| 5118 | |
| 5119 TEST(ForOfYieldExpressionError) { | |
|
adamk
2016/01/20 00:35:57
This name seems wrong.
mike3
2016/01/20 17:55:40
Acknowledged.
| |
| 5120 const char* context_data[][2] = {{"'use strict';", ""}, | |
|
adamk
2016/01/20 00:35:57
Again, non-strict versions would be good too, same
| |
| 5121 {"function foo(){ 'use strict';", "}"}, | |
| 5122 {NULL, NULL}}; | |
| 5123 | |
| 5124 const char* data[] = {"(function* g() { for(x of [], []) {} }", | |
| 5125 "(function* g() { for(var x of [], []) {} }", | |
| 5126 "(function* g() { for(let x of [], []) {} }", | |
| 5127 "(function* g() { for(const x of [], []) {} }", NULL}; | |
| 5128 RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0); | |
| 5129 } | |
| 5130 | |
| 5131 | |
| 5132 TEST(ForOfExpressionError) { | |
| 5133 const char* context_data[][2] = {{"'use strict';", ""}, | |
| 5134 {"function foo(){ 'use strict';", "}"}, | |
| 5135 {NULL, NULL}}; | |
| 5136 | |
| 5137 const char* data[] = { | |
| 5138 "for(x of [], []) {}", "for(var x of [], []) {}", | |
| 5139 "for(let x of [], []) {}", "for(const x of [], []) {}", | |
| 5140 | |
| 5141 // AssignmentExpression should be validated statically: | |
| 5142 "for(x of { y = 23 }) {}", "for(var x of { y = 23 }) {}", | |
| 5143 "for(let x of { y = 23 }) {}", "for(const x of { y = 23 }) {}", NULL}; | |
| 5144 RunParserSyncTest(context_data, data, kError, nullptr, 0, nullptr, 0); | |
| 5145 } | |
| 5146 | |
| 5147 | |
| 5085 TEST(InvalidUnicodeEscapes) { | 5148 TEST(InvalidUnicodeEscapes) { |
| 5086 const char* context_data[][2] = {{"", ""}, | 5149 const char* context_data[][2] = {{"", ""}, |
| 5087 {"'use strict';", ""}, | 5150 {"'use strict';", ""}, |
| 5088 {NULL, NULL}}; | 5151 {NULL, NULL}}; |
| 5089 const char* data[] = { | 5152 const char* data[] = { |
| 5090 "var foob\\u123r = 0;", | 5153 "var foob\\u123r = 0;", |
| 5091 "var \\u123roo = 0;", | 5154 "var \\u123roo = 0;", |
| 5092 "\"foob\\u123rr\"", | 5155 "\"foob\\u123rr\"", |
| 5093 // No escapes allowed in regexp flags | 5156 // No escapes allowed in regexp flags |
| 5094 "/regex/\\u0069g", | 5157 "/regex/\\u0069g", |
| (...skipping 2743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7838 } | 7901 } |
| 7839 | 7902 |
| 7840 | 7903 |
| 7841 TEST(MiscSyntaxErrors) { | 7904 TEST(MiscSyntaxErrors) { |
| 7842 const char* context_data[][2] = { | 7905 const char* context_data[][2] = { |
| 7843 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7906 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
| 7844 const char* error_data[] = {"for (();;) {}", NULL}; | 7907 const char* error_data[] = {"for (();;) {}", NULL}; |
| 7845 | 7908 |
| 7846 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7909 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
| 7847 } | 7910 } |
| OLD | NEW |