[tint][core] Fix tests
These tests were creating constants with a mismatch between the type and
value. This causes problems when calling core::constant::Value::Equal().
Change-Id: I112765e60753b80d5f8a5f9f52f66576a91488a4
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/172560
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Kokoro: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/lang/core/constant/composite_test.cc b/src/tint/lang/core/constant/composite_test.cc
index 1e0e550..f03f323 100644
--- a/src/tint/lang/core/constant/composite_test.cc
+++ b/src/tint/lang/core/constant/composite_test.cc
@@ -47,8 +47,8 @@
auto* fPos1 = constants.Get(1_f);
auto* fNeg1 = constants.Get(-1_f);
- auto* compositePosZeros = constants.Composite(vec3f, Vector{fPos0, fPos0});
- auto* compositeNegZeros = constants.Composite(vec3f, Vector{fNeg0, fNeg0});
+ auto* compositePosZeros = constants.Composite(vec3f, Vector{fPos0, fPos0, fPos0});
+ auto* compositeNegZeros = constants.Composite(vec3f, Vector{fNeg0, fNeg0, fNeg0});
auto* compositeMixed = constants.Composite(vec3f, Vector{fNeg0, fPos1, fPos0});
auto* compositePosNeg = constants.Composite(vec3f, Vector{fNeg1, fPos1, fPos1});
@@ -66,8 +66,8 @@
auto* fPos1 = constants.Get(1_f);
auto* fNeg1 = constants.Get(-1_f);
- auto* compositePosZeros = constants.Composite(vec3f, Vector{fPos0, fPos0});
- auto* compositeNegZeros = constants.Composite(vec3f, Vector{fNeg0, fNeg0});
+ auto* compositePosZeros = constants.Composite(vec3f, Vector{fPos0, fPos0, fPos0});
+ auto* compositeNegZeros = constants.Composite(vec3f, Vector{fNeg0, fNeg0, fNeg0});
auto* compositeMixed = constants.Composite(vec3f, Vector{fNeg0, fPos1, fPos0});
auto* compositePosNeg = constants.Composite(vec3f, Vector{fNeg1, fPos1, fPos1});
@@ -78,12 +78,12 @@
}
TEST_F(ConstantTest_Composite, Index) {
- auto* vec3f = create<core::type::Vector>(create<core::type::F32>(), 3u);
+ auto* vec2f = create<core::type::Vector>(create<core::type::F32>(), 2u);
auto* fPos0 = constants.Get(0_f);
auto* fPos1 = constants.Get(1_f);
- auto* composite = constants.Composite(vec3f, Vector{fPos1, fPos0});
+ auto* composite = constants.Composite(vec2f, Vector{fPos1, fPos0});
ASSERT_NE(composite->Index(0), nullptr);
ASSERT_NE(composite->Index(1), nullptr);
@@ -96,12 +96,12 @@
}
TEST_F(ConstantTest_Composite, Clone) {
- auto* vec3f = create<core::type::Vector>(create<core::type::F32>(), 3u);
+ auto* vec2f = create<core::type::Vector>(create<core::type::F32>(), 2u);
auto* fPos0 = constants.Get(0_f);
auto* fPos1 = constants.Get(1_f);
- auto* composite = constants.Composite(vec3f, Vector{fPos1, fPos0});
+ auto* composite = constants.Composite(vec2f, Vector{fPos1, fPos0});
constant::Manager mgr;
constant::CloneContext ctx{core::type::CloneContext{{nullptr}, {nullptr, &mgr.types}}, mgr};
diff --git a/src/tint/lang/core/constant/eval_runtime_semantics_test.cc b/src/tint/lang/core/constant/eval_runtime_semantics_test.cc
index 95798e9..d48c8c9 100644
--- a/src/tint/lang/core/constant/eval_runtime_semantics_test.cc
+++ b/src/tint/lang/core/constant/eval_runtime_semantics_test.cc
@@ -479,8 +479,9 @@
}
TEST_F(ConstEvalRuntimeSemanticsTest, Unpack2x16Float_OutOfRange) {
+ auto* vec2f = create<core::type::Vector>(create<core::type::F32>(), 2u);
auto* a = constants.Get(u32(0x51437C00));
- auto result = eval.unpack2x16float(create<core::type::U32>(), Vector{a}, {});
+ auto result = eval.unpack2x16float(vec2f, Vector{a}, {});
ASSERT_EQ(result, Success);
EXPECT_FLOAT_EQ(result.Get()->Index(0)->ValueAs<f32>(), 0.f);
EXPECT_FLOAT_EQ(result.Get()->Index(1)->ValueAs<f32>(), 42.09375f);