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

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

Issue 1164073003: [es6] super.prop, eval and lazy functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make the logger use 2 fields Created 5 years, 6 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
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/classes-lazy-parsing.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 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 { "var f = () => {", "};" }, 969 { "var f = () => {", "};" },
970 { "class C { constructor() {", "} }" }, 970 { "class C { constructor() {", "} }" },
971 }; 971 };
972 972
973 enum Expected { 973 enum Expected {
974 NONE = 0, 974 NONE = 0,
975 ARGUMENTS = 1, 975 ARGUMENTS = 1,
976 SUPER_PROPERTY = 1 << 1, 976 SUPER_PROPERTY = 1 << 1,
977 THIS = 1 << 2, 977 THIS = 1 << 2,
978 INNER_ARGUMENTS = 1 << 3, 978 INNER_ARGUMENTS = 1 << 3,
979 EVAL = 1 << 4
979 }; 980 };
980 981
981 // clang-format off 982 // clang-format off
982 static const struct { 983 static const struct {
983 const char* body; 984 const char* body;
984 int expected; 985 int expected;
985 } source_data[] = { 986 } source_data[] = {
986 {"", NONE}, 987 {"", NONE},
987 {"return this", THIS}, 988 {"return this", THIS},
988 {"return arguments", ARGUMENTS}, 989 {"return arguments", ARGUMENTS},
(...skipping 29 matching lines...) Expand all
1018 {"\"use strict\"; while (true) { let x; this, arguments; }", 1019 {"\"use strict\"; while (true) { let x; this, arguments; }",
1019 INNER_ARGUMENTS | THIS}, 1020 INNER_ARGUMENTS | THIS},
1020 {"\"use strict\"; while (true) { let x; this, super.f(), arguments; }", 1021 {"\"use strict\"; while (true) { let x; this, super.f(), arguments; }",
1021 INNER_ARGUMENTS | SUPER_PROPERTY | THIS}, 1022 INNER_ARGUMENTS | SUPER_PROPERTY | THIS},
1022 {"\"use strict\"; if (foo()) { let x; this.f() }", THIS}, 1023 {"\"use strict\"; if (foo()) { let x; this.f() }", THIS},
1023 {"\"use strict\"; if (foo()) { let x; super.f() }", SUPER_PROPERTY}, 1024 {"\"use strict\"; if (foo()) { let x; super.f() }", SUPER_PROPERTY},
1024 {"\"use strict\"; if (1) {" 1025 {"\"use strict\"; if (1) {"
1025 " let x; return { m() { return this + super.m() + arguments } }" 1026 " let x; return { m() { return this + super.m() + arguments } }"
1026 "}", 1027 "}",
1027 NONE}, 1028 NONE},
1029 {"eval(42)", EVAL},
1030 {"if (1) { eval(42) }", EVAL},
1031 {"eval('super.x')", EVAL},
1032 {"eval('this.x')", EVAL},
1033 {"eval('arguments')", EVAL},
1028 }; 1034 };
1029 // clang-format on 1035 // clang-format on
1030 1036
1031 i::Isolate* isolate = CcTest::i_isolate(); 1037 i::Isolate* isolate = CcTest::i_isolate();
1032 i::Factory* factory = isolate->factory(); 1038 i::Factory* factory = isolate->factory();
1033 1039
1034 v8::HandleScope handles(CcTest::isolate()); 1040 v8::HandleScope handles(CcTest::isolate());
1035 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate()); 1041 v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
1036 v8::Context::Scope context_scope(context); 1042 v8::Context::Scope context_scope(context);
1037 1043
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 scope->uses_arguments()); 1088 scope->uses_arguments());
1083 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, 1089 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0,
1084 scope->uses_super_property()); 1090 scope->uses_super_property());
1085 if ((source_data[i].expected & THIS) != 0) { 1091 if ((source_data[i].expected & THIS) != 0) {
1086 // Currently the is_used() flag is conservative; all variables in a 1092 // Currently the is_used() flag is conservative; all variables in a
1087 // script scope are marked as used. 1093 // script scope are marked as used.
1088 CHECK(scope->LookupThis()->is_used()); 1094 CHECK(scope->LookupThis()->is_used());
1089 } 1095 }
1090 CHECK_EQ((source_data[i].expected & INNER_ARGUMENTS) != 0, 1096 CHECK_EQ((source_data[i].expected & INNER_ARGUMENTS) != 0,
1091 scope->inner_uses_arguments()); 1097 scope->inner_uses_arguments());
1098 CHECK_EQ((source_data[i].expected & EVAL) != 0, scope->calls_eval());
1092 } 1099 }
1093 } 1100 }
1094 } 1101 }
1095 1102
1096 1103
1097 TEST(ScopePositions) { 1104 TEST(ScopePositions) {
1098 // Test the parser for correctly setting the start and end positions 1105 // Test the parser for correctly setting the start and end positions
1099 // of a scope. We check the scope positions of exactly one scope 1106 // of a scope. We check the scope positions of exactly one scope
1100 // nested in the global scope of a program. 'inner source' is the 1107 // nested in the global scope of a program. 'inner source' is the
1101 // source code that determines the part of the source belonging 1108 // source code that determines the part of the source belonging
(...skipping 5499 matching lines...) Expand 10 before | Expand all | Expand 10 after
6601 "[a, ...]", 6608 "[a, ...]",
6602 "[..., ]", 6609 "[..., ]",
6603 "[..., ...]", 6610 "[..., ...]",
6604 "[ (...a)]", 6611 "[ (...a)]",
6605 NULL}; 6612 NULL};
6606 // clang-format on 6613 // clang-format on
6607 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays}; 6614 static const ParserFlag always_flags[] = {kAllowHarmonySpreadArrays};
6608 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 6615 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
6609 arraysize(always_flags)); 6616 arraysize(always_flags));
6610 } 6617 }
OLDNEW
« no previous file with comments | « src/scopes.h ('k') | test/mjsunit/harmony/classes-lazy-parsing.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698