v8/test/unittests/torque/torque-unittest.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.6 KiB
C++
Raw Normal View History

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/torque/torque-compiler.h"
#include "src/torque/utils.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
namespace v8 {
namespace internal {
namespace torque {
namespace {
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
TorqueCompilerResult TestCompileTorque(const std::string& source) {
TorqueCompilerOptions options;
options.output_directory = "";
options.collect_language_server_data = false;
options.force_assert_statements = false;
return CompileTorque(source, options);
}
} // namespace
TEST(Torque, StackDeleteRange) {
Stack<int> stack = {1, 2, 3, 4, 5, 6, 7};
stack.DeleteRange(StackRange{BottomOffset{2}, BottomOffset{4}});
Stack<int> result = {1, 2, 5, 6, 7};
ASSERT_TRUE(stack == result);
}
using ::testing::HasSubstr;
TEST(Torque, TypeNamingConventionLintError) {
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
std::string source = R"(
type void;
type never;
type foo generates 'TNode<Foo>';
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
)";
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
const TorqueCompilerResult result = TestCompileTorque(source);
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
ASSERT_EQ(result.messages.size(), static_cast<size_t>(1));
EXPECT_THAT(result.messages[0].message, HasSubstr("\"foo\""));
}
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
TEST(Torque, StructNamingConventionLintError) {
const std::string source = R"(
type void;
type never;
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
struct foo {}
)";
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
const TorqueCompilerResult result = TestCompileTorque(source);
Revert "Reland "[torque] move class tests to unittests"" This reverts commit c33a1ef227bba6d7b442170fcee8ba01c45316d6. Reason for revert: fails win32 test: https://ci.chromium.org/p/v8/builders/ci/V8%20Win32%20-%20nosnap%20-%20shared/33658 Original change's description: > Reland "[torque] move class tests to unittests" > > This is a reland of f589d56101783d915f8350fd64dc89c9557022e6 > > Now with an ASAN-container-overflow false positive workaround: > Somehow ASAN was unhappy about a simple > std::vector<std::string>::push_back. > Increasing the std::vector capacity before doing the push_back > strangely fixes the problem. > > Original change's description: > > [torque] move class tests to unittests > > > > This avoids the generation of fake external classes. > > > > Bug: v8:7793 > > Change-Id: I9744b299d3ec474d72b298b4f6143f95e345d1d9 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1625991 > > Reviewed-by: Simon Zünd <szuend@chromium.org> > > Reviewed-by: Sigurd Schneider <sigurds@chromium.org> > > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#61778} > > TBR: szuend@chromium.org, sigurds@chromium.org > Bug: v8:7793 > Change-Id: Ifa1958e4d6e850ba27632aa95c7efaf5ca4bfefa > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627970 > Commit-Queue: Tobias Tebbi <tebbi@chromium.org> > Reviewed-by: Tobias Tebbi <tebbi@chromium.org> > Cr-Commit-Position: refs/heads/master@{#61807} TBR=sigurds@chromium.org,tebbi@chromium.org,szuend@chromium.org Change-Id: I079e3ccf2c7a4778e3e6aabee85313ab5a070ee3 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: v8:7793 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1626834 Reviewed-by: Francis McCabe <fgm@chromium.org> Commit-Queue: Francis McCabe <fgm@chromium.org> Cr-Commit-Position: refs/heads/master@{#61808}
2019-05-23 21:38:11 +00:00
ASSERT_EQ(result.messages.size(), static_cast<size_t>(1));
EXPECT_THAT(result.messages[0].message, HasSubstr("\"foo\""));
}
} // namespace torque
} // namespace internal
} // namespace v8