[tint] Improve unit test failure output.
Change-Id: I5777664fdce51e533601ffd9c8c3181867895798
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/168641
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/lang/core/ir/transform/BUILD.bazel b/src/tint/lang/core/ir/transform/BUILD.bazel
index b75b761..467e451 100644
--- a/src/tint/lang/core/ir/transform/BUILD.bazel
+++ b/src/tint/lang/core/ir/transform/BUILD.bazel
@@ -151,6 +151,7 @@
"//src/tint/lang/wgsl/program",
"//src/tint/lang/wgsl/sem",
"//src/tint/lang/wgsl/writer/ir_to_program",
+ "//src/tint/lang/wgsl/writer/raise",
"//src/tint/utils/containers",
"//src/tint/utils/diagnostic",
"//src/tint/utils/ice",
diff --git a/src/tint/lang/core/ir/transform/BUILD.cmake b/src/tint/lang/core/ir/transform/BUILD.cmake
index 76a01e3..01120f4 100644
--- a/src/tint/lang/core/ir/transform/BUILD.cmake
+++ b/src/tint/lang/core/ir/transform/BUILD.cmake
@@ -141,6 +141,7 @@
tint_lang_wgsl_program
tint_lang_wgsl_sem
tint_lang_wgsl_writer_ir_to_program
+ tint_lang_wgsl_writer_raise
tint_utils_containers
tint_utils_diagnostic
tint_utils_ice
diff --git a/src/tint/lang/core/ir/transform/BUILD.gn b/src/tint/lang/core/ir/transform/BUILD.gn
index fbb325a..56910e6 100644
--- a/src/tint/lang/core/ir/transform/BUILD.gn
+++ b/src/tint/lang/core/ir/transform/BUILD.gn
@@ -143,6 +143,7 @@
"${tint_src_dir}/lang/wgsl/program",
"${tint_src_dir}/lang/wgsl/sem",
"${tint_src_dir}/lang/wgsl/writer/ir_to_program",
+ "${tint_src_dir}/lang/wgsl/writer/raise",
"${tint_src_dir}/utils/containers",
"${tint_src_dir}/utils/diagnostic",
"${tint_src_dir}/utils/ice",
diff --git a/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc b/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc
index 9f39916..49780b7 100644
--- a/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc
+++ b/src/tint/lang/core/ir/transform/direct_variable_access_wgsl_test.cc
@@ -36,6 +36,7 @@
#include "src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.h"
#include "src/tint/lang/wgsl/reader/reader.h"
#include "src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.h"
+#include "src/tint/lang/wgsl/writer/raise/raise.h"
#include "src/tint/lang/wgsl/writer/writer.h"
namespace tint::core::ir::transform {
@@ -62,12 +63,12 @@
wgsl::reader::Options parser_options;
parser_options.allowed_features = wgsl::AllowedFeatures::Everything();
Source::File file{"test", in};
- auto program = wgsl::reader::Parse(&file, parser_options);
- if (!program.IsValid()) {
- return "wgsl::reader::Parse() failed: \n" + program.Diagnostics().str();
+ auto program_in = wgsl::reader::Parse(&file, parser_options);
+ if (!program_in.IsValid()) {
+ return "wgsl::reader::Parse() failed: \n" + program_in.Diagnostics().str();
}
- auto module = wgsl::reader::ProgramToIR(program);
+ auto module = wgsl::reader::ProgramToIR(program_in);
if (module != Success) {
return "ProgramToIR() failed:\n" + module.Failure().reason.str();
}
@@ -77,19 +78,27 @@
return "DirectVariableAccess failed:\n" + res.Failure().reason.str();
}
+ auto pre_raise = ir::Disassemble(module.Get());
+
+ if (auto raise = wgsl::writer::Raise(module.Get()); raise != Success) {
+ return "wgsl::writer::Raise failed:\n" + res.Failure().reason.str();
+ }
+
wgsl::writer::ProgramOptions program_options;
program_options.allowed_features.extensions.insert(
wgsl::Extension::kChromiumExperimentalFullPtrParameters);
- auto transformed = wgsl::writer::IRToProgram(module.Get(), program_options);
- if (!transformed.IsValid()) {
- return "wgsl::writer::IRToProgram() failed: \n" + transformed.Diagnostics().str() +
- "\n\nIR:\n" + ir::Disassemble(module.Get()) + //
- "\n\nAST:\n" + Program::printer(transformed);
+ auto program_out = wgsl::writer::IRToProgram(module.Get(), program_options);
+ if (!program_out.IsValid()) {
+ return "wgsl::writer::IRToProgram() failed: \n" + program_out.Diagnostics().str() +
+ "\n\nIR (pre):\n" + pre_raise + //
+ "\n\nIR (post):\n" + ir::Disassemble(module.Get()) + //
+ "\n\nAST:\n" + Program::printer(program_out);
}
- auto output = wgsl::writer::Generate(transformed, wgsl::writer::Options{});
+ auto output = wgsl::writer::Generate(program_out, wgsl::writer::Options{});
if (output != Success) {
- return "wgsl::writer::Generate() failed: \n" + output.Failure().reason.str();
+ return "wgsl::writer::IRToProgram() failed: \n" + output.Failure().reason.str() +
+ "\n\nIR:\n" + ir::Disassemble(module.Get());
}
return "\n" + output->wgsl;
diff --git a/src/tint/lang/wgsl/BUILD.bazel b/src/tint/lang/wgsl/BUILD.bazel
index f30a202..b945e60 100644
--- a/src/tint/lang/wgsl/BUILD.bazel
+++ b/src/tint/lang/wgsl/BUILD.bazel
@@ -94,12 +94,10 @@
"//src/tint/lang/wgsl/ast",
"//src/tint/lang/wgsl/common",
"//src/tint/lang/wgsl/features",
- "//src/tint/lang/wgsl/helpers:test",
"//src/tint/lang/wgsl/program",
- "//src/tint/lang/wgsl/reader/lower",
- "//src/tint/lang/wgsl/resolver",
"//src/tint/lang/wgsl/sem",
"//src/tint/lang/wgsl/writer/ir_to_program",
+ "//src/tint/lang/wgsl/writer/raise",
"//src/tint/utils/containers",
"//src/tint/utils/diagnostic",
"//src/tint/utils/ice",
diff --git a/src/tint/lang/wgsl/BUILD.cmake b/src/tint/lang/wgsl/BUILD.cmake
index 17f4d73..63b67a8 100644
--- a/src/tint/lang/wgsl/BUILD.cmake
+++ b/src/tint/lang/wgsl/BUILD.cmake
@@ -97,12 +97,10 @@
tint_lang_wgsl_ast
tint_lang_wgsl_common
tint_lang_wgsl_features
- tint_lang_wgsl_helpers_test
tint_lang_wgsl_program
- tint_lang_wgsl_reader_lower
- tint_lang_wgsl_resolver
tint_lang_wgsl_sem
tint_lang_wgsl_writer_ir_to_program
+ tint_lang_wgsl_writer_raise
tint_utils_containers
tint_utils_diagnostic
tint_utils_ice
diff --git a/src/tint/lang/wgsl/BUILD.gn b/src/tint/lang/wgsl/BUILD.gn
index 1b7590c..c63b21c 100644
--- a/src/tint/lang/wgsl/BUILD.gn
+++ b/src/tint/lang/wgsl/BUILD.gn
@@ -86,12 +86,10 @@
"${tint_src_dir}/lang/wgsl/ast",
"${tint_src_dir}/lang/wgsl/common",
"${tint_src_dir}/lang/wgsl/features",
- "${tint_src_dir}/lang/wgsl/helpers:unittests",
"${tint_src_dir}/lang/wgsl/program",
- "${tint_src_dir}/lang/wgsl/reader/lower",
- "${tint_src_dir}/lang/wgsl/resolver",
"${tint_src_dir}/lang/wgsl/sem",
"${tint_src_dir}/lang/wgsl/writer/ir_to_program",
+ "${tint_src_dir}/lang/wgsl/writer/raise",
"${tint_src_dir}/utils/containers",
"${tint_src_dir}/utils/diagnostic",
"${tint_src_dir}/utils/ice",
diff --git a/src/tint/lang/wgsl/ir_roundtrip_test.cc b/src/tint/lang/wgsl/ir_roundtrip_test.cc
index ab1b3d6..d3497d0 100644
--- a/src/tint/lang/wgsl/ir_roundtrip_test.cc
+++ b/src/tint/lang/wgsl/ir_roundtrip_test.cc
@@ -27,10 +27,13 @@
// GEN_BUILD:CONDITION(tint_build_wgsl_reader && tint_build_wgsl_writer)
-#include "src/tint/lang/wgsl/helpers/ir_program_test.h"
+#include "gtest/gtest.h"
+
+#include "src/tint/lang/core/ir/disassembler.h"
#include "src/tint/lang/wgsl/reader/program_to_ir/program_to_ir.h"
#include "src/tint/lang/wgsl/reader/reader.h"
#include "src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.h"
+#include "src/tint/lang/wgsl/writer/raise/raise.h"
#include "src/tint/lang/wgsl/writer/writer.h"
#include "src/tint/utils/text/string.h"
@@ -39,60 +42,146 @@
using namespace tint::core::number_suffixes; // NOLINT
-class IRToProgramRoundtripTest : public helpers::IRProgramTest {
+class IRToProgramRoundtripTest : public testing::Test {
public:
- void Test(std::string_view input_wgsl, std::string_view expected_wgsl) {
+ struct Result {
+ /// The resulting WGSL
+ std::string wgsl;
+ /// The resulting AST
+ std::string ast;
+ /// The resulting IR before raising
+ std::string ir_pre_raise;
+ /// The resulting IR after raising
+ std::string ir_post_raise;
+ /// The resulting error
+ std::string err;
+ /// The expected WGSL
+ std::string expected;
+ };
+
+ /// @return the round-tripped string and the expected string
+ Result Run(std::string input_wgsl, std::string expected_wgsl) {
+ std::string input{tint::TrimSpace(input_wgsl)};
+
+ Result result;
+
wgsl::reader::Options options;
options.allowed_features = wgsl::AllowedFeatures::Everything();
- auto input = tint::TrimSpace(input_wgsl);
Source::File file("test.wgsl", std::string(input));
auto ir_module = wgsl::reader::WgslToIR(&file, options);
- ASSERT_EQ(ir_module, Success);
+ if (ir_module != Success) {
+ return result;
+ }
- auto disassembly = tint::core::ir::Disassemble(ir_module.Get());
+ result.ir_pre_raise = core::ir::Disassemble(ir_module.Get());
+
+ if (auto res = tint::wgsl::writer::Raise(ir_module.Get()); res != Success) {
+ result.err = res.Failure().reason.str();
+ return result;
+ }
+
+ result.ir_post_raise = core::ir::Disassemble(ir_module.Get());
writer::ProgramOptions program_options;
program_options.allowed_features = AllowedFeatures::Everything();
- auto output = wgsl::writer::WgslFromIR(ir_module.Get(), program_options);
- if (output != Success) {
- FAIL() << output.Failure() << std::endl //
- << "IR:" << std::endl //
- << disassembly << std::endl;
+ auto output_program = wgsl::writer::IRToProgram(ir_module.Get(), program_options);
+ if (!output_program.IsValid()) {
+ result.err = output_program.Diagnostics().str();
+ result.ast = Program::printer(output_program);
+ return result;
}
- auto expected = expected_wgsl.empty() ? input : tint::TrimSpace(expected_wgsl);
- auto got = tint::TrimSpace(output->wgsl);
- EXPECT_EQ(expected, got) << "IR:" << std::endl << disassembly;
+ auto output = wgsl::writer::Generate(output_program, {});
+ if (output != Success) {
+ std::stringstream ss;
+ ss << "wgsl::Generate() errored: " << output.Failure();
+ result.err = ss.str();
+ result.ast = Program::printer(output_program);
+ return result;
+ }
+
+ result.expected = expected_wgsl.empty() ? input : tint::TrimSpace(expected_wgsl);
+ if (!result.expected.empty()) {
+ result.expected = "\n" + result.expected + "\n";
+ }
+
+ result.wgsl = std::string(tint::TrimSpace(output->wgsl));
+ if (!result.wgsl.empty()) {
+ result.wgsl = "\n" + result.wgsl + "\n";
+ }
+
+ return result;
}
- void Test(std::string_view wgsl) { Test(wgsl, wgsl); }
+ Result Run(std::string wgsl) { return Run(wgsl, wgsl); }
};
+std::ostream& operator<<(std::ostream& o, const IRToProgramRoundtripTest::Result& res) {
+ if (!res.err.empty()) {
+ o << "============================" << std::endl
+ << "== Error ==" << std::endl
+ << "============================" << std::endl
+ << res.err << std::endl
+ << std::endl;
+ }
+ if (!res.ir_pre_raise.empty()) {
+ o << "============================" << std::endl
+ << "== IR (pre-raise) ==" << std::endl
+ << "============================" << std::endl
+ << res.ir_pre_raise << std::endl
+ << std::endl;
+ }
+ if (!res.ir_post_raise.empty()) {
+ o << "============================" << std::endl
+ << "== IR (post-raise) ==" << std::endl
+ << "============================" << std::endl
+ << res.ir_post_raise << std::endl
+ << std::endl;
+ }
+ if (!res.ast.empty()) {
+ o << "============================" << std::endl
+ << "== AST ==" << std::endl
+ << "============================" << std::endl
+ << res.ast << std::endl
+ << std::endl;
+ }
+ return o;
+}
+
+#define RUN_TEST(...) \
+ do { \
+ if (auto res = Run(__VA_ARGS__); res.err.empty()) { \
+ EXPECT_EQ(res.expected, res.wgsl) << res; \
+ } else { \
+ FAIL() << res; \
+ } \
+ } while (false)
+
TEST_F(IRToProgramRoundtripTest, EmptyModule) {
- Test("");
+ RUN_TEST("");
}
TEST_F(IRToProgramRoundtripTest, SingleFunction_Empty) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
}
)");
}
TEST_F(IRToProgramRoundtripTest, SingleFunction_Return) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
return;
}
)",
- R"(
+ R"(
fn f() {
}
)");
}
TEST_F(IRToProgramRoundtripTest, SingleFunction_Return_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
return 42i;
}
@@ -100,7 +189,7 @@
}
TEST_F(IRToProgramRoundtripTest, SingleFunction_Parameters) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32, u : u32) -> i32 {
return i;
}
@@ -111,7 +200,7 @@
// Struct declaration
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, StructDecl_Scalars) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
b : u32,
@@ -123,7 +212,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberAlign) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@align(32u)
@@ -136,7 +225,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberSize) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@size(32u)
@@ -149,7 +238,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberLocation) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@location(1u)
@@ -162,7 +251,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberIndex) {
- Test(R"(
+ RUN_TEST(R"(
enable chromium_internal_dual_source_blending;
struct S {
@@ -177,7 +266,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberBuiltin) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@builtin(position)
@@ -190,7 +279,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberInterpolateType) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@location(1u) @interpolate(flat)
@@ -203,7 +292,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberInterpolateTypeSampling) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@location(1u) @interpolate(perspective, centroid)
@@ -216,7 +305,7 @@
}
TEST_F(IRToProgramRoundtripTest, StructDecl_MemberInvariant) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
@builtin(position) @invariant
@@ -232,7 +321,7 @@
// Function Call
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, FnCall_NoArgs_NoRet) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -243,7 +332,7 @@
}
TEST_F(IRToProgramRoundtripTest, FnCall_NoArgs_Ret_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> i32 {
return 1i;
}
@@ -255,7 +344,7 @@
}
TEST_F(IRToProgramRoundtripTest, FnCall_3Args_NoRet) {
- Test(R"(
+ RUN_TEST(R"(
fn a(x : i32, y : u32, z : f32) {
}
@@ -266,7 +355,7 @@
}
TEST_F(IRToProgramRoundtripTest, FnCall_3Args_Ret_f32) {
- Test(R"(
+ RUN_TEST(R"(
fn a(x : i32, y : u32, z : f32) -> f32 {
return z;
}
@@ -278,7 +367,7 @@
}
TEST_F(IRToProgramRoundtripTest, FnCall_PtrArgs) {
- Test(R"(
+ RUN_TEST(R"(
var<private> y : i32 = 2i;
fn a(px : ptr<function, i32>, py : ptr<private, i32>) -> i32 {
@@ -296,7 +385,7 @@
// Core Builtin Call
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, CoreBuiltinCall_Stmt) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
workgroupBarrier();
}
@@ -304,7 +393,7 @@
}
TEST_F(IRToProgramRoundtripTest, CoreBuiltinCall_Expr) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) {
var i : i32 = max(a, b);
}
@@ -312,7 +401,7 @@
}
TEST_F(IRToProgramRoundtripTest, CoreBuiltinCall_PhonyAssignment) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) {
_ = max(a, b);
}
@@ -320,7 +409,7 @@
}
TEST_F(IRToProgramRoundtripTest, CoreBuiltinCall_UnusedLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) {
let unused = max(a, b);
}
@@ -328,7 +417,7 @@
}
TEST_F(IRToProgramRoundtripTest, CoreBuiltinCall_PtrArg) {
- Test(R"(
+ RUN_TEST(R"(
@group(0) @binding(0) var<storage, read> v : array<u32>;
fn foo() -> u32 {
@@ -338,13 +427,13 @@
}
TEST_F(IRToProgramRoundtripTest, CoreBuiltinCall_DisableDerivativeUniformity) {
- Test(R"(
+ RUN_TEST(R"(
fn f(in : f32) {
let x = dpdx(in);
let y = dpdy(in);
}
)",
- R"(
+ R"(
diagnostic(off, derivative_uniformity);
fn f(in : f32) {
@@ -358,7 +447,7 @@
// Type Construct
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, TypeConstruct_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) {
var v : i32 = i32(i);
}
@@ -366,7 +455,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_u32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : u32) {
var v : u32 = u32(i);
}
@@ -374,7 +463,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_f32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : f32) {
var v : f32 = f32(i);
}
@@ -382,7 +471,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_bool) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : bool) {
var v : bool = bool(i);
}
@@ -390,7 +479,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_struct) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
b : u32,
@@ -404,7 +493,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_array) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) {
var v : array<i32, 3u> = array<i32, 3u>(i, i, i);
}
@@ -412,7 +501,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_vec3i_Splat) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) {
var v : vec3<i32> = vec3<i32>(i);
}
@@ -420,7 +509,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_vec3i_Scalars) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) {
var v : vec3<i32> = vec3<i32>(i, i, i);
}
@@ -428,7 +517,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_mat2x3f_Scalars) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : f32) {
var v : mat2x3<f32> = mat2x3<f32>(i, i, i, i, i, i);
}
@@ -436,7 +525,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConstruct_mat2x3f_Columns) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : f32) {
var v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(i, i, i), vec3<f32>(i, i, i));
}
@@ -447,7 +536,7 @@
// Type Convert
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, TypeConvert_i32_to_u32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) {
var v : u32 = u32(i);
}
@@ -455,7 +544,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConvert_u32_to_f32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : u32) {
var v : f32 = f32(i);
}
@@ -463,7 +552,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConvert_f32_to_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : f32) {
var v : i32 = i32(i);
}
@@ -471,7 +560,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConvert_bool_to_u32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : bool) {
var v : u32 = u32(i);
}
@@ -479,7 +568,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConvert_vec3i_to_vec3u) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : vec3<i32>) {
var v : vec3<u32> = vec3<u32>(i);
}
@@ -487,7 +576,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConvert_vec3u_to_vec3f) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : vec3<u32>) {
var v : vec3<f32> = vec3<f32>(i);
}
@@ -495,7 +584,7 @@
}
TEST_F(IRToProgramRoundtripTest, TypeConvert_mat2x3f_to_mat2x3h) {
- Test(R"(
+ RUN_TEST(R"(
enable f16;
fn f(i : mat2x3<f32>) {
@@ -508,7 +597,7 @@
// Bitcast
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Bitcast_i32_to_u32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) {
var v : u32 = bitcast<u32>(i);
}
@@ -516,7 +605,7 @@
}
TEST_F(IRToProgramRoundtripTest, Bitcast_u32_to_f32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : u32) {
var v : f32 = bitcast<f32>(i);
}
@@ -524,7 +613,7 @@
}
TEST_F(IRToProgramRoundtripTest, Bitcast_f32_to_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : f32) {
var v : i32 = bitcast<i32>(i);
}
@@ -535,7 +624,7 @@
// Discard
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Discard) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
discard;
}
@@ -546,12 +635,12 @@
// Access
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Access_Value_vec3f_1) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> f32 {
return v[1];
}
)",
- R"(
+ R"(
fn f(v : vec3<f32>) -> f32 {
return v.y;
}
@@ -559,14 +648,14 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_vec3f_1) {
- Test(R"(
+ RUN_TEST(R"(
var<private> v : vec3<f32>;
fn f() -> f32 {
return v[1];
}
)",
- R"(
+ R"(
var<private> v : vec3<f32>;
fn f() -> f32 {
@@ -576,7 +665,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_vec3f_z) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> f32 {
return v.z;
}
@@ -584,7 +673,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_vec3f_z) {
- Test(R"(
+ RUN_TEST(R"(
var<private> v : vec3<f32>;
fn f() -> f32 {
@@ -594,12 +683,12 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_vec3f_g) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> f32 {
return v.g;
}
)",
- R"(
+ R"(
fn f(v : vec3<f32>) -> f32 {
return v.y;
}
@@ -607,14 +696,14 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_vec3f_g) {
- Test(R"(
+ RUN_TEST(R"(
var<private> v : vec3<f32>;
fn f() -> f32 {
return v.g;
}
)",
- R"(
+ R"(
var<private> v : vec3<f32>;
fn f() -> f32 {
@@ -624,7 +713,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_vec3f_i) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>, i : i32) -> f32 {
return v[i];
}
@@ -632,7 +721,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_vec3f_i) {
- Test(R"(
+ RUN_TEST(R"(
var<private> v : vec3<f32>;
fn f(i : i32) -> f32 {
@@ -642,12 +731,12 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_mat3x2f_1_0) {
- Test(R"(
+ RUN_TEST(R"(
fn f(m : mat3x2<f32>) -> f32 {
return m[1][0];
}
)",
- R"(
+ R"(
fn f(m : mat3x2<f32>) -> f32 {
return m[1i].x;
}
@@ -655,14 +744,14 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_mat3x2f_1_0) {
- Test(R"(
+ RUN_TEST(R"(
var<private> m : mat3x2<f32>;
fn f() -> f32 {
return m[1][0];
}
)",
- R"(
+ R"(
var<private> m : mat3x2<f32>;
fn f() -> f32 {
@@ -672,12 +761,12 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_mat3x2f_u_0) {
- Test(R"(
+ RUN_TEST(R"(
fn f(m : mat3x2<f32>, u : u32) -> f32 {
return m[u][0];
}
)",
- R"(
+ R"(
fn f(m : mat3x2<f32>, u : u32) -> f32 {
return m[u].x;
}
@@ -685,14 +774,14 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_mat3x2f_u_0) {
- Test(R"(
+ RUN_TEST(R"(
var<private> m : mat3x2<f32>;
fn f(u : u32) -> f32 {
return m[u][0];
}
)",
- R"(
+ R"(
var<private> m : mat3x2<f32>;
fn f(u : u32) -> f32 {
@@ -702,7 +791,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_mat3x2f_u_i) {
- Test(R"(
+ RUN_TEST(R"(
fn f(m : mat3x2<f32>, u : u32, i : i32) -> f32 {
return m[u][i];
}
@@ -710,7 +799,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_mat3x2f_u_i) {
- Test(R"(
+ RUN_TEST(R"(
var<private> m : mat3x2<f32>;
fn f(u : u32, i : i32) -> f32 {
@@ -720,7 +809,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_array_0u) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : array<i32, 4u>) -> i32 {
return a[0u];
}
@@ -728,7 +817,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_array_0u) {
- Test(R"(
+ RUN_TEST(R"(
var<private> a : array<i32, 4u>;
fn f() -> i32 {
@@ -738,7 +827,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Value_array_i) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : array<i32, 4u>, i : i32) -> i32 {
return a[i];
}
@@ -746,7 +835,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Ref_array_i) {
- Test(R"(
+ RUN_TEST(R"(
var<private> a : array<i32, 4u>;
fn f(i : i32) -> i32 {
@@ -756,7 +845,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ValueStruct) {
- Test(R"(
+ RUN_TEST(R"(
struct Y {
a : i32,
b : i32,
@@ -776,7 +865,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ReferenceStruct) {
- Test(R"(
+ RUN_TEST(R"(
struct Y {
a : i32,
b : i32,
@@ -797,7 +886,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfArrayOfArray_123) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -810,7 +899,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfArrayOfArray_213) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -824,7 +913,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfArrayOfArray_312) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -838,7 +927,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfArrayOfArray_321) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -853,7 +942,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfMat3x4f_123) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -865,7 +954,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfMat3x4f_213) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -879,7 +968,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfMat3x4f_312) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -893,7 +982,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_ArrayOfMat3x4f_321) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> i32 {
return 1i;
}
@@ -908,7 +997,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_UsePartialChains) {
- Test(R"(
+ RUN_TEST(R"(
var<private> a : array<array<array<i32, 4u>, 5u>, 6u>;
fn f(i : i32) -> i32 {
@@ -927,7 +1016,7 @@
// Swizzle
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Value_xy) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> vec2<f32> {
return v.xy;
}
@@ -935,7 +1024,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Value_yz) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> vec2<f32> {
return v.yz;
}
@@ -943,7 +1032,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Value_yzx) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> vec3<f32> {
return v.yzx;
}
@@ -951,7 +1040,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Value_yzxy) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : vec3<f32>) -> vec4<f32> {
return v.yzxy;
}
@@ -959,7 +1048,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Pointer_xy) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : ptr<function, vec3<f32>>) -> vec2<f32> {
return (*(v)).xy;
}
@@ -967,7 +1056,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Pointer_yz) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : ptr<function, vec3<f32>>) -> vec2<f32> {
return (*(v)).yz;
}
@@ -975,7 +1064,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Pointer_yzx) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : ptr<function, vec3<f32>>) -> vec3<f32> {
return (*(v)).yzx;
}
@@ -983,7 +1072,7 @@
}
TEST_F(IRToProgramRoundtripTest, Access_Vec3_Pointer_yzxy) {
- Test(R"(
+ RUN_TEST(R"(
fn f(v : ptr<function, vec3<f32>>) -> vec4<f32> {
return (*(v)).yzxy;
}
@@ -994,7 +1083,7 @@
// Unary ops
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, UnaryOp_Negate) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) -> i32 {
return -(i);
}
@@ -1002,7 +1091,7 @@
}
TEST_F(IRToProgramRoundtripTest, UnaryOp_Complement) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : u32) -> u32 {
return ~(i);
}
@@ -1010,7 +1099,7 @@
}
TEST_F(IRToProgramRoundtripTest, UnaryOp_Not) {
- Test(R"(
+ RUN_TEST(R"(
fn f(b : bool) -> bool {
return !(b);
}
@@ -1021,7 +1110,7 @@
// Binary ops
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, BinaryOp_Add) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a + b);
}
@@ -1029,7 +1118,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Subtract) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a - b);
}
@@ -1037,7 +1126,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Multiply) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a * b);
}
@@ -1045,7 +1134,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Divide) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a / b);
}
@@ -1053,7 +1142,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Modulo) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a % b);
}
@@ -1061,7 +1150,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_And) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a & b);
}
@@ -1069,7 +1158,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Or) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a | b);
}
@@ -1077,7 +1166,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Xor) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> i32 {
return (a ^ b);
}
@@ -1085,7 +1174,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_Equal) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> bool {
return (a == b);
}
@@ -1093,7 +1182,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_NotEqual) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> bool {
return (a != b);
}
@@ -1101,7 +1190,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_LessThan) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> bool {
return (a < b);
}
@@ -1109,7 +1198,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_GreaterThan) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> bool {
return (a > b);
}
@@ -1117,7 +1206,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_LessThanEqual) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> bool {
return (a <= b);
}
@@ -1125,7 +1214,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_GreaterThanEqual) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : i32) -> bool {
return (a >= b);
}
@@ -1133,7 +1222,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_ShiftLeft) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : u32) -> i32 {
return (a << b);
}
@@ -1141,7 +1230,7 @@
}
TEST_F(IRToProgramRoundtripTest, BinaryOp_ShiftRight) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : i32, b : u32) -> i32 {
return (a >> b);
}
@@ -1152,7 +1241,7 @@
// Short-circuiting binary ops
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Param_2) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool) -> bool {
return (a && b);
}
@@ -1160,7 +1249,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Param_3_ab_c) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
return ((a && b) && c);
}
@@ -1168,7 +1257,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Param_3_a_bc) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
return ((a && b) && c);
}
@@ -1176,7 +1265,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Let_2) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool) -> bool {
let l = (a && b);
return l;
@@ -1185,7 +1274,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Let_3_ab_c) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
let l = ((a && b) && c);
return l;
@@ -1194,7 +1283,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Let_3_a_bc) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
let l = (a && (b && c));
return l;
@@ -1203,7 +1292,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Call_2) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> bool {
return true;
}
@@ -1219,7 +1308,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Call_3_ab_c) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> bool {
return true;
}
@@ -1239,7 +1328,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_And_Call_3_a_bc) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> bool {
return true;
}
@@ -1259,7 +1348,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Param_2) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool) -> bool {
return (a || b);
}
@@ -1267,7 +1356,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Param_3_ab_c) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
return ((a || b) || c);
}
@@ -1275,7 +1364,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Param_3_a_bc) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
return (a || (b || c));
}
@@ -1283,7 +1372,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Let_2) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool) -> bool {
let l = (a || b);
return l;
@@ -1292,7 +1381,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Let_3_ab_c) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
let l = ((a || b) || c);
return l;
@@ -1301,7 +1390,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Let_3_a_bc) {
- Test(R"(
+ RUN_TEST(R"(
fn f(a : bool, b : bool, c : bool) -> bool {
let l = (a || (b || c));
return l;
@@ -1310,7 +1399,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Call_2) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> bool {
return true;
}
@@ -1326,7 +1415,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Call_3_ab_c) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> bool {
return true;
}
@@ -1346,7 +1435,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Or_Call_3_a_bc) {
- Test(R"(
+ RUN_TEST(R"(
fn a() -> bool {
return true;
}
@@ -1366,7 +1455,7 @@
}
TEST_F(IRToProgramRoundtripTest, ShortCircuit_Mixed) {
- Test(R"(
+ RUN_TEST(R"(
fn b() -> bool {
return true;
}
@@ -1386,7 +1475,7 @@
// Assignment
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Assign_ArrayOfArrayOfArrayAccess_123456) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1399,7 +1488,7 @@
}
TEST_F(IRToProgramRoundtripTest, Assign_ArrayOfArrayOfArrayAccess_261345) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1414,7 +1503,7 @@
}
TEST_F(IRToProgramRoundtripTest, Assign_ArrayOfArrayOfArrayAccess_532614) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1431,7 +1520,7 @@
}
TEST_F(IRToProgramRoundtripTest, Assign_ArrayOfMatrixAccess_123456) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1444,7 +1533,7 @@
}
TEST_F(IRToProgramRoundtripTest, Assign_ArrayOfMatrixAccess_261345) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1459,7 +1548,7 @@
}
TEST_F(IRToProgramRoundtripTest, Assign_ArrayOfMatrixAccess_532614) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1479,13 +1568,13 @@
// Compound assignment
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Increment) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v++;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v + 1i);
@@ -1494,13 +1583,13 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Decrement) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v++;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v + 1i);
@@ -1509,13 +1598,13 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Add) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v += 8i;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v + 8i);
@@ -1524,13 +1613,13 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Subtract) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v -= 8i;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v - 8i);
@@ -1539,13 +1628,13 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Multiply) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v *= 8i;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v * 8i);
@@ -1554,13 +1643,13 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Divide) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v /= 8i;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v / 8i);
@@ -1569,13 +1658,13 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_Xor) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var v : i32;
v ^= 8i;
}
)",
- R"(
+ R"(
fn f() {
var v : i32;
v = (v ^ 8i);
@@ -1584,7 +1673,7 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_ArrayOfArrayOfArrayAccess_123456) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1594,7 +1683,8 @@
v[e(1i)][e(2i)][e(3i)] += v[e(4i)][e(5i)][e(6i)];
}
)",
- R"(fn e(i : i32) -> i32 {
+ R"(
+fn e(i : i32) -> i32 {
return i;
}
@@ -1607,7 +1697,7 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_ArrayOfArrayOfArrayAccess_261345) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1619,7 +1709,8 @@
v[e(1i)][v_2][e(3i)] += v[e(4i)][e(5i)][v_3];
}
)",
- R"(fn e(i : i32) -> i32 {
+ R"(
+fn e(i : i32) -> i32 {
return i;
}
@@ -1634,7 +1725,7 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_ArrayOfArrayOfArrayAccess_532614) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1648,7 +1739,8 @@
v[e(1i)][v_4][v_3] += v[e(4i)][v_2][v_5];
}
)",
- R"(fn e(i : i32) -> i32 {
+ R"(
+fn e(i : i32) -> i32 {
return i;
}
@@ -1665,7 +1757,7 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_ArrayOfMatrixAccess_123456) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1675,7 +1767,8 @@
v[e(1i)][e(2i)][e(3i)] += v[e(4i)][e(5i)][e(6i)];
}
)",
- R"(fn e(i : i32) -> i32 {
+ R"(
+fn e(i : i32) -> i32 {
return i;
}
@@ -1689,7 +1782,7 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_ArrayOfMatrixAccess_261345) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1701,7 +1794,8 @@
v[e(1i)][v_2][e(3i)] += v[e(4i)][e(5i)][v_3];
}
)",
- R"(fn e(i : i32) -> i32 {
+ R"(
+fn e(i : i32) -> i32 {
return i;
}
@@ -1717,7 +1811,7 @@
}
TEST_F(IRToProgramRoundtripTest, CompoundAssign_ArrayOfMatrixAccess_532614) {
- Test(R"(
+ RUN_TEST(R"(
fn e(i : i32) -> i32 {
return i;
}
@@ -1731,7 +1825,8 @@
v[e(1i)][v_4][v_3] += v[e(4i)][v_2][v_5];
}
)",
- R"(fn e(i : i32) -> i32 {
+ R"(
+fn e(i : i32) -> i32 {
return i;
}
@@ -1751,7 +1846,7 @@
// Phony Assignment
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, PhonyAssign_PrivateVar) {
- Test(R"(
+ RUN_TEST(R"(
var<private> p : i32;
fn f() {
@@ -1761,7 +1856,7 @@
}
TEST_F(IRToProgramRoundtripTest, PhonyAssign_FunctionVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var i : i32;
_ = i;
@@ -1770,13 +1865,13 @@
}
TEST_F(IRToProgramRoundtripTest, PhonyAssign_FunctionLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
let i : i32 = 42i;
_ = i;
}
)",
- R"(
+ R"(
fn f() {
let i = 42i;
}
@@ -1784,7 +1879,7 @@
}
TEST_F(IRToProgramRoundtripTest, PhonyAssign_HandleVar) {
- Test(R"(
+ RUN_TEST(R"(
@group(0) @binding(0) var t : texture_2d<f32>;
fn f() {
@@ -1794,19 +1889,19 @@
}
TEST_F(IRToProgramRoundtripTest, PhonyAssign_Constant) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
_ = 42i;
}
)",
- R"(
+ R"(
fn f() {
}
)");
}
TEST_F(IRToProgramRoundtripTest, PhonyAssign_Call) {
- Test(R"(
+ RUN_TEST(R"(
fn v() -> i32 {
return 42;
}
@@ -1815,7 +1910,7 @@
_ = v();
}
)",
- R"(
+ R"(
fn v() -> i32 {
return 42i;
}
@@ -1830,7 +1925,7 @@
// let
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, LetUsedOnce) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : u32) -> u32 {
let v = ~(i);
return v;
@@ -1839,7 +1934,7 @@
}
TEST_F(IRToProgramRoundtripTest, LetUsedTwice) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) -> i32 {
let v = (i * 2i);
return (v + v);
@@ -1851,19 +1946,25 @@
// Module-scope var
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_i32) {
- Test("var<private> v : i32 = 1i;");
+ RUN_TEST(R"(
+var<private> v : i32 = 1i;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_u32) {
- Test("var<private> v : u32 = 1u;");
+ RUN_TEST(R"(
+var<private> v : u32 = 1u;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_f32) {
- Test("var<private> v : f32 = 1.0f;");
+ RUN_TEST(R"(
+var<private> v : f32 = 1.0f;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_f16) {
- Test(R"(
+ RUN_TEST(R"(
enable f16;
var<private> v : f16 = 1.0h;
@@ -1871,28 +1972,38 @@
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_bool) {
- Test("var<private> v : bool = true;");
+ RUN_TEST(R"(
+var<private> v : bool = true;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_array_NoArgs) {
- Test("var<private> v : array<i32, 4u> = array<i32, 4u>();");
+ RUN_TEST(R"(
+var<private> v : array<i32, 4u> = array<i32, 4u>();
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_array_Zero) {
- Test("var<private> v : array<i32, 4u> = array<i32, 4u>(0i, 0i, 0i, 0i);",
- "var<private> v : array<i32, 4u> = array<i32, 4u>();");
+ RUN_TEST(R"(
+var<private> v : array<i32, 4u> = array<i32, 4u>(0i, 0i, 0i, 0i);
+var<private> v : array<i32, 4u> = array<i32, 4u>();
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_array_SameValue) {
- Test("var<private> v : array<i32, 4u> = array<i32, 4u>(4i, 4i, 4i, 4i);");
+ RUN_TEST(R"(
+var<private> v : array<i32, 4u> = array<i32, 4u>(4i, 4i, 4i, 4i);
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_array_DifferentValues) {
- Test("var<private> v : array<i32, 4u> = array<i32, 4u>(1i, 2i, 3i, 4i);");
+ RUN_TEST(R"(
+var<private> v : array<i32, 4u> = array<i32, 4u>(1i, 2i, 3i, 4i);
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_struct_NoArgs) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
i : i32,
u : u32,
@@ -1904,7 +2015,7 @@
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_struct_Zero) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
i : i32,
u : u32,
@@ -1913,7 +2024,7 @@
var<private> s : S = S(0i, 0u, 0f);
)",
- R"(
+ R"(
struct S {
i : i32,
u : u32,
@@ -1925,7 +2036,7 @@
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_struct_SameValue) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
b : i32,
@@ -1937,7 +2048,7 @@
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_struct_DifferentValues) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
a : i32,
b : i32,
@@ -1949,78 +2060,104 @@
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_vec3f_NoArgs) {
- Test("var<private> v : vec3<f32> = vec3<f32>();");
+ RUN_TEST(R"(
+var<private> v : vec3<f32> = vec3<f32>();
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_vec3f_Zero) {
- Test("var<private> v : vec3<f32> = vec3<f32>(0f);",
- "var<private> v : vec3<f32> = vec3<f32>();");
+ RUN_TEST(R"(
+var<private> v : vec3<f32> = vec3<f32>(0f);",
+ "var<private> v : vec3<f32> = vec3<f32>();
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_vec3f_Splat) {
- Test("var<private> v : vec3<f32> = vec3<f32>(1.0f);");
+ RUN_TEST(R"(
+var<private> v : vec3<f32> = vec3<f32>(1.0f);
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_vec3f_Scalars) {
- Test("var<private> v : vec3<f32> = vec3<f32>(1.0f, 2.0f, 3.0f);");
+ RUN_TEST(R"(
+var<private> v : vec3<f32> = vec3<f32>(1.0f, 2.0f, 3.0f);
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_NoArgs) {
- Test("var<private> v : mat2x3<f32> = mat2x3<f32>();");
+ RUN_TEST(R"(
+var<private> v : mat2x3<f32> = mat2x3<f32>();
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Scalars_SameValue) {
- Test("var<private> v : mat2x3<f32> = mat2x3<f32>(4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f);",
- "var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f), vec3<f32>(4.0f));");
+ RUN_TEST(R"(
+var<private> v : mat2x3<f32> = mat2x3<f32>(4.0f, 4.0f, 4.0f, 4.0f, 4.0f, 4.0f);
+var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f), vec3<f32>(4.0f));
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Scalars) {
- Test("var<private> v : mat2x3<f32> = mat2x3<f32>(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);",
- "var<private> v : mat2x3<f32> = "
- "mat2x3<f32>(vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(4.0f, 5.0f, 6.0f));");
+ RUN_TEST(R"(
+var<private> v : mat2x3<f32> = mat2x3<f32>(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);
+var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(4.0f, 5.0f, 6.0f));
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Columns) {
- Test(
- "var<private> v : mat2x3<f32> = "
- "mat2x3<f32>(vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(4.0f, 5.0f, 6.0f));");
+ RUN_TEST(
+ R"(
+var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(4.0f, 5.0f, 6.0f));
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Private_mat2x3f_Columns_SameValue) {
- Test(
- "var<private> v : mat2x3<f32> = "
- "mat2x3<f32>(vec3<f32>(4.0f, 4.0f, 4.0f), vec3<f32>(4.0f, 4.0f, 4.0f));",
- "var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f), vec3<f32>(4.0f));");
+ RUN_TEST(R"(
+var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f, 4.0f, 4.0f), vec3<f32>(4.0f, 4.0f, 4.0f));
+var<private> v : mat2x3<f32> = mat2x3<f32>(vec3<f32>(4.0f), vec3<f32>(4.0f));
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Uniform_vec4i) {
- Test("@group(10) @binding(20) var<uniform> v : vec4<i32>;");
+ RUN_TEST(R"(
+@group(10) @binding(20) var<uniform> v : vec4<i32>;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_StorageRead_u32) {
- Test("@group(10) @binding(20) var<storage, read> v : u32;");
+ RUN_TEST(R"(
+@group(10) @binding(20) var<storage, read> v : u32;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_StorageReadWrite_i32) {
- Test("@group(10) @binding(20) var<storage, read_write> v : i32;");
+ RUN_TEST(R"(
+@group(10) @binding(20) var<storage, read_write> v : i32;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Handle_Texture2D) {
- Test("@group(0) @binding(0) var t : texture_2d<f32>;");
+ RUN_TEST(R"(
+@group(0) @binding(0) var t : texture_2d<f32>;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Handle_Sampler) {
- Test("@group(0) @binding(0) var s : sampler;");
+ RUN_TEST(R"(
+@group(0) @binding(0) var s : sampler;
+)");
}
TEST_F(IRToProgramRoundtripTest, ModuleScopeVar_Handle_SamplerCmp) {
- Test("@group(0) @binding(0) var s : sampler_comparison;");
+ RUN_TEST(R"(
+@group(0) @binding(0) var s : sampler_comparison;
+)");
}
////////////////////////////////////////////////////////////////////////////////
// Function-scope var
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var i : i32;
}
@@ -2028,7 +2165,7 @@
}
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_i32_InitLiteral) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var i : i32 = 42i;
}
@@ -2036,7 +2173,7 @@
}
TEST_F(IRToProgramRoundtripTest, FunctionScopeVar_Chained) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var a : i32 = 42i;
var b : i32 = a;
@@ -2049,7 +2186,7 @@
// Function-scope let
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, FunctionScopeLet_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f(i : i32) -> i32 {
let a = (42i + i);
let b = (24i + i);
@@ -2060,7 +2197,7 @@
}
TEST_F(IRToProgramRoundtripTest, FunctionScopeLet_ptr) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var a : array<i32, 3u>;
let b = &(a[1i]);
@@ -2075,7 +2212,7 @@
// If their constant values were inlined, then the initializer for 'c' would be treated as a
// constant expression instead of the authored runtime expression. Evaluating '1 / 0' as a
// constant expression is a WGSL validation error.
- Test(R"(
+ RUN_TEST(R"(
fn f() {
let a = 1i;
let b = 0i;
@@ -2088,7 +2225,7 @@
// If
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, If_CallFn) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2101,7 +2238,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_Return) {
- Test(R"(
+ RUN_TEST(R"(
fn f(cond : bool) {
if (cond) {
return;
@@ -2111,7 +2248,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_Return_i32) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var cond : bool = true;
if (cond) {
@@ -2123,7 +2260,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_CallFn_Else_CallFn) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2141,7 +2278,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_Return_f32_Else_Return_f32) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> f32 {
var cond : bool = true;
if (cond) {
@@ -2154,7 +2291,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_Return_u32_Else_CallFn) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2175,7 +2312,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_CallFn_ElseIf_CallFn) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2198,7 +2335,7 @@
}
TEST_F(IRToProgramRoundtripTest, If_Else_Chain) {
- Test(R"(
+ RUN_TEST(R"(
fn x(i : i32) -> bool {
return true;
}
@@ -2221,7 +2358,7 @@
// Switch
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Switch_Default) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2237,7 +2374,7 @@
}
TEST_F(IRToProgramRoundtripTest, Switch_3_Cases) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2265,7 +2402,7 @@
}
TEST_F(IRToProgramRoundtripTest, Switch_3_Cases_AllReturn) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2285,7 +2422,7 @@
a();
}
)",
- R"(
+ R"(
fn a() {
}
@@ -2307,7 +2444,7 @@
}
TEST_F(IRToProgramRoundtripTest, Switch_Nested) {
- Test(R"(
+ RUN_TEST(R"(
fn a() {
}
@@ -2345,7 +2482,7 @@
// For
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, For_Empty) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
for(var i : i32 = 0i; (i < 5i); i = (i + 1i)) {
}
@@ -2354,7 +2491,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_Empty_NoInit) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var i : i32 = 0i;
for(; (i < 5i); i = (i + 1i)) {
@@ -2364,14 +2501,14 @@
}
TEST_F(IRToProgramRoundtripTest, For_Empty_NoCond) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
for(var i : i32 = 0i; ; i = (i + 1i)) {
break;
}
}
)",
- R"(
+ R"(
fn f() {
{
var i : i32 = 0i;
@@ -2388,7 +2525,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_Empty_NoCont) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
for(var i : i32 = 0i; (i < 5i); ) {
}
@@ -2397,7 +2534,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_ComplexBody) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> bool {
return (v == 1i);
}
@@ -2416,7 +2553,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_ComplexBody_NoInit) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> bool {
return (v == 1i);
}
@@ -2436,7 +2573,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_ComplexBody_NoCond) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> bool {
return (v == 1i);
}
@@ -2451,7 +2588,7 @@
}
}
)",
- R"(
+ R"(
fn a(v : i32) -> bool {
return (v == 1i);
}
@@ -2476,7 +2613,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_ComplexBody_NoCont) {
- Test(R"(
+ RUN_TEST(R"(
fn a(v : i32) -> bool {
return (v == 1i);
}
@@ -2495,7 +2632,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_CallInInitCondCont) {
- Test(R"(
+ RUN_TEST(R"(
fn n(v : i32) -> i32 {
return (v + 1i);
}
@@ -2508,7 +2645,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_AssignAsInit) {
- Test(R"(
+ RUN_TEST(R"(
fn n() {
}
@@ -2521,7 +2658,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_CompoundAssignAsInit) {
- Test(R"(
+ RUN_TEST(R"(
fn n() {
}
@@ -2531,7 +2668,7 @@
}
}
)",
- R"(
+ R"(
fn n() {
}
@@ -2544,7 +2681,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_IncrementAsInit) {
- Test(R"(
+ RUN_TEST(R"(
fn n() {
}
@@ -2554,7 +2691,7 @@
}
}
)",
- R"(
+ R"(
fn n() {
}
@@ -2567,7 +2704,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_DecrementAsInit) {
- Test(R"(
+ RUN_TEST(R"(
fn n() {
}
@@ -2577,7 +2714,7 @@
}
}
)",
- R"(
+ R"(
fn n() {
}
@@ -2590,7 +2727,7 @@
}
TEST_F(IRToProgramRoundtripTest, For_CallAsInit) {
- Test(R"(
+ RUN_TEST(R"(
fn n() {
}
@@ -2606,7 +2743,7 @@
// While
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, While_Empty) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
while(true) {
}
@@ -2615,7 +2752,7 @@
}
TEST_F(IRToProgramRoundtripTest, While_Cond) {
- Test(R"(
+ RUN_TEST(R"(
fn f(cond : bool) {
while(cond) {
}
@@ -2624,7 +2761,7 @@
}
TEST_F(IRToProgramRoundtripTest, While_Break) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
while(true) {
break;
@@ -2634,7 +2771,7 @@
}
TEST_F(IRToProgramRoundtripTest, While_IfBreak) {
- Test(R"(
+ RUN_TEST(R"(
fn f(cond : bool) {
while(true) {
if (cond) {
@@ -2646,7 +2783,7 @@
}
TEST_F(IRToProgramRoundtripTest, While_IfReturn) {
- Test(R"(
+ RUN_TEST(R"(
fn f(cond : bool) {
while(true) {
if (cond) {
@@ -2661,7 +2798,7 @@
// Loop
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Loop_Break) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
loop {
break;
@@ -2671,7 +2808,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_IfBreak) {
- Test(R"(
+ RUN_TEST(R"(
fn f(cond : bool) {
loop {
if (cond) {
@@ -2683,7 +2820,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_IfReturn) {
- Test(R"(
+ RUN_TEST(R"(
fn f(cond : bool) {
loop {
if (cond) {
@@ -2695,7 +2832,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_IfContinuing) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var cond : bool = false;
loop {
@@ -2712,7 +2849,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_VarsDeclaredOutsideAndInside) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
var b : i32 = 1i;
loop {
@@ -2730,7 +2867,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_BreakIf_EmptyBody) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
loop {
@@ -2743,7 +2880,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_BreakIf_NotFalse) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
loop {
if (false) {
@@ -2757,7 +2894,7 @@
}
}
)",
- R"(
+ R"(
fn f() {
loop {
if (!(false)) {
@@ -2773,7 +2910,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_BreakIf_NotTrue) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
loop {
if (false) {
@@ -2787,7 +2924,7 @@
}
}
)",
- R"(
+ R"(
fn f() {
loop {
if (!(false)) {
@@ -2803,7 +2940,7 @@
}
TEST_F(IRToProgramRoundtripTest, Loop_WithReturn) {
- Test(R"(
+ RUN_TEST(R"(
fn f() {
loop {
let i = 42i;
@@ -2817,12 +2954,12 @@
// Shadowing tests
////////////////////////////////////////////////////////////////////////////////
TEST_F(IRToProgramRoundtripTest, Shadow_f32_With_Fn) {
- Test(R"(
+ RUN_TEST(R"(
fn f32() {
var v = mat4x4f();
}
)",
- R"(
+ R"(
fn f32_1() {
var v : mat4x4<f32> = mat4x4<f32>();
}
@@ -2830,7 +2967,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_f32_With_Struct) {
- Test(R"(
+ RUN_TEST(R"(
struct f32 {
v : i32,
}
@@ -2839,7 +2976,7 @@
let f = vec2f(1.0f);
}
)",
- R"(
+ R"(
struct f32_1 {
v : i32,
}
@@ -2851,21 +2988,21 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_f32_With_ModVar) {
- Test(R"(
+ RUN_TEST(R"(
var<private> f32 : vec2f = vec2f(0.0f, 1.0f);
)",
- R"(
+ R"(
var<private> f32_1 : vec2<f32> = vec2<f32>(0.0f, 1.0f);
)");
}
TEST_F(IRToProgramRoundtripTest, Shadow_f32_With_ModVar2) {
- Test(R"(
+ RUN_TEST(R"(
var<private> f32 : i32 = 1i;
var<private> v = vec2(1.0).x;
)",
- R"(
+ R"(
var<private> f32_1 : i32 = 1i;
var<private> v : f32 = 1.0f;
@@ -2873,14 +3010,14 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_f32_With_Alias) {
- Test(R"(
+ RUN_TEST(R"(
alias f32 = i32;
fn f() {
var v = vec3(1.0f, 2.0f, 3.0f);
}
)",
- R"(
+ R"(
fn f() {
var v : vec3<f32> = vec3<f32>(1.0f, 2.0f, 3.0f);
}
@@ -2888,7 +3025,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_Struct_With_FnVar) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
i : i32,
}
@@ -2901,7 +3038,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_Struct_With_Param) {
- Test(R"(
+ RUN_TEST(R"(
struct S {
i : i32,
}
@@ -2913,7 +3050,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_ModVar_With_FnVar) {
- Test(R"(
+ RUN_TEST(R"(
var<private> i : i32 = 1i;
fn f() -> i32 {
@@ -2925,7 +3062,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_ModVar_With_FnLet) {
- Test(R"(
+ RUN_TEST(R"(
var<private> i : i32 = 1i;
fn f() -> i32 {
@@ -2937,7 +3074,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_IfVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
if (true) {
@@ -2951,7 +3088,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_IfLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
if (true) {
@@ -2965,7 +3102,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_WhileVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
while((i < 4i)) {
@@ -2978,7 +3115,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_WhileLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
while((i < 4i)) {
@@ -2991,7 +3128,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_ForInitVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
for(var i : f32 = 0.0f; (i < 4.0f); ) {
@@ -3003,7 +3140,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_ForInitLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
for(let i = 0.0f; (i < 4.0f); ) {
@@ -3015,7 +3152,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_ForBodyVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
for(var x : i32 = 0i; (i < 4i); ) {
@@ -3028,7 +3165,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_ForBodyLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
for(var x : i32 = 0i; (i < 4i); ) {
@@ -3041,7 +3178,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_LoopBodyVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
loop {
@@ -3059,7 +3196,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_LoopBodyLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
loop {
@@ -3077,7 +3214,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_LoopContinuingVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
loop {
@@ -3096,7 +3233,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_LoopContinuingLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
loop {
@@ -3115,7 +3252,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_SwitchCaseVar) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
switch(i) {
@@ -3135,7 +3272,7 @@
}
TEST_F(IRToProgramRoundtripTest, Shadow_FnVar_With_SwitchCaseLet) {
- Test(R"(
+ RUN_TEST(R"(
fn f() -> i32 {
var i : i32;
switch(i) {