Re-enable float emission tests

Test a value that should stably convert to decimal exponent
representation.  This might be working around a bug in the MSVC runtime
library.

Bug: tint:201
Change-Id: I37200cef815cafc35284c8c873dfbb8a5312360e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27160
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
David Neto 2020-08-21 21:19:33 +00:00 committed by Commit Bot service account
parent e871e48df0
commit c189b1d479
3 changed files with 12 additions and 9 deletions

View File

@ -69,15 +69,16 @@ TEST_F(HlslGeneratorImplTest, EmitConstructor_UInt) {
EXPECT_EQ(g.result(), "56779u"); EXPECT_EQ(g.result(), "56779u");
} }
TEST_F(HlslGeneratorImplTest, DISABLED_EmitConstructor_Float) { TEST_F(HlslGeneratorImplTest, EmitConstructor_Float) {
ast::type::F32Type f32; ast::type::F32Type f32;
auto lit = std::make_unique<ast::FloatLiteral>(&f32, 1.5e27); // Use a number close to 1<<30 but whose decimal representation ends in 0.
auto lit = std::make_unique<ast::FloatLiteral>(&f32, float((1 << 30) - 4));
ast::ScalarConstructorExpression expr(std::move(lit)); ast::ScalarConstructorExpression expr(std::move(lit));
ast::Module m; ast::Module m;
GeneratorImpl g(&m); GeneratorImpl g(&m);
ASSERT_TRUE(g.EmitConstructor(&expr)) << g.error(); ASSERT_TRUE(g.EmitConstructor(&expr)) << g.error();
EXPECT_EQ(g.result(), "1.49999995e+27f"); EXPECT_EQ(g.result(), "1.07374182e+09f");
} }
TEST_F(HlslGeneratorImplTest, EmitConstructor_Type_Float) { TEST_F(HlslGeneratorImplTest, EmitConstructor_Type_Float) {

View File

@ -69,15 +69,16 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_UInt) {
EXPECT_EQ(g.result(), "56779u"); EXPECT_EQ(g.result(), "56779u");
} }
TEST_F(MslGeneratorImplTest, DISABLED_EmitConstructor_Float) { TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
ast::type::F32Type f32; ast::type::F32Type f32;
auto lit = std::make_unique<ast::FloatLiteral>(&f32, 1.5e27); // Use a number close to 1<<30 but whose decimal representation ends in 0.
auto lit = std::make_unique<ast::FloatLiteral>(&f32, float((1 << 30) - 4));
ast::ScalarConstructorExpression expr(std::move(lit)); ast::ScalarConstructorExpression expr(std::move(lit));
ast::Module m; ast::Module m;
GeneratorImpl g(&m); GeneratorImpl g(&m);
ASSERT_TRUE(g.EmitConstructor(&expr)) << g.error(); ASSERT_TRUE(g.EmitConstructor(&expr)) << g.error();
EXPECT_EQ(g.result(), "1.49999995e+27f"); EXPECT_EQ(g.result(), "1.07374182e+09f");
} }
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) { TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {

View File

@ -64,14 +64,15 @@ TEST_F(WgslGeneratorImplTest, EmitConstructor_UInt) {
EXPECT_EQ(g.result(), "56779u"); EXPECT_EQ(g.result(), "56779u");
} }
TEST_F(WgslGeneratorImplTest, DISABLED_EmitConstructor_Float) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Float) {
ast::type::F32Type f32; ast::type::F32Type f32;
auto lit = std::make_unique<ast::FloatLiteral>(&f32, 1.5e27); // Use a number close to 1<<30 but whose decimal representation ends in 0.
auto lit = std::make_unique<ast::FloatLiteral>(&f32, float((1 << 30) - 4));
ast::ScalarConstructorExpression expr(std::move(lit)); ast::ScalarConstructorExpression expr(std::move(lit));
GeneratorImpl g; GeneratorImpl g;
ASSERT_TRUE(g.EmitConstructor(&expr)) << g.error(); ASSERT_TRUE(g.EmitConstructor(&expr)) << g.error();
EXPECT_EQ(g.result(), "1.49999995e+27"); EXPECT_EQ(g.result(), "1.07374182e+09");
} }
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) { TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {