tint: add AFloat and AInt const eval scalar constructor tests
Bug: tint:1581 Change-Id: I0cb190e3114f3fd1c68f4cb821399547830239a2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115240 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
bc44620d68
commit
994b70feb9
src/tint/resolver
|
@ -19,6 +19,40 @@ using namespace tint::number_suffixes; // NOLINT
|
||||||
namespace tint::resolver {
|
namespace tint::resolver {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
TEST_F(ResolverConstEvalTest, Scalar_AFloat) {
|
||||||
|
auto* expr = Expr(99.0_a);
|
||||||
|
auto* a = Const("a", expr);
|
||||||
|
WrapInFunction(a);
|
||||||
|
|
||||||
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
auto* sem = Sem().Get(expr);
|
||||||
|
ASSERT_NE(sem, nullptr);
|
||||||
|
EXPECT_TRUE(sem->Type()->Is<type::AbstractFloat>());
|
||||||
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
EXPECT_FALSE(sem->ConstantValue()->AllZero());
|
||||||
|
EXPECT_EQ(sem->ConstantValue()->ValueAs<AFloat>(), 99.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(ResolverConstEvalTest, Scalar_AInt) {
|
||||||
|
auto* expr = Expr(99_a);
|
||||||
|
auto* a = Const("a", expr);
|
||||||
|
WrapInFunction(a);
|
||||||
|
|
||||||
|
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||||
|
|
||||||
|
auto* sem = Sem().Get(expr);
|
||||||
|
ASSERT_NE(sem, nullptr);
|
||||||
|
EXPECT_TRUE(sem->Type()->Is<type::AbstractInt>());
|
||||||
|
EXPECT_TYPE(sem->ConstantValue()->Type(), sem->Type());
|
||||||
|
EXPECT_TRUE(sem->ConstantValue()->AllEqual());
|
||||||
|
EXPECT_FALSE(sem->ConstantValue()->AnyZero());
|
||||||
|
EXPECT_FALSE(sem->ConstantValue()->AllZero());
|
||||||
|
EXPECT_EQ(sem->ConstantValue()->ValueAs<AInt>(), 99);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(ResolverConstEvalTest, Scalar_i32) {
|
TEST_F(ResolverConstEvalTest, Scalar_i32) {
|
||||||
auto* expr = Expr(99_i);
|
auto* expr = Expr(99_i);
|
||||||
WrapInFunction(expr);
|
WrapInFunction(expr);
|
||||||
|
|
Loading…
Reference in New Issue