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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1819123002: Remove support for legacy const, part 1 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased, deleted one more file Created 4 years, 9 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <fstream> 5 #include <fstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/interpreter/bytecode-array-iterator.h" 10 #include "src/interpreter/bytecode-array-iterator.h"
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 1489
1490 "function f(a, ...restArgs) { return restArgs[0]; }", 1490 "function f(a, ...restArgs) { return restArgs[0]; }",
1491 1491
1492 "function f(a, ...restArgs) { return restArgs[0] + arguments[0]; }", 1492 "function f(a, ...restArgs) { return restArgs[0] + arguments[0]; }",
1493 }; 1493 };
1494 1494
1495 CHECK_EQ(BuildActual(printer, snippets, "", "\nf();"), 1495 CHECK_EQ(BuildActual(printer, snippets, "", "\nf();"),
1496 LoadGolden("CreateRestParameter.golden")); 1496 LoadGolden("CreateRestParameter.golden"));
1497 } 1497 }
1498 1498
1499 TEST(IllegalRedeclaration) {
1500 bool old_legacy_const_flag = FLAG_legacy_const;
1501 FLAG_legacy_const = true;
1502
1503 CHECK_GE(MessageTemplate::kVarRedeclaration, 128);
1504 // Must adapt bytecode if this changes.
1505
1506 InitializedIgnitionHandleScope scope;
1507 BytecodeExpectationsPrinter printer(CcTest::isolate(),
1508 ConstantPoolType::kMixed);
1509 const char* snippets[] = {"const a = 1; { var a = 2; }"};
1510
1511 CHECK_EQ(BuildActual(printer, snippets),
1512 LoadGolden("IllegalRedeclaration.golden"));
1513
1514 FLAG_legacy_const = old_legacy_const_flag;
1515 }
1516
1517 TEST(ForIn) { 1499 TEST(ForIn) {
1518 InitializedIgnitionHandleScope scope; 1500 InitializedIgnitionHandleScope scope;
1519 BytecodeExpectationsPrinter printer(CcTest::isolate(), 1501 BytecodeExpectationsPrinter printer(CcTest::isolate(),
1520 ConstantPoolType::kMixed); 1502 ConstantPoolType::kMixed);
1521 const char* snippets[] = { 1503 const char* snippets[] = {
1522 "for (var p in null) {}", 1504 "for (var p in null) {}",
1523 1505
1524 "for (var p in undefined) {}", 1506 "for (var p in undefined) {}",
1525 1507
1526 "for (var p in undefined) {}", 1508 "for (var p in undefined) {}",
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 "let x = 10; return x;", 1977 "let x = 10; return x;",
1996 1978
1997 "let x = (x = 20);", 1979 "let x = (x = 20);",
1998 1980
1999 "let x = 10; x = 20;", 1981 "let x = 10; x = 20;",
2000 }; 1982 };
2001 1983
2002 CHECK_EQ(BuildActual(printer, snippets), LoadGolden("LetVariable.golden")); 1984 CHECK_EQ(BuildActual(printer, snippets), LoadGolden("LetVariable.golden"));
2003 } 1985 }
2004 1986
2005 TEST(LegacyConstVariable) {
2006 bool old_legacy_const_flag = FLAG_legacy_const;
2007 FLAG_legacy_const = true;
2008
2009 InitializedIgnitionHandleScope scope;
2010 BytecodeExpectationsPrinter printer(CcTest::isolate(),
2011 ConstantPoolType::kString);
2012 const char* snippets[] = {
2013 "const x = 10;",
2014
2015 "const x = 10; return x;",
2016
2017 "const x = ( x = 20);",
2018
2019 "const x = 10; x = 20;",
2020 };
2021
2022 CHECK_EQ(BuildActual(printer, snippets),
2023 LoadGolden("LegacyConstVariable.golden"));
2024
2025 FLAG_legacy_const = old_legacy_const_flag;
2026 }
2027
2028 TEST(ConstVariableContextSlot) { 1987 TEST(ConstVariableContextSlot) {
2029 // TODO(mythria): Add tests for initialization of this via super calls. 1988 // TODO(mythria): Add tests for initialization of this via super calls.
2030 // TODO(mythria): Add tests that walk the context chain. 1989 // TODO(mythria): Add tests that walk the context chain.
2031 InitializedIgnitionHandleScope scope; 1990 InitializedIgnitionHandleScope scope;
2032 BytecodeExpectationsPrinter printer(CcTest::isolate(), 1991 BytecodeExpectationsPrinter printer(CcTest::isolate(),
2033 ConstantPoolType::kMixed); 1992 ConstantPoolType::kMixed);
2034 const char* snippets[] = { 1993 const char* snippets[] = {
2035 "const x = 10; function f1() {return x;}", 1994 "const x = 10; function f1() {return x;}",
2036 1995
2037 "const x = 10; function f1() {return x;} return x;", 1996 "const x = 10; function f1() {return x;} return x;",
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 "})();\n", 2150 "})();\n",
2192 }; 2151 };
2193 2152
2194 CHECK_EQ(BuildActual(printer, snippets), 2153 CHECK_EQ(BuildActual(printer, snippets),
2195 LoadGolden("ClassAndSuperClass.golden")); 2154 LoadGolden("ClassAndSuperClass.golden"));
2196 } 2155 }
2197 2156
2198 } // namespace interpreter 2157 } // namespace interpreter
2199 } // namespace internal 2158 } // namespace internal
2200 } // namespace v8 2159 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/generate-bytecode-expectations.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698