2e3862d750
This is a reland of 2d45ecf09f
The reland properly initializes struct fields in unittests. To prevent
this in the future, TorqueCompilerOptions uses brace initialization.
Original change's description:
> [torque] Introduce force_assert_statements compiler option
>
> "assert(...)" statements are usually only visited and generated in
> debug builds. To provide Language Server support for statements inside
> asserts, the force_assert_statements option allows to manually
> override this behavior and visit assert statements in release builds.
>
> R=sigurds@chromium.org
>
> Bug: v8:7793
> Change-Id: I38f48e35f2b0a1a98abb74b7babb1edd2d7dba24
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1599180
> Auto-Submit: Simon Zünd <szuend@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61295}
Bug: v8:7793
Change-Id: I96ef863c8c85ae87a00cbe858655d4a2c9368b41
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1599599
Auto-Submit: Simon Zünd <szuend@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61315}
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
// 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 {
|
|
|
|
TorqueCompilerResult TestCompileTorque(const std::string& source) {
|
|
TorqueCompilerOptions options;
|
|
options.output_directory = "";
|
|
options.verbose = false;
|
|
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) {
|
|
std::string source = R"(
|
|
type void;
|
|
type never;
|
|
|
|
type foo generates 'TNode<Foo>';
|
|
)";
|
|
|
|
const TorqueCompilerResult result = TestCompileTorque(source);
|
|
|
|
ASSERT_EQ(result.lint_errors.size(), static_cast<size_t>(1));
|
|
EXPECT_THAT(result.lint_errors[0].message, HasSubstr("\"foo\""));
|
|
}
|
|
|
|
TEST(Torque, StructNamingConventionLintError) {
|
|
const std::string source = R"(
|
|
type void;
|
|
type never;
|
|
|
|
struct foo {}
|
|
)";
|
|
|
|
const TorqueCompilerResult result = TestCompileTorque(source);
|
|
|
|
ASSERT_EQ(result.lint_errors.size(), static_cast<size_t>(1));
|
|
EXPECT_THAT(result.lint_errors[0].message, HasSubstr("\"foo\""));
|
|
}
|
|
|
|
} // namespace torque
|
|
} // namespace internal
|
|
} // namespace v8
|