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

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

Issue 446023002: Enable ES6 iteration by default (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moved tests to es6, fixed duplicate ExtendArrayPrototype name in unscopables.js Created 6 years, 4 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/unscopables.js ('k') | test/mjsunit/builtins.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 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1201 return i::Handle<i::String>::cast(result); 1201 return i::Handle<i::String>::cast(result);
1202 } 1202 }
1203 1203
1204 1204
1205 enum ParserFlag { 1205 enum ParserFlag {
1206 kAllowLazy, 1206 kAllowLazy,
1207 kAllowNativesSyntax, 1207 kAllowNativesSyntax,
1208 kAllowHarmonyScoping, 1208 kAllowHarmonyScoping,
1209 kAllowModules, 1209 kAllowModules,
1210 kAllowGenerators, 1210 kAllowGenerators,
1211 kAllowForOf,
1212 kAllowHarmonyNumericLiterals, 1211 kAllowHarmonyNumericLiterals,
1213 kAllowArrowFunctions 1212 kAllowArrowFunctions
1214 }; 1213 };
1215 1214
1216 1215
1217 enum ParserSyncTestResult { 1216 enum ParserSyncTestResult {
1218 kSuccessOrError, 1217 kSuccessOrError,
1219 kSuccess, 1218 kSuccess,
1220 kError 1219 kError
1221 }; 1220 };
1222 1221
1223 template <typename Traits> 1222 template <typename Traits>
1224 void SetParserFlags(i::ParserBase<Traits>* parser, 1223 void SetParserFlags(i::ParserBase<Traits>* parser,
1225 i::EnumSet<ParserFlag> flags) { 1224 i::EnumSet<ParserFlag> flags) {
1226 parser->set_allow_lazy(flags.Contains(kAllowLazy)); 1225 parser->set_allow_lazy(flags.Contains(kAllowLazy));
1227 parser->set_allow_natives_syntax(flags.Contains(kAllowNativesSyntax)); 1226 parser->set_allow_natives_syntax(flags.Contains(kAllowNativesSyntax));
1228 parser->set_allow_harmony_scoping(flags.Contains(kAllowHarmonyScoping)); 1227 parser->set_allow_harmony_scoping(flags.Contains(kAllowHarmonyScoping));
1229 parser->set_allow_modules(flags.Contains(kAllowModules)); 1228 parser->set_allow_modules(flags.Contains(kAllowModules));
1230 parser->set_allow_generators(flags.Contains(kAllowGenerators)); 1229 parser->set_allow_generators(flags.Contains(kAllowGenerators));
1231 parser->set_allow_for_of(flags.Contains(kAllowForOf));
1232 parser->set_allow_harmony_numeric_literals( 1230 parser->set_allow_harmony_numeric_literals(
1233 flags.Contains(kAllowHarmonyNumericLiterals)); 1231 flags.Contains(kAllowHarmonyNumericLiterals));
1234 parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions)); 1232 parser->set_allow_arrow_functions(flags.Contains(kAllowArrowFunctions));
1235 } 1233 }
1236 1234
1237 1235
1238 void TestParserSyncWithFlags(i::Handle<i::String> source, 1236 void TestParserSyncWithFlags(i::Handle<i::String> source,
1239 i::EnumSet<ParserFlag> flags, 1237 i::EnumSet<ParserFlag> flags,
1240 ParserSyncTestResult result) { 1238 ParserSyncTestResult result) {
1241 i::Isolate* isolate = CcTest::i_isolate(); 1239 i::Isolate* isolate = CcTest::i_isolate();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 NULL 1427 NULL
1430 }; 1428 };
1431 1429
1432 v8::HandleScope handles(CcTest::isolate()); 1430 v8::HandleScope handles(CcTest::isolate());
1433 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 1431 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
1434 v8::Context::Scope context_scope(context); 1432 v8::Context::Scope context_scope(context);
1435 1433
1436 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 1434 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
1437 128 * 1024); 1435 128 * 1024);
1438 1436
1439 static const ParserFlag flags1[] = { 1437 static const ParserFlag flags1[] = {kAllowLazy, kAllowHarmonyScoping,
1440 kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators, 1438 kAllowModules, kAllowGenerators,
1441 kAllowForOf, kAllowArrowFunctions 1439 kAllowArrowFunctions};
1442 };
1443 for (int i = 0; context_data[i][0] != NULL; ++i) { 1440 for (int i = 0; context_data[i][0] != NULL; ++i) {
1444 for (int j = 0; statement_data[j] != NULL; ++j) { 1441 for (int j = 0; statement_data[j] != NULL; ++j) {
1445 for (int k = 0; termination_data[k] != NULL; ++k) { 1442 for (int k = 0; termination_data[k] != NULL; ++k) {
1446 int kPrefixLen = i::StrLength(context_data[i][0]); 1443 int kPrefixLen = i::StrLength(context_data[i][0]);
1447 int kStatementLen = i::StrLength(statement_data[j]); 1444 int kStatementLen = i::StrLength(statement_data[j]);
1448 int kTerminationLen = i::StrLength(termination_data[k]); 1445 int kTerminationLen = i::StrLength(termination_data[k]);
1449 int kSuffixLen = i::StrLength(context_data[i][1]); 1446 int kSuffixLen = i::StrLength(context_data[i][1]);
1450 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen 1447 int kProgramSize = kPrefixLen + kStatementLen + kTerminationLen
1451 + kSuffixLen + i::StrLength("label: for (;;) { }"); 1448 + kSuffixLen + i::StrLength("label: for (;;) { }");
1452 1449
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 const ParserFlag* always_true_flags = NULL, 1504 const ParserFlag* always_true_flags = NULL,
1508 int always_true_flags_len = 0) { 1505 int always_true_flags_len = 0) {
1509 v8::HandleScope handles(CcTest::isolate()); 1506 v8::HandleScope handles(CcTest::isolate());
1510 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 1507 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
1511 v8::Context::Scope context_scope(context); 1508 v8::Context::Scope context_scope(context);
1512 1509
1513 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() - 1510 CcTest::i_isolate()->stack_guard()->SetStackLimit(GetCurrentStackPosition() -
1514 128 * 1024); 1511 128 * 1024);
1515 1512
1516 static const ParserFlag default_flags[] = { 1513 static const ParserFlag default_flags[] = {
1517 kAllowLazy, kAllowHarmonyScoping, kAllowModules, kAllowGenerators, 1514 kAllowLazy, kAllowHarmonyScoping, kAllowModules,
1518 kAllowForOf, kAllowNativesSyntax, kAllowArrowFunctions 1515 kAllowGenerators, kAllowNativesSyntax, kAllowArrowFunctions};
1519 };
1520 ParserFlag* generated_flags = NULL; 1516 ParserFlag* generated_flags = NULL;
1521 if (flags == NULL) { 1517 if (flags == NULL) {
1522 flags = default_flags; 1518 flags = default_flags;
1523 flags_len = ARRAY_SIZE(default_flags); 1519 flags_len = ARRAY_SIZE(default_flags);
1524 if (always_true_flags != NULL) { 1520 if (always_true_flags != NULL) {
1525 // Remove always_true_flags from default_flags. 1521 // Remove always_true_flags from default_flags.
1526 CHECK(always_true_flags_len < flags_len); 1522 CHECK(always_true_flags_len < flags_len);
1527 generated_flags = new ParserFlag[flags_len - always_true_flags_len]; 1523 generated_flags = new ParserFlag[flags_len - always_true_flags_len];
1528 int flag_index = 0; 1524 int flag_index = 0;
1529 for (int i = 0; i < flags_len; ++i) { 1525 for (int i = 0; i < flags_len; ++i) {
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 3336
3341 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) 3337 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {})
3342 "foo ? bar : baz => {}", 3338 "foo ? bar : baz => {}",
3343 NULL 3339 NULL
3344 }; 3340 };
3345 3341
3346 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; 3342 static const ParserFlag always_flags[] = {kAllowArrowFunctions};
3347 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, 3343 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
3348 always_flags, ARRAY_SIZE(always_flags)); 3344 always_flags, ARRAY_SIZE(always_flags));
3349 } 3345 }
OLDNEW
« no previous file with comments | « src/unscopables.js ('k') | test/mjsunit/builtins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698