tint: Replace all ProgramBuilder float literals with '_f' suffix
Unsuffixed float literals are currently treated as f32,
but will shortly become AbstractFloat. To keep tests behaving
identically to how they are currently, change all float literals
to explicitly use the f32 '_f' suffix.
Bug: tint:1504
Change-Id: I2a00725ee1b34a6efbe15ac4ba438c00c4416dd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89402
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc
index 8f9091d..21cbd93 100644
--- a/src/tint/ast/builtin_texture_helper_test.cc
+++ b/src/tint/ast/builtin_texture_helper_test.cc
@@ -461,7 +461,7 @@
return b->ExprList(0_i, // component
"texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f)); // coords
+ b->vec2<f32>(1_f, 2_f)); // coords
},
},
{
@@ -480,7 +480,7 @@
return b->ExprList(0_i, // component
"texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
b->vec2<i32>(3_i, 4_i)); // offset
},
},
@@ -500,7 +500,7 @@
return b->ExprList(0_i, // component
"texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i); // array index
},
},
@@ -521,7 +521,7 @@
return b->ExprList(0_i, // component
"texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
b->vec2<i32>(4_i, 5_i)); // offset
},
@@ -541,7 +541,7 @@
return b->ExprList(0_i, // component
"texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f)); // coords
+ b->vec3<f32>(1_f, 2_f, 3_f)); // coords
},
},
{
@@ -560,7 +560,7 @@
return b->ExprList(0_i, // component
"texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i); // array_index
},
},
@@ -577,7 +577,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f)); // coords
+ b->vec2<f32>(1_f, 2_f)); // coords
},
},
{
@@ -594,7 +594,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
b->vec2<i32>(3_i, 4_i)); // offset
},
},
@@ -612,7 +612,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i); // array_index
},
},
@@ -631,7 +631,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
b->vec2<i32>(4_i, 5_i)); // offset
},
@@ -649,7 +649,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f)); // coords
+ b->vec3<f32>(1_f, 2_f, 3_f)); // coords
},
},
{
@@ -666,7 +666,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i); // array_index
},
},
@@ -684,8 +684,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f); // depth_ref
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f); // depth_ref
},
},
{
@@ -703,8 +703,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f, // depth_ref
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f, // depth_ref
b->vec2<i32>(4_i, 5_i)); // offset
},
},
@@ -723,9 +723,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- 4.f); // depth_ref
+ 4_f); // depth_ref
},
},
{
@@ -744,9 +744,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- 4.f, // depth_ref
+ 4_f, // depth_ref
b->vec2<i32>(5_i, 6_i)); // offset
},
},
@@ -764,8 +764,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f); // depth_ref
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f); // depth_ref
},
},
{
@@ -783,9 +783,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i, // array_index
- 5.f); // depth_ref
+ 5_f); // depth_ref
},
},
{
@@ -951,7 +951,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- 1.0f); // coords
+ 1_f); // coords
},
},
{
@@ -967,7 +967,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f)); // coords
+ b->vec2<f32>(1_f, 2_f)); // coords
},
},
{
@@ -984,7 +984,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
b->vec2<i32>(3_i, 4_i)); // offset
},
},
@@ -1002,7 +1002,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i); // array_index
},
},
@@ -1021,7 +1021,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
b->vec2<i32>(4_i, 5_i)); // offset
},
@@ -1039,7 +1039,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f)); // coords
+ b->vec3<f32>(1_f, 2_f, 3_f)); // coords
},
},
{
@@ -1056,7 +1056,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
b->vec3<i32>(4_i, 5_i, 6_i)); // offset
},
},
@@ -1073,7 +1073,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f)); // coords
+ b->vec3<f32>(1_f, 2_f, 3_f)); // coords
},
},
{
@@ -1090,7 +1090,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i); // array_index
},
},
@@ -1107,7 +1107,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f)); // coords
+ b->vec2<f32>(1_f, 2_f)); // coords
},
},
{
@@ -1124,7 +1124,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
b->vec2<i32>(3_i, 4_i)); // offset
},
},
@@ -1142,7 +1142,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i); // array_index
},
},
@@ -1161,7 +1161,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
b->vec2<i32>(4_i, 5_i)); // offset
},
@@ -1179,7 +1179,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f)); // coords
+ b->vec3<f32>(1_f, 2_f, 3_f)); // coords
},
},
{
@@ -1196,7 +1196,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i); // array_index
},
},
@@ -1214,8 +1214,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f); // bias
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f); // bias
},
},
{
@@ -1233,8 +1233,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f, // bias
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f, // bias
b->vec2<i32>(4_i, 5_i)); // offset
},
},
@@ -1253,9 +1253,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
4_i, // array_index
- 3.f); // bias
+ 3_f); // bias
},
},
{
@@ -1274,9 +1274,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- 4.f, // bias
+ 4_f, // bias
b->vec2<i32>(5_i, 6_i)); // offset
},
},
@@ -1294,8 +1294,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f); // bias
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f); // bias
},
},
{
@@ -1313,8 +1313,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f, // bias
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f, // bias
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
},
},
@@ -1332,8 +1332,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f); // bias
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f); // bias
},
},
{
@@ -1351,9 +1351,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
3_i, // array_index
- 4.f); // bias
+ 4_f); // bias
},
},
{
@@ -1370,8 +1370,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f); // level
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f); // level
},
},
{
@@ -1389,8 +1389,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f, // level
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f, // level
b->vec2<i32>(4_i, 5_i)); // offset
},
},
@@ -1409,9 +1409,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- 4.f); // level
+ 4_f); // level
},
},
{
@@ -1430,9 +1430,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- 4.f, // level
+ 4_f, // level
b->vec2<i32>(5_i, 6_i)); // offset
},
},
@@ -1450,8 +1450,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f); // level
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f); // level
},
},
{
@@ -1469,8 +1469,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f, // level
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f, // level
b->vec3<i32>(5_i, 6_i, 7_i)); // offset
},
},
@@ -1488,8 +1488,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f); // level
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f); // level
},
},
{
@@ -1507,9 +1507,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i, // array_index
- 5.f); // level
+ 5_f); // level
},
},
{
@@ -1526,7 +1526,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i); // level
},
},
@@ -1545,7 +1545,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // level
b->vec2<i32>(4_i, 5_i)); // offset
},
@@ -1565,7 +1565,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
4_i); // level
},
@@ -1586,7 +1586,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
4_i, // level
b->vec2<i32>(5_i, 6_i)); // offset
@@ -1606,7 +1606,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i); // level
},
},
@@ -1625,7 +1625,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i, // array_index
5_i); // level
},
@@ -1643,11 +1643,11 @@
TextureDataType::kF32,
"textureSampleGrad",
[](ProgramBuilder* b) {
- return b->ExprList("texture", // t
- "sampler", // s
- b->vec2<f32>(1.0f, 2.0f), // coords
- b->vec2<f32>(3.0f, 4.0f), // ddx
- b->vec2<f32>(5.0f, 6.0f)); // ddy
+ return b->ExprList("texture", // t
+ "sampler", // s
+ b->vec2<f32>(1_f, 2_f), // coords
+ b->vec2<f32>(3_f, 4_f), // ddx
+ b->vec2<f32>(5_f, 6_f)); // ddy
},
},
{
@@ -1666,9 +1666,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- b->vec2<f32>(3.f, 4.f), // ddx
- b->vec2<f32>(5.f, 6.f), // ddy
+ b->vec2<f32>(1_f, 2_f), // coords
+ b->vec2<f32>(3_f, 4_f), // ddx
+ b->vec2<f32>(5_f, 6_f), // ddy
b->vec2<i32>(7_i, 7_i)); // offset
},
},
@@ -1688,10 +1688,10 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- b->vec2<f32>(4.f, 5.f), // ddx
- b->vec2<f32>(6.f, 7.f)); // ddy
+ b->vec2<f32>(4_f, 5_f), // ddx
+ b->vec2<f32>(6_f, 7_f)); // ddy
},
},
{
@@ -1711,10 +1711,10 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
3_i, // array_index
- b->vec2<f32>(4.f, 5.f), // ddx
- b->vec2<f32>(6.f, 7.f), // ddy
+ b->vec2<f32>(4_f, 5_f), // ddx
+ b->vec2<f32>(6_f, 7_f), // ddy
b->vec2<i32>(6_i, 7_i)); // offset
},
},
@@ -1733,9 +1733,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- b->vec3<f32>(4.f, 5.f, 6.f), // ddx
- b->vec3<f32>(7.f, 8.f, 9.f)); // ddy
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ b->vec3<f32>(4_f, 5_f, 6_f), // ddx
+ b->vec3<f32>(7_f, 8_f, 9_f)); // ddy
},
},
{
@@ -1754,9 +1754,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- b->vec3<f32>(4.f, 5.f, 6.f), // ddx
- b->vec3<f32>(7.f, 8.f, 9.f), // ddy
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ b->vec3<f32>(4_f, 5_f, 6_f), // ddx
+ b->vec3<f32>(7_f, 8_f, 9_f), // ddy
b->vec3<i32>(0_i, 1_i, 2_i)); // offset
},
},
@@ -1775,9 +1775,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- b->vec3<f32>(4.f, 5.f, 6.f), // ddx
- b->vec3<f32>(7.f, 8.f, 9.f)); // ddy
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ b->vec3<f32>(4_f, 5_f, 6_f), // ddx
+ b->vec3<f32>(7_f, 8_f, 9_f)); // ddy
},
},
{
@@ -1796,10 +1796,10 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i, // array_index
- b->vec3<f32>(5.f, 6.f, 7.f), // ddx
- b->vec3<f32>(8.f, 9.f, 10.f)); // ddy
+ b->vec3<f32>(5_f, 6_f, 7_f), // ddx
+ b->vec3<f32>(8_f, 9_f, 10_f)); // ddy
},
},
{
@@ -1816,8 +1816,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f); // depth_ref
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f); // depth_ref
},
},
{
@@ -1835,8 +1835,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
- 3.f, // depth_ref
+ b->vec2<f32>(1_f, 2_f), // coords
+ 3_f, // depth_ref
b->vec2<i32>(4_i, 5_i)); // offset
},
},
@@ -1855,9 +1855,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
4_i, // array_index
- 3.f); // depth_ref
+ 3_f); // depth_ref
},
},
{
@@ -1876,9 +1876,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec2<f32>(1.f, 2.f), // coords
+ b->vec2<f32>(1_f, 2_f), // coords
4_i, // array_index
- 3.f, // depth_ref
+ 3_f, // depth_ref
b->vec2<i32>(5_i, 6_i)); // offset
},
},
@@ -1896,8 +1896,8 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
- 4.f); // depth_ref
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
+ 4_f); // depth_ref
},
},
{
@@ -1915,9 +1915,9 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
"sampler", // s
- b->vec3<f32>(1.f, 2.f, 3.f), // coords
+ b->vec3<f32>(1_f, 2_f, 3_f), // coords
4_i, // array_index
- 5.f); // depth_ref
+ 5_f); // depth_ref
},
},
{
@@ -2196,7 +2196,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
1_i, // coords
- b->vec4<f32>(2.f, 3.f, 4.f, 5.f)); // value
+ b->vec4<f32>(2_f, 3_f, 4_f, 5_f)); // value
},
},
{
@@ -2212,7 +2212,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
b->vec2<i32>(1_i, 2_i), // coords
- b->vec4<f32>(3.f, 4.f, 5.f, 6.f)); // value
+ b->vec4<f32>(3_f, 4_f, 5_f, 6_f)); // value
},
},
{
@@ -2230,7 +2230,7 @@
return b->ExprList("texture", // t
b->vec2<i32>(1_i, 2_i), // coords
3_i, // array_index
- b->vec4<f32>(4.f, 5.f, 6.f, 7.f)); // value
+ b->vec4<f32>(4_f, 5_f, 6_f, 7_f)); // value
},
},
{
@@ -2246,7 +2246,7 @@
[](ProgramBuilder* b) {
return b->ExprList("texture", // t
b->vec3<i32>(1_i, 2_i, 3_i), // coords
- b->vec4<f32>(4.f, 5.f, 6.f, 7.f)); // value
+ b->vec4<f32>(4_f, 5_f, 6_f, 7_f)); // value
},
},
};
diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc
index b43a19e..e62ec1e 100644
--- a/src/tint/ast/variable_test.cc
+++ b/src/tint/ast/variable_test.cc
@@ -17,6 +17,8 @@
#include "src/tint/ast/id_attribute.h"
#include "src/tint/ast/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::ast {
namespace {
@@ -84,7 +86,7 @@
{
ProgramBuilder b1;
ProgramBuilder b2;
- b1.Var("x", b1.ty.f32(), StorageClass::kNone, b2.Expr(1.2f));
+ b1.Var("x", b1.ty.f32(), StorageClass::kNone, b2.Expr(1.2_f));
},
"internal compiler error");
}
diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc
index 1d28818..18a33b1 100644
--- a/src/tint/inspector/inspector_test.cc
+++ b/src/tint/inspector/inspector_test.cc
@@ -623,7 +623,7 @@
}
TEST_F(InspectorGetEntryPointTest, OverridableConstantInitialized) {
- AddOverridableConstantWithoutID("foo", ty.f32(), Expr(0.0f));
+ AddOverridableConstantWithoutID("foo", ty.f32(), Expr(0_f));
MakePlainGlobalReferenceBodyFunction("ep_func", "foo", ty.f32(),
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
@@ -1013,9 +1013,9 @@
TEST_F(InspectorGetConstantIDsTest, Float) {
AddOverridableConstantWithID("foo", 1, ty.f32(), nullptr);
- AddOverridableConstantWithID("bar", 20, ty.f32(), Expr(0.0f));
- AddOverridableConstantWithID("baz", 300, ty.f32(), Expr(-10.0f));
- AddOverridableConstantWithID("x", 4000, ty.f32(), Expr(15.0f));
+ AddOverridableConstantWithID("bar", 20, ty.f32(), Expr(0_f));
+ AddOverridableConstantWithID("baz", 300, ty.f32(), Expr(-10_f));
+ AddOverridableConstantWithID("x", 4000, ty.f32(), Expr(15_f));
Inspector& inspector = Build();
diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h
index 72ffdce..2cd0ff2 100644
--- a/src/tint/program_builder.h
+++ b/src/tint/program_builder.h
@@ -991,21 +991,6 @@
/// @param source the source information
/// @param value the float value
- /// @return a unsuffixed FloatLiteralExpression for the float value
- const ast::FloatLiteralExpression* Expr(const Source& source, float value) {
- return create<ast::FloatLiteralExpression>(source, static_cast<double>(value),
- ast::FloatLiteralExpression::Suffix::kNone);
- }
-
- /// @param value the float value
- /// @return a unsuffixed FloatLiteralExpression for the float value
- const ast::FloatLiteralExpression* Expr(float value) {
- return create<ast::FloatLiteralExpression>(static_cast<double>(value),
- ast::FloatLiteralExpression::Suffix::kNone);
- }
-
- /// @param source the source information
- /// @param value the float value
/// @return a 'f'-suffixed FloatLiteralExpression for the f32 value
const ast::FloatLiteralExpression* Expr(const Source& source, f32 value) {
return create<ast::FloatLiteralExpression>(source, static_cast<double>(value.value),
diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc
index 4a96c7f..82f6224 100644
--- a/src/tint/reader/spirv/function.cc
+++ b/src/tint/reader/spirv/function.cc
@@ -137,6 +137,8 @@
// constructs
//
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::reader::spirv {
namespace {
@@ -3929,7 +3931,7 @@
case GLSLstd450Normalize:
// WGSL does not have scalar form of the normalize builtin.
// The answer would be 1 anyway, so return that directly.
- return {ty_.F32(), builder_.Expr(1.0f)};
+ return {ty_.F32(), builder_.Expr(1_f)};
case GLSLstd450FaceForward: {
// If dot(Nref, Incident) < 0, the result is Normal, otherwise -Normal.
@@ -3952,7 +3954,7 @@
create<ast::BinaryExpression>(
Source{}, ast::BinaryOp::kLessThan,
builder_.Mul({}, incident.expr, nref.expr),
- builder_.Expr(0.0f))})};
+ builder_.Expr(0_f))})};
}
case GLSLstd450Reflect: {
@@ -3961,12 +3963,12 @@
auto normal = MakeOperand(inst, 3);
TINT_ASSERT(Reader, incident.type->Is<F32>());
TINT_ASSERT(Reader, normal.type->Is<F32>());
- return {ty_.F32(),
- builder_.Sub(
- incident.expr,
- builder_.Mul(2.0f,
- builder_.Mul(normal.expr,
- builder_.Mul(normal.expr, incident.expr))))};
+ return {
+ ty_.F32(),
+ builder_.Sub(
+ incident.expr,
+ builder_.Mul(2_f, builder_.Mul(normal.expr,
+ builder_.Mul(normal.expr, incident.expr))))};
}
case GLSLstd450Refract: {
@@ -3987,8 +3989,8 @@
builder_.Call(
Source{}, "refract",
ast::ExpressionList{
- builder_.vec2<tint::f32>(incident.expr, 0.0f),
- builder_.vec2<tint::f32>(normal.expr, 0.0f), eta.expr}),
+ builder_.vec2<tint::f32>(incident.expr, 0_f),
+ builder_.vec2<tint::f32>(normal.expr, 0_f), eta.expr}),
"x")};
}
default:
diff --git a/src/tint/resolver/array_accessor_test.cc b/src/tint/resolver/array_accessor_test.cc
index 1704699..9323b23 100644
--- a/src/tint/resolver/array_accessor_test.cc
+++ b/src/tint/resolver/array_accessor_test.cc
@@ -27,7 +27,7 @@
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
- auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1.0f));
+ auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1_f));
WrapInFunction(acc);
EXPECT_FALSE(r()->Resolve());
@@ -116,7 +116,7 @@
TEST_F(ResolverIndexAccessorTest, Vector_F32) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
- auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2.0f));
+ auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2_f));
WrapInFunction(acc);
EXPECT_FALSE(r()->Resolve());
@@ -224,7 +224,7 @@
// let a : array<f32, 3>;
// var f : f32 = a[2.0f];
auto* a = Let("a", ty.array<f32, 3>(), array<f32, 3>());
- auto* f = Var("a_2", ty.f32(), IndexAccessor("a", Expr(Source{{12, 34}}, 2.0f)));
+ auto* f = Var("a_2", ty.f32(), IndexAccessor("a", Expr(Source{{12, 34}}, 2_f)));
Func("my_func", ast::VariableList{}, ty.void_(),
{
Decl(a),
diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc
index f12f804..e9fb7bf 100644
--- a/src/tint/resolver/assignment_validation_test.cc
+++ b/src/tint/resolver/assignment_validation_test.cc
@@ -52,7 +52,7 @@
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
- auto* assign = Assign(Source{{12, 34}}, "a", 2.3f);
+ auto* assign = Assign(Source{{12, 34}}, "a", 2.3_f);
WrapInFunction(var, assign);
ASSERT_FALSE(r()->Resolve());
@@ -118,7 +118,7 @@
// }
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
- WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2.3f));
+ WrapInFunction(var, Assign(Source{{12, 34}}, "a", 2.3_f));
ASSERT_FALSE(r()->Resolve());
@@ -134,7 +134,7 @@
// }
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
- auto* inner_block = Block(Decl(var), Assign(Source{{12, 34}}, "a", 2.3f));
+ auto* inner_block = Block(Decl(var), Assign(Source{{12, 34}}, "a", 2.3_f));
auto* outer_block = Block(inner_block);
WrapInFunction(outer_block);
@@ -353,7 +353,7 @@
WrapInFunction(Assign(Phony(), 1_i), //
Assign(Phony(), 2_u), //
- Assign(Phony(), 3.f), //
+ Assign(Phony(), 3_f), //
Assign(Phony(), vec2<bool>()), //
Assign(Phony(), "tex"), //
Assign(Phony(), "smp"), //
diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc
index dbefb14..3280ebf 100644
--- a/src/tint/resolver/attribute_validation_test.cc
+++ b/src/tint/resolver/attribute_validation_test.cc
@@ -161,7 +161,7 @@
TEST_P(FunctionReturnTypeAttributeTest, IsValid) {
auto& params = GetParam();
- Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1.f)}, {},
+ Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1_f)}, {},
createAttributes({}, *this, params.kind));
if (params.should_pass) {
@@ -316,7 +316,7 @@
using ComputeShaderReturnTypeAttributeTest = TestWithParams;
TEST_P(ComputeShaderReturnTypeAttributeTest, IsValid) {
auto& params = GetParam();
- Func("main", ast::VariableList{}, ty.vec4<f32>(), {Return(Construct(ty.vec4<f32>(), 1.f))},
+ Func("main", ast::VariableList{}, ty.vec4<f32>(), {Return(Construct(ty.vec4<f32>(), 1_f))},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)},
createAttributes(Source{{12, 34}}, *this, params.kind));
@@ -450,7 +450,7 @@
using EntryPointParameterAttributeTest = TestWithParams;
TEST_F(EntryPointParameterAttributeTest, DuplicateAttribute) {
- Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1.f)},
+ Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1_f)},
{Stage(ast::PipelineStage::kFragment)},
{
Location(Source{{12, 34}}, 2),
@@ -478,7 +478,7 @@
using EntryPointReturnTypeAttributeTest = ResolverTest;
TEST_F(EntryPointReturnTypeAttributeTest, DuplicateAttribute) {
- Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1.f)},
+ Func("main", ast::VariableList{}, ty.f32(), ast::StatementList{Return(1_f)},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)},
ast::AttributeList{
Location(Source{{12, 34}}, 2),
@@ -721,7 +721,8 @@
TEST_P(ConstantAttributeTest, IsValid) {
auto& params = GetParam();
- GlobalConst("a", ty.f32(), Expr(1.23f), createAttributes(Source{{12, 34}}, *this, params.kind));
+ GlobalConst("a", ty.f32(), Expr(1.23_f),
+ createAttributes(Source{{12, 34}}, *this, params.kind));
WrapInFunction();
@@ -750,7 +751,7 @@
TestParams{AttributeKind::kBindingAndGroup, false}));
TEST_F(ConstantAttributeTest, DuplicateAttribute) {
- GlobalConst("a", ty.f32(), Expr(1.23f),
+ GlobalConst("a", ty.f32(), Expr(1.23_f),
ast::AttributeList{
create<ast::IdAttribute>(Source{{12, 34}}, 0),
create<ast::IdAttribute>(Source{{56, 78}}, 1),
diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc
index 3692e98..6020eae 100644
--- a/src/tint/resolver/builtin_test.cc
+++ b/src/tint/resolver/builtin_test.cc
@@ -287,7 +287,7 @@
}
TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) {
- auto* expr = Call("dot", 1.0f, 1.0f);
+ auto* expr = Call("dot", 1_f, 1_f);
WrapInFunction(expr);
EXPECT_FALSE(r()->Resolve());
@@ -349,8 +349,8 @@
}
TEST_F(ResolverBuiltinTest, Select_Error_Matrix) {
- auto* expr = Call("select", mat2x2<f32>(vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f)),
- mat2x2<f32>(vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f)), Expr(true));
+ auto* expr = Call("select", mat2x2<f32>(vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f)),
+ mat2x2<f32>(vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f)), Expr(true));
WrapInFunction(expr);
EXPECT_FALSE(r()->Resolve());
@@ -366,7 +366,7 @@
}
TEST_F(ResolverBuiltinTest, Select_Error_MismatchTypes) {
- auto* expr = Call("select", 1.0f, vec2<f32>(2.0f, 3.0f), Expr(true));
+ auto* expr = Call("select", 1_f, vec2<f32>(2_f, 3_f), Expr(true));
WrapInFunction(expr);
EXPECT_FALSE(r()->Resolve());
@@ -382,7 +382,7 @@
}
TEST_F(ResolverBuiltinTest, Select_Error_MismatchVectorSize) {
- auto* expr = Call("select", vec2<f32>(1.0f, 2.0f), vec3<f32>(3.0f, 4.0f, 5.0f), Expr(true));
+ auto* expr = Call("select", vec2<f32>(1_f, 2_f), vec3<f32>(3_f, 4_f, 5_f), Expr(true));
WrapInFunction(expr);
EXPECT_FALSE(r()->Resolve());
@@ -422,7 +422,7 @@
TEST_P(ResolverBuiltinTest_Barrier, Error_TooManyParams) {
auto param = GetParam();
- auto* call = Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f), 1.0f);
+ auto* call = Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f), 1_f);
WrapInFunction(CallStmt(call));
EXPECT_FALSE(r()->Resolve());
@@ -443,8 +443,8 @@
bool pack4 =
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
- auto* call = pack4 ? Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f))
- : Call(param.name, vec2<f32>(1.f, 2.f));
+ auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f))
+ : Call(param.name, vec2<f32>(1_f, 2_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -484,8 +484,8 @@
bool pack4 =
param.builtin == BuiltinType::kPack4x8snorm || param.builtin == BuiltinType::kPack4x8unorm;
- auto* call = pack4 ? Call(param.name, vec4<f32>(1.f, 2.f, 3.f, 4.f), 1.0f)
- : Call(param.name, vec2<f32>(1.f, 2.f), 1.0f);
+ auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 2_f, 3_f, 4_f), 1_f)
+ : Call(param.name, vec2<f32>(1_f, 2_f), 1_f);
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -535,7 +535,7 @@
TEST_P(ResolverBuiltinTest_SingleParam, Scalar) {
auto param = GetParam();
- auto* call = Call(param.name, 1.f);
+ auto* call = Call(param.name, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -547,7 +547,7 @@
TEST_P(ResolverBuiltinTest_SingleParam, Vector) {
auto param = GetParam();
- auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -647,7 +647,7 @@
}
TEST_F(ResolverBuiltinDataTest, Normalize_Vector) {
- auto* call = Call("normalize", vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call("normalize", vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -671,7 +671,7 @@
}
TEST_F(ResolverBuiltinDataTest, FrexpScalar) {
- auto* call = Call("frexp", 1.0f);
+ auto* call = Call("frexp", 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -750,7 +750,7 @@
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamFloatPtr) {
Global("v", ty.f32(), ast::StorageClass::kWorkgroup);
- auto* call = Call("frexp", 1.0f, AddressOf("v"));
+ auto* call = Call("frexp", 1_f, AddressOf("v"));
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -765,7 +765,7 @@
}
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamNotAPointer) {
- auto* call = Call("frexp", 1.0f, 1_i);
+ auto* call = Call("frexp", 1_f, 1_i);
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -780,7 +780,7 @@
TEST_F(ResolverBuiltinDataTest, Frexp_Error_VectorSizesDontMatch) {
Global("v", ty.vec4<i32>(), ast::StorageClass::kWorkgroup);
- auto* call = Call("frexp", vec2<f32>(1.0f, 2.0f), AddressOf("v"));
+ auto* call = Call("frexp", vec2<f32>(1_f, 2_f), AddressOf("v"));
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -795,7 +795,7 @@
}
TEST_F(ResolverBuiltinDataTest, ModfScalar) {
- auto* call = Call("modf", 1.0f);
+ auto* call = Call("modf", 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -874,7 +874,7 @@
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamIntPtr) {
Global("whole", ty.i32(), ast::StorageClass::kWorkgroup);
- auto* call = Call("modf", 1.0f, AddressOf("whole"));
+ auto* call = Call("modf", 1_f, AddressOf("whole"));
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -889,7 +889,7 @@
}
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamNotAPointer) {
- auto* call = Call("modf", 1.0f, 1.0f);
+ auto* call = Call("modf", 1_f, 1_f);
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -904,7 +904,7 @@
TEST_F(ResolverBuiltinDataTest, Modf_Error_VectorSizesDontMatch) {
Global("whole", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
- auto* call = Call("modf", vec2<f32>(1.0f, 2.0f), AddressOf("whole"));
+ auto* call = Call("modf", vec2<f32>(1_f, 2_f), AddressOf("whole"));
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -922,7 +922,7 @@
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Scalar) {
auto param = GetParam();
- auto* call = Call(param.name, 1.f);
+ auto* call = Call(param.name, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -934,7 +934,7 @@
TEST_P(ResolverBuiltinTest_SingleParam_FloatOrInt, Float_Vector) {
auto param = GetParam();
- auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1015,7 +1015,7 @@
testing::Values(BuiltinData{"abs", BuiltinType::kAbs}));
TEST_F(ResolverBuiltinTest, Length_Scalar) {
- auto* call = Call("length", 1.f);
+ auto* call = Call("length", 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1025,7 +1025,7 @@
}
TEST_F(ResolverBuiltinTest, Length_FloatVector) {
- auto* call = Call("length", vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call("length", vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1038,7 +1038,7 @@
TEST_P(ResolverBuiltinTest_TwoParam, Scalar) {
auto param = GetParam();
- auto* call = Call(param.name, 1.f, 1.f);
+ auto* call = Call(param.name, 1_f, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1050,7 +1050,7 @@
TEST_P(ResolverBuiltinTest_TwoParam, Vector) {
auto param = GetParam();
- auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1097,7 +1097,7 @@
BuiltinData{"step", BuiltinType::kStep}));
TEST_F(ResolverBuiltinTest, Distance_Scalar) {
- auto* call = Call("distance", 1.f, 1.f);
+ auto* call = Call("distance", 1_f, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1107,7 +1107,7 @@
}
TEST_F(ResolverBuiltinTest, Distance_Vector) {
- auto* call = Call("distance", vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call("distance", vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1117,7 +1117,7 @@
}
TEST_F(ResolverBuiltinTest, Cross) {
- auto* call = Call("cross", vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(1.0f, 2.0f, 3.0f));
+ auto* call = Call("cross", vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(1_f, 2_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1141,7 +1141,7 @@
}
TEST_F(ResolverBuiltinTest, Cross_Error_Scalar) {
- auto* call = Call("cross", 1.0f, 1.0f);
+ auto* call = Call("cross", 1_f, 1_f);
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -1168,8 +1168,7 @@
}
TEST_F(ResolverBuiltinTest, Cross_Error_Vec4) {
- auto* call =
- Call("cross", vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f), vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f));
+ auto* call = Call("cross", vec4<f32>(1_f, 2_f, 3_f, 4_f), vec4<f32>(1_f, 2_f, 3_f, 4_f));
WrapInFunction(call);
@@ -1184,8 +1183,8 @@
}
TEST_F(ResolverBuiltinTest, Cross_Error_TooManyParams) {
- auto* call = Call("cross", vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(1.0f, 2.0f, 3.0f),
- vec3<f32>(1.0f, 2.0f, 3.0f));
+ auto* call =
+ Call("cross", vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(1_f, 2_f, 3_f));
WrapInFunction(call);
@@ -1199,7 +1198,7 @@
)");
}
TEST_F(ResolverBuiltinTest, Normalize) {
- auto* call = Call("normalize", vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call("normalize", vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1226,7 +1225,7 @@
TEST_P(ResolverBuiltinTest_ThreeParam, Scalar) {
auto param = GetParam();
- auto* call = Call(param.name, 1.f, 1.f, 1.f);
+ auto* call = Call(param.name, 1_f, 1_f, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1238,8 +1237,8 @@
TEST_P(ResolverBuiltinTest_ThreeParam, Vector) {
auto param = GetParam();
- auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f),
- vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f),
+ vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1271,7 +1270,7 @@
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Scalar) {
auto param = GetParam();
- auto* call = Call(param.name, 1.f, 1.f, 1.f);
+ auto* call = Call(param.name, 1_f, 1_f, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1283,8 +1282,8 @@
TEST_P(ResolverBuiltinTest_ThreeParam_FloatOrInt, Float_Vector) {
auto param = GetParam();
- auto* call = Call(param.name, vec3<f32>(1.0f, 1.0f, 3.0f), vec3<f32>(1.0f, 1.0f, 3.0f),
- vec3<f32>(1.0f, 1.0f, 3.0f));
+ auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f),
+ vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1443,7 +1442,7 @@
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Scalar_Float) {
auto param = GetParam();
- auto* call = Call(param.name, 1.0f, 1.0f);
+ auto* call = Call(param.name, 1_f, 1_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1481,7 +1480,7 @@
TEST_P(ResolverBuiltinTest_FloatOrInt_TwoParam, Vector_Float) {
auto param = GetParam();
- auto* call = Call(param.name, vec3<f32>(1.f, 1.f, 3.f), vec3<f32>(1.f, 1.f, 3.f));
+ auto* call = Call(param.name, vec3<f32>(1_f, 1_f, 3_f), vec3<f32>(1_f, 1_f, 3_f));
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc
index 171c693..0e48b55 100644
--- a/src/tint/resolver/builtin_validation_test.cc
+++ b/src/tint/resolver/builtin_validation_test.cc
@@ -37,7 +37,7 @@
// @stage(compute) @workgroup_size(1) fn func { return dpdx(1.0); }
auto* dpdx =
- create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1.0f)});
+ create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1_f)});
Func(Source{{1, 2}}, "func", ast::VariableList{}, ty.void_(), {CallStmt(dpdx)},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
@@ -52,7 +52,7 @@
// @stage(compute) @workgroup_size(1) fn main { return f2(); }
auto* dpdx =
- create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1.0f)});
+ create<ast::CallExpression>(Source{{3, 4}}, Expr("dpdx"), ast::ExpressionList{Expr(1_f)});
Func(Source{{1, 2}}, "f0", {}, ty.void_(), {CallStmt(dpdx)});
Func(Source{{3, 4}}, "f1", {}, ty.void_(), {CallStmt(Call("f0"))});
diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc
index 87835d6..9744e9b 100644
--- a/src/tint/resolver/builtins_validation_test.cc
+++ b/src/tint/resolver/builtins_validation_test.cc
@@ -132,7 +132,7 @@
// ) -> @location(0) f32 { return 1.0; }
auto* fd = Param("fd", ty.f32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
- Func("fs_main", ast::VariableList{fd}, ty.f32(), {Return(1.0f)},
+ Func("fs_main", ast::VariableList{fd}, ty.f32(), {Return(1_f)},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -152,7 +152,7 @@
{Member("frag_depth", ty.f32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)})});
- Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -187,7 +187,7 @@
auto* m = Member("position", ty.vec4<u32>(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
auto* s = Structure("MyInputs", {m});
- Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
@@ -197,7 +197,7 @@
TEST_F(ResolverBuiltinsValidationTest, PositionNotF32_ReturnType_Fail) {
// @stage(vertex)
// fn main() -> @builtin(position) f32 { return 1.0; }
- Func("main", {}, ty.f32(), {Return(1.0f)}, {Stage(ast::PipelineStage::kVertex)},
+ Func("main", {}, ty.f32(), {Return(1_f)}, {Stage(ast::PipelineStage::kVertex)},
{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
EXPECT_FALSE(r()->Resolve());
@@ -214,7 +214,7 @@
auto* m = Member("frag_depth", ty.i32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFragDepth)});
auto* s = Structure("MyInputs", {m});
- Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
@@ -232,7 +232,7 @@
"MyInputs",
{Member("m", ty.f32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)})});
- Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
@@ -256,7 +256,7 @@
// ) -> @location(0) f32 { return 1.0; }
auto* arg = Param("arg", ty.bool_(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleMask)});
- Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1.0f)},
+ Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1_f)},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(sample_mask) must be 'u32'");
@@ -273,7 +273,7 @@
"MyInputs",
{Member("m", ty.f32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)})});
- Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
@@ -287,7 +287,7 @@
// ) -> @location(0) f32 { return 1.0; }
auto* arg = Param("arg", ty.bool_(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kSampleIndex)});
- Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1.0f)},
+ Func("fs_main", ast::VariableList{arg}, ty.f32(), {Return(1_f)},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(sample_index) must be 'u32'");
@@ -300,7 +300,7 @@
// ) -> @location(0) f32 { return 1.0; }
auto* p = Param("p", ty.vec3<f32>(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kPosition)});
- Func("fs_main", ast::VariableList{p}, ty.f32(), {Return(1.0f)},
+ Func("fs_main", ast::VariableList{p}, ty.f32(), {Return(1_f)},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: store type of builtin(position) must be 'vec4<f32>'");
@@ -503,7 +503,7 @@
ast::AttributeList{Builtin(ast::Builtin::kFrontFacing)}),
Member("sample_index", ty.u32(), ast::AttributeList{Builtin(ast::Builtin::kSampleIndex)}),
Member("sample_mask", ty.u32(), ast::AttributeList{Builtin(ast::Builtin::kSampleMask)})});
- Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("arg", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@@ -517,7 +517,7 @@
auto* is_front =
Param("is_front", ty.i32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFrontFacing)});
- Func("fs_main", ast::VariableList{is_front}, ty.f32(), {Return(1.0f)},
+ Func("fs_main", ast::VariableList{is_front}, ty.f32(), {Return(1_f)},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
@@ -535,7 +535,7 @@
"MyInputs",
{Member("pos", ty.f32(),
ast::AttributeList{Builtin(Source{{12, 34}}, ast::Builtin::kFrontFacing)})});
- Func("fragShader", {Param("is_front", ty.Of(s))}, ty.f32(), {Return(1.0f)},
+ Func("fragShader", {Param("is_front", ty.Of(s))}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_FALSE(r()->Resolve());
@@ -543,90 +543,88 @@
}
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Scalar) {
- auto* builtin = Call("length", 1.0f);
+ auto* builtin = Call("length", 1_f);
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec2) {
- auto* builtin = Call("length", vec2<f32>(1.0f, 1.0f));
+ auto* builtin = Call("length", vec2<f32>(1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec3) {
- auto* builtin = Call("length", vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("length", vec3<f32>(1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Length_Float_Vec4) {
- auto* builtin = Call("length", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("length", vec4<f32>(1_f, 1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Scalar) {
- auto* builtin = Call("distance", 1.0f, 1.0f);
+ auto* builtin = Call("distance", 1_f, 1_f);
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec2) {
- auto* builtin = Call("distance", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* builtin = Call("distance", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec3) {
- auto* builtin = Call("distance", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("distance", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Distance_Float_Vec4) {
- auto* builtin =
- Call("distance", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("distance", vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat2x2) {
- auto* builtin = Call("determinant", mat2x2<f32>(vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f)));
+ auto* builtin = Call("determinant", mat2x2<f32>(vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f)));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat3x3) {
- auto* builtin =
- Call("determinant", mat3x3<f32>(vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f),
- vec3<f32>(1.0f, 1.0f, 1.0f)));
+ auto* builtin = Call(
+ "determinant",
+ mat3x3<f32>(vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f)));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Determinant_Mat4x4) {
- auto* builtin =
- Call("determinant",
- mat4x4<f32>(vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f),
- vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f)));
+ auto* builtin = Call("determinant",
+ mat4x4<f32>(vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f),
+ vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f)));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Scalar) {
- auto* builtin = Call("frexp", 1.0f);
+ auto* builtin = Call("frexp", 1_f);
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -639,7 +637,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec2) {
- auto* builtin = Call("frexp", vec2<f32>(1.0f, 1.0f));
+ auto* builtin = Call("frexp", vec2<f32>(1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -656,7 +654,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec3) {
- auto* builtin = Call("frexp", vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("frexp", vec3<f32>(1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -673,7 +671,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Frexp_Vec4) {
- auto* builtin = Call("frexp", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("frexp", vec4<f32>(1_f, 1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -690,7 +688,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Scalar) {
- auto* builtin = Call("modf", 1.0f);
+ auto* builtin = Call("modf", 1_f);
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -703,7 +701,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec2) {
- auto* builtin = Call("modf", vec2<f32>(1.0f, 1.0f));
+ auto* builtin = Call("modf", vec2<f32>(1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -720,7 +718,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec3) {
- auto* builtin = Call("modf", vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("modf", vec3<f32>(1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -737,7 +735,7 @@
}
TEST_F(ResolverBuiltinsValidationTest, Modf_Vec4) {
- auto* builtin = Call("modf", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("modf", vec4<f32>(1_f, 1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -754,36 +752,35 @@
}
TEST_F(ResolverBuiltinsValidationTest, Cross_Float_Vec3) {
- auto* builtin = Call("cross", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("cross", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec2) {
- auto* builtin = Call("dot", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* builtin = Call("dot", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec3) {
- auto* builtin = Call("dot", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("dot", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Dot_Float_Vec4) {
- auto* builtin =
- Call("dot", vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f), vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ auto* builtin = Call("dot", vec4<f32>(1_f, 1_f, 1_f, 1_f), vec4<f32>(1_f, 1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverBuiltinsValidationTest, Select_Float_Scalar) {
- auto* builtin = Call("select", Expr(1.0f), Expr(1.0f), Expr(true));
+ auto* builtin = Call("select", Expr(1_f), Expr(1_f), Expr(true));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -805,7 +802,7 @@
TEST_F(ResolverBuiltinsValidationTest, Select_Float_Vec2) {
auto* builtin =
- Call("select", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f), vec2<bool>(true, true));
+ Call("select", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f), vec2<bool>(true, true));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -840,7 +837,7 @@
ast::ExpressionList params;
for (uint32_t i = 0; i < num_params; ++i) {
- params.push_back(Expr(1.0f));
+ params.push_back(Expr(1_f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {CallStmt(builtin)},
@@ -856,7 +853,7 @@
ast::ExpressionList params;
for (uint32_t i = 0; i < num_params; ++i) {
- params.push_back(vec2<f32>(1.0f, 1.0f));
+ params.push_back(vec2<f32>(1_f, 1_f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {CallStmt(builtin)},
@@ -872,7 +869,7 @@
ast::ExpressionList params;
for (uint32_t i = 0; i < num_params; ++i) {
- params.push_back(vec3<f32>(1.0f, 1.0f, 1.0f));
+ params.push_back(vec3<f32>(1_f, 1_f, 1_f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {CallStmt(builtin)},
@@ -888,7 +885,7 @@
ast::ExpressionList params;
for (uint32_t i = 0; i < num_params; ++i) {
- params.push_back(vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ params.push_back(vec4<f32>(1_f, 1_f, 1_f, 1_f));
}
auto* builtin = Call(name, params);
Func("func", {}, ty.void_(), {CallStmt(builtin)},
@@ -1126,7 +1123,7 @@
TEST_P(DataPacking4x8, Float_Vec4) {
auto name = GetParam();
- auto* builtin = Call(name, vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f));
+ auto* builtin = Call(name, vec4<f32>(1_f, 1_f, 1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@@ -1139,7 +1136,7 @@
TEST_P(DataPacking2x16, Float_Vec2) {
auto name = GetParam();
- auto* builtin = Call(name, vec2<f32>(1.0f, 1.0f));
+ auto* builtin = Call(name, vec2<f32>(1_f, 1_f));
WrapInFunction(builtin);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
diff --git a/src/tint/resolver/call_test.cc b/src/tint/resolver/call_test.cc
index c8b9856..d84f300 100644
--- a/src/tint/resolver/call_test.cc
+++ b/src/tint/resolver/call_test.cc
@@ -18,6 +18,8 @@
#include "src/tint/ast/call_statement.h"
#include "src/tint/resolver/resolver_test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::resolver {
namespace {
// Helpers and typedefs
@@ -86,7 +88,7 @@
args.push_back(p.create_value(*this, 0));
}
- auto* func = Func("foo", std::move(params), ty.f32(), {Return(1.23f)});
+ auto* func = Func("foo", std::move(params), ty.f32(), {Return(1.23_f)});
auto* call_expr = Call("foo", std::move(args));
WrapInFunction(call_expr);
diff --git a/src/tint/resolver/call_validation_test.cc b/src/tint/resolver/call_validation_test.cc
index e1956ae..84d2a51 100644
--- a/src/tint/resolver/call_validation_test.cc
+++ b/src/tint/resolver/call_validation_test.cc
@@ -36,7 +36,7 @@
TEST_F(ResolverCallValidationTest, TooManyArgs) {
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
- auto* call = Call(Source{{12, 34}}, "foo", 1_i, 1.0f, 1.0f);
+ auto* call = Call(Source{{12, 34}}, "foo", 1_i, 1_f, 1_f);
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -45,7 +45,7 @@
TEST_F(ResolverCallValidationTest, MismatchedArgs) {
Func("foo", {Param(Sym(), ty.i32()), Param(Sym(), ty.f32())}, ty.void_(), {Return()});
- auto* call = Call("foo", Expr(Source{{12, 34}}, true), 1.0f);
+ auto* call = Call("foo", Expr(Source{{12, 34}}, true), 1_f);
WrapInFunction(call);
EXPECT_FALSE(r()->Resolve());
@@ -58,7 +58,7 @@
// fn func() -> f32 { return 1.0; }
// fn main() {func(); return; }
- Func("func", {}, ty.f32(), {Return(Expr(1.0f))}, {});
+ Func("func", {}, ty.f32(), {Return(Expr(1_f))}, {});
Func("main", {}, ty.void_(),
{
diff --git a/src/tint/resolver/compound_assignment_validation_test.cc b/src/tint/resolver/compound_assignment_validation_test.cc
index 1bfffb9..1ae7040 100644
--- a/src/tint/resolver/compound_assignment_validation_test.cc
+++ b/src/tint/resolver/compound_assignment_validation_test.cc
@@ -68,7 +68,7 @@
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2_i));
- auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.3f, ast::BinaryOp::kAdd);
+ auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.3_f, ast::BinaryOp::kAdd);
WrapInFunction(var, assign);
ASSERT_FALSE(r()->Resolve());
@@ -83,9 +83,9 @@
// a |= 2.0;
// }
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1.f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
- auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.0f, ast::BinaryOp::kOr);
+ auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2_f, ast::BinaryOp::kOr);
WrapInFunction(var, assign);
ASSERT_FALSE(r()->Resolve());
@@ -102,7 +102,7 @@
auto* var = Var("a", ty.vec4<f32>(), ast::StorageClass::kNone);
- auto* assign = CompoundAssign(Source{{12, 34}}, "a", 1.f, ast::BinaryOp::kAdd);
+ auto* assign = CompoundAssign(Source{{12, 34}}, "a", 1_f, ast::BinaryOp::kAdd);
WrapInFunction(var, assign);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -132,7 +132,7 @@
auto* var = Var("a", ty.mat4x4<f32>(), ast::StorageClass::kNone);
- auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2.f, ast::BinaryOp::kMultiply);
+ auto* assign = CompoundAssign(Source{{12, 34}}, "a", 2_f, ast::BinaryOp::kMultiply);
WrapInFunction(var, assign);
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/control_block_validation_test.cc b/src/tint/resolver/control_block_validation_test.cc
index 0fab665..a5ba7ca 100644
--- a/src/tint/resolver/control_block_validation_test.cc
+++ b/src/tint/resolver/control_block_validation_test.cc
@@ -30,7 +30,7 @@
// switch (a) {
// default: {}
// }
- auto* var = Var("a", ty.f32(), Expr(3.14f));
+ auto* var = Var("a", ty.f32(), Expr(3.14_f));
auto* block = Block(Decl(var), Switch(Expr(Source{{12, 34}}, "a"), //
DefaultCase()));
diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc
index 248dc87..82b0a69 100644
--- a/src/tint/resolver/dependency_graph_test.cc
+++ b/src/tint/resolver/dependency_graph_test.cc
@@ -717,9 +717,10 @@
// }
// var G: f32 = 2.1;
- Func("F", ast::VariableList{}, ty.void_(), {Block(Assign(Expr(Source{{12, 34}}, "G"), 3.14f))});
+ Func("F", ast::VariableList{}, ty.void_(),
+ {Block(Assign(Expr(Source{{12, 34}}, "G"), 3.14_f))});
- Global(Source{{56, 78}}, "G", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
+ Global(Source{{56, 78}}, "G", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
Build();
}
diff --git a/src/tint/resolver/entry_point_validation_test.cc b/src/tint/resolver/entry_point_validation_test.cc
index c3f1ff5..3028d9b 100644
--- a/src/tint/resolver/entry_point_validation_test.cc
+++ b/src/tint/resolver/entry_point_validation_test.cc
@@ -49,7 +49,7 @@
TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Location) {
// @stage(fragment)
// fn main() -> @location(0) f32 { return 1.0; }
- Func(Source{{12, 34}}, "main", {}, ty.f32(), {Return(1.0f)},
+ Func(Source{{12, 34}}, "main", {}, ty.f32(), {Return(1_f)},
{Stage(ast::PipelineStage::kFragment)}, {Location(0)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/function_validation_test.cc b/src/tint/resolver/function_validation_test.cc
index 8f878c0..ce37ba5 100644
--- a/src/tint/resolver/function_validation_test.cc
+++ b/src/tint/resolver/function_validation_test.cc
@@ -288,7 +288,7 @@
// fn func() -> f32 { return 2.0; }
Func("func", ast::VariableList{}, ty.f32(),
ast::StatementList{
- Return(Source{{12, 34}}, Expr(2.f)),
+ Return(Source{{12, 34}}, Expr(2_f)),
},
ast::AttributeList{});
@@ -315,7 +315,7 @@
auto* myf32 = Alias("myf32", ty.f32());
Func("func", ast::VariableList{}, ty.Of(myf32),
ast::StatementList{
- Return(Source{{12, 34}}, Expr(2.f)),
+ Return(Source{{12, 34}}, Expr(2_f)),
},
ast::AttributeList{});
@@ -539,7 +539,7 @@
// fn main() {}
Func("main", {}, ty.void_(), {},
- {Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, 64.f))});
+ {Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, 64_f))});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@@ -573,7 +573,7 @@
// let x = 64.0;
// @stage(compute) @workgroup_size(x)
// fn main() {}
- GlobalConst("x", ty.f32(), Expr(64.f));
+ GlobalConst("x", ty.f32(), Expr(64_f));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
diff --git a/src/tint/resolver/increment_decrement_validation_test.cc b/src/tint/resolver/increment_decrement_validation_test.cc
index 37033c5..e03352e 100644
--- a/src/tint/resolver/increment_decrement_validation_test.cc
+++ b/src/tint/resolver/increment_decrement_validation_test.cc
@@ -101,7 +101,7 @@
TEST_F(ResolverIncrementDecrementValidationTest, Float) {
// var a : f32 = 2.0;
// a++;
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* inc = Increment(Expr(Source{{12, 34}}, "a"));
WrapInFunction(var, inc);
diff --git a/src/tint/resolver/pipeline_overridable_constant_test.cc b/src/tint/resolver/pipeline_overridable_constant_test.cc
index 35c145e..035936c3 100644
--- a/src/tint/resolver/pipeline_overridable_constant_test.cc
+++ b/src/tint/resolver/pipeline_overridable_constant_test.cc
@@ -16,6 +16,8 @@
#include "src/tint/resolver/resolver_test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::resolver {
namespace {
@@ -36,7 +38,7 @@
};
TEST_F(ResolverPipelineOverridableConstantTest, NonOverridable) {
- auto* a = GlobalConst("a", ty.f32(), Expr(1.f));
+ auto* a = GlobalConst("a", ty.f32(), Expr(1_f));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -48,7 +50,7 @@
}
TEST_F(ResolverPipelineOverridableConstantTest, WithId) {
- auto* a = Override("a", ty.f32(), Expr(1.f), {Id(7u)});
+ auto* a = Override("a", ty.f32(), Expr(1_f), {Id(7u)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -56,7 +58,7 @@
}
TEST_F(ResolverPipelineOverridableConstantTest, WithoutId) {
- auto* a = Override("a", ty.f32(), Expr(1.f));
+ auto* a = Override("a", ty.f32(), Expr(1_f));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -65,12 +67,12 @@
TEST_F(ResolverPipelineOverridableConstantTest, WithAndWithoutIds) {
std::vector<ast::Variable*> variables;
- auto* a = Override("a", ty.f32(), Expr(1.f));
- auto* b = Override("b", ty.f32(), Expr(1.f));
- auto* c = Override("c", ty.f32(), Expr(1.f), {Id(2u)});
- auto* d = Override("d", ty.f32(), Expr(1.f), {Id(4u)});
- auto* e = Override("e", ty.f32(), Expr(1.f));
- auto* f = Override("f", ty.f32(), Expr(1.f), {Id(1u)});
+ auto* a = Override("a", ty.f32(), Expr(1_f));
+ auto* b = Override("b", ty.f32(), Expr(1_f));
+ auto* c = Override("c", ty.f32(), Expr(1_f), {Id(2u)});
+ auto* d = Override("d", ty.f32(), Expr(1_f), {Id(4u)});
+ auto* e = Override("e", ty.f32(), Expr(1_f));
+ auto* f = Override("f", ty.f32(), Expr(1_f), {Id(1u)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -84,8 +86,8 @@
}
TEST_F(ResolverPipelineOverridableConstantTest, DuplicateIds) {
- Override("a", ty.f32(), Expr(1.f), {Id(Source{{12, 34}}, 7u)});
- Override("b", ty.f32(), Expr(1.f), {Id(Source{{56, 78}}, 7u)});
+ Override("a", ty.f32(), Expr(1_f), {Id(Source{{12, 34}}, 7u)});
+ Override("b", ty.f32(), Expr(1_f), {Id(Source{{56, 78}}, 7u)});
EXPECT_FALSE(r()->Resolve());
@@ -94,7 +96,7 @@
}
TEST_F(ResolverPipelineOverridableConstantTest, IdTooLarge) {
- Override("a", ty.f32(), Expr(1.f), {Id(Source{{12, 34}}, 65536u)});
+ Override("a", ty.f32(), Expr(1_f), {Id(Source{{12, 34}}, 65536u)});
EXPECT_FALSE(r()->Resolve());
diff --git a/src/tint/resolver/resolver_constants.cc b/src/tint/resolver/resolver_constants.cc
index 1400926..2a8a1d1 100644
--- a/src/tint/resolver/resolver_constants.cc
+++ b/src/tint/resolver/resolver_constants.cc
@@ -71,7 +71,7 @@
return sem::Constant(type, sem::Constant::Scalars(result_size, 0_u));
}
if (elem_type->Is<sem::F32>()) {
- return sem::Constant(type, sem::Constant::Scalars(result_size, 0._f));
+ return sem::Constant(type, sem::Constant::Scalars(result_size, 0_f));
}
if (elem_type->Is<sem::Bool>()) {
return sem::Constant(type, sem::Constant::Scalars(result_size, false));
diff --git a/src/tint/resolver/resolver_constants_test.cc b/src/tint/resolver/resolver_constants_test.cc
index 585aaf5..a9624ca 100644
--- a/src/tint/resolver/resolver_constants_test.cc
+++ b/src/tint/resolver/resolver_constants_test.cc
@@ -58,7 +58,7 @@
}
TEST_F(ResolverConstantsTest, Scalar_f32) {
- auto* expr = Expr(9.9f);
+ auto* expr = Expr(9.9_f);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -202,7 +202,7 @@
}
TEST_F(ResolverConstantsTest, Vec3_Splat_f32) {
- auto* expr = vec3<f32>(9.9f);
+ auto* expr = vec3<f32>(9.9_f);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -278,7 +278,7 @@
}
TEST_F(ResolverConstantsTest, Vec3_FullConstruct_f32) {
- auto* expr = vec3<f32>(1.f, 2.f, 3.f);
+ auto* expr = vec3<f32>(1_f, 2_f, 3_f);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -354,7 +354,7 @@
}
TEST_F(ResolverConstantsTest, Vec3_MixConstruct_f32) {
- auto* expr = vec3<f32>(1.f, vec2<f32>(2.f, 3.f));
+ auto* expr = vec3<f32>(1_f, vec2<f32>(2_f, 3_f));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -392,7 +392,7 @@
}
TEST_F(ResolverConstantsTest, Vec3_Cast_f32_to_32) {
- auto* expr = vec3<i32>(vec3<f32>(1.1f, 2.2f, 3.3f));
+ auto* expr = vec3<i32>(vec3<f32>(1.1_f, 2.2_f, 3.3_f));
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc
index 8b2b04f..3b86a48 100644
--- a/src/tint/resolver/resolver_test.cc
+++ b/src/tint/resolver/resolver_test.cc
@@ -88,7 +88,7 @@
TEST_F(ResolverTest, Stmt_Assign) {
auto* v = Var("v", ty.f32());
auto* lhs = Expr("v");
- auto* rhs = Expr(2.3f);
+ auto* rhs = Expr(2.3_f);
auto* assign = Assign(lhs, rhs);
WrapInFunction(v, assign);
@@ -107,7 +107,7 @@
TEST_F(ResolverTest, Stmt_Case) {
auto* v = Var("v", ty.f32());
auto* lhs = Expr("v");
- auto* rhs = Expr(2.3f);
+ auto* rhs = Expr(2.3_f);
auto* assign = Assign(lhs, rhs);
auto* block = Block(assign);
@@ -132,7 +132,7 @@
TEST_F(ResolverTest, Stmt_Block) {
auto* v = Var("v", ty.f32());
auto* lhs = Expr("v");
- auto* rhs = Expr(2.3f);
+ auto* rhs = Expr(2.3_f);
auto* assign = Assign(lhs, rhs);
auto* block = Block(assign);
@@ -154,7 +154,7 @@
TEST_F(ResolverTest, Stmt_If) {
auto* v = Var("v", ty.f32());
auto* else_lhs = Expr("v");
- auto* else_rhs = Expr(2.3f);
+ auto* else_rhs = Expr(2.3_f);
auto* else_body = Block(Assign(else_lhs, else_rhs));
@@ -162,7 +162,7 @@
auto* else_stmt = If(else_cond, else_body);
auto* lhs = Expr("v");
- auto* rhs = Expr(2.3f);
+ auto* rhs = Expr(2.3_f);
auto* assign = Assign(lhs, rhs);
auto* body = Block(assign);
@@ -195,11 +195,11 @@
TEST_F(ResolverTest, Stmt_Loop) {
auto* v = Var("v", ty.f32());
auto* body_lhs = Expr("v");
- auto* body_rhs = Expr(2.3f);
+ auto* body_rhs = Expr(2.3_f);
auto* body = Block(Assign(body_lhs, body_rhs), Break());
auto* continuing_lhs = Expr("v");
- auto* continuing_rhs = Expr(2.3f);
+ auto* continuing_rhs = Expr(2.3_f);
auto* continuing = Block(Assign(continuing_lhs, continuing_rhs));
auto* stmt = Loop(body, continuing);
@@ -243,7 +243,7 @@
TEST_F(ResolverTest, Stmt_Switch) {
auto* v = Var("v", ty.f32());
auto* lhs = Expr("v");
- auto* rhs = Expr(2.3f);
+ auto* rhs = Expr(2.3_f);
auto* case_block = Block(Assign(lhs, rhs));
auto* stmt = Switch(Expr(2_i), Case(Expr(3_i), case_block), DefaultCase());
WrapInFunction(v, stmt);
@@ -340,7 +340,7 @@
auto* inner = Block(foo_i32_decl, bar_i32_decl);
// Declare f32 "foo" at function scope
- auto* foo_f32 = Var("foo", ty.f32(), ast::StorageClass::kNone, Expr(2.f));
+ auto* foo_f32 = Var("foo", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* foo_f32_init = foo_f32->constructor;
auto* foo_f32_decl = Decl(foo_f32);
@@ -390,7 +390,7 @@
Func("func_i32", params, ty.void_(), {fn_i32_decl}, ast::AttributeList{});
// Declare f32 "foo" at module scope
- auto* mod_f32 = Var("foo", ty.f32(), ast::StorageClass::kPrivate, Expr(2.f));
+ auto* mod_f32 = Var("foo", ty.f32(), ast::StorageClass::kPrivate, Expr(2_f));
auto* mod_init = mod_f32->constructor;
AST().AddGlobalVariable(mod_f32);
@@ -486,7 +486,7 @@
TEST_F(ResolverTest, Expr_Call) {
ast::VariableList params;
- Func("my_func", params, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
+ Func("my_func", params, ty.f32(), {Return(0_f)}, ast::AttributeList{});
auto* call = Call("my_func");
WrapInFunction(call);
@@ -499,7 +499,7 @@
TEST_F(ResolverTest, Expr_Call_InBinaryOp) {
ast::VariableList params;
- Func("func", params, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
+ Func("func", params, ty.f32(), {Return(0_f)}, ast::AttributeList{});
auto* expr = Add(Call("func"), Call("func"));
WrapInFunction(expr);
@@ -513,10 +513,10 @@
TEST_F(ResolverTest, Expr_Call_WithParams) {
Func("my_func", {Param(Sym(), ty.f32())}, ty.f32(),
{
- Return(1.2f),
+ Return(1.2_f),
});
- auto* param = Expr(2.4f);
+ auto* param = Expr(2.4_f);
auto* call = Call("my_func", param);
WrapInFunction(call);
@@ -528,7 +528,7 @@
}
TEST_F(ResolverTest, Expr_Call_Builtin) {
- auto* call = Call("round", 2.4f);
+ auto* call = Call("round", 2.4_f);
WrapInFunction(call);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -550,7 +550,7 @@
}
TEST_F(ResolverTest, Expr_Constructor_Scalar) {
- auto* s = Expr(1.0f);
+ auto* s = Expr(1_f);
WrapInFunction(s);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -560,7 +560,7 @@
}
TEST_F(ResolverTest, Expr_Constructor_Type_Vec2) {
- auto* tc = vec2<f32>(1.0f, 1.0f);
+ auto* tc = vec2<f32>(1_f, 1_f);
WrapInFunction(tc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -572,7 +572,7 @@
}
TEST_F(ResolverTest, Expr_Constructor_Type_Vec3) {
- auto* tc = vec3<f32>(1.0f, 1.0f, 1.0f);
+ auto* tc = vec3<f32>(1_f, 1_f, 1_f);
WrapInFunction(tc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -584,7 +584,7 @@
}
TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) {
- auto* tc = vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f);
+ auto* tc = vec4<f32>(1_f, 1_f, 1_f, 1_f);
WrapInFunction(tc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -703,7 +703,7 @@
auto* p = Expr("p");
auto* v_decl = Decl(Var("v", ty.f32()));
auto* p_decl = Decl(Let("p", ty.pointer<f32>(ast::StorageClass::kFunction), AddressOf(v)));
- auto* assign = Assign(Deref(p), 1.23f);
+ auto* assign = Assign(Deref(p), 1.23_f);
Func("my_func", ast::VariableList{}, ty.void_(),
{
v_decl,
@@ -725,7 +725,7 @@
}
TEST_F(ResolverTest, Expr_Call_Function) {
- Func("my_func", ast::VariableList{}, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
+ Func("my_func", ast::VariableList{}, ty.f32(), {Return(0_f)}, ast::AttributeList{});
auto* call = Call("my_func");
WrapInFunction(call);
@@ -815,7 +815,7 @@
Func("my_func", ast::VariableList{}, ty.f32(),
{Assign("wg_var", "wg_var"), Assign("sb_var", "sb_var"), Assign("priv_var", "priv_var"),
- Return(0.0f)},
+ Return(0_f)},
ast::AttributeList{});
auto* func2 = Func("func", ast::VariableList{}, ty.void_(),
@@ -841,7 +841,7 @@
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
{
Decl(Var("var", ty.f32())),
- Assign("var", 1.f),
+ Assign("var", 1_f),
});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -1795,11 +1795,11 @@
Global("call_c", ty.f32(), ast::StorageClass::kPrivate);
ast::VariableList params;
- auto* func_b = Func("b", params, ty.f32(), {Return(0.0f)}, ast::AttributeList{});
- auto* func_c = Func("c", params, ty.f32(), {Assign("second", Call("b")), Return(0.0f)},
+ auto* func_b = Func("b", params, ty.f32(), {Return(0_f)}, ast::AttributeList{});
+ auto* func_c = Func("c", params, ty.f32(), {Assign("second", Call("b")), Return(0_f)},
ast::AttributeList{});
- auto* func_a = Func("a", params, ty.f32(), {Assign("first", Call("c")), Return(0.0f)},
+ auto* func_a = Func("a", params, ty.f32(), {Assign("first", Call("c")), Return(0_f)},
ast::AttributeList{});
auto* ep_1 = Func("ep_1", params, ty.void_(),
@@ -1959,7 +1959,7 @@
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
- auto* call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1.0f, 2.0f)));
+ auto* call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* f =
Func("test_function", {}, ty.void_(), {call}, {Stage(ast::PipelineStage::kFragment)});
@@ -1976,7 +1976,7 @@
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
- auto* inner_call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1.0f, 2.0f)));
+ auto* inner_call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* inner_func = Func("inner_func", {}, ty.void_(), {inner_call});
auto* outer_call = CallStmt(Call("inner_func"));
const ast::Function* outer_func =
@@ -1999,9 +1999,9 @@
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
- auto* inner_call_1 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1.0f, 2.0f)));
+ auto* inner_call_1 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
- auto* inner_call_2 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(3.0f, 4.0f)));
+ auto* inner_call_2 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(3_f, 4_f)));
const ast::Function* inner_func_2 = Func("inner_func_2", {}, ty.void_(), {inner_call_2});
auto* outer_call_1 = CallStmt(Call("inner_func_1"));
auto* outer_call_2 = CallStmt(Call("inner_func_2"));
@@ -2032,9 +2032,9 @@
Global("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 2));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 3));
- auto* inner_call_1 = CallStmt(Call("textureSample", "t1", "s", vec2<f32>(1.0f, 2.0f)));
+ auto* inner_call_1 = CallStmt(Call("textureSample", "t1", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
- auto* inner_call_2 = CallStmt(Call("textureSample", "t2", "s", vec2<f32>(3.0f, 4.0f)));
+ auto* inner_call_2 = CallStmt(Call("textureSample", "t2", "s", vec2<f32>(3_f, 4_f)));
const ast::Function* inner_func_2 = Func("inner_func_2", {}, ty.void_(), {inner_call_2});
auto* outer_call_1 = CallStmt(Call("inner_func_1"));
auto* outer_call_2 = CallStmt(Call("inner_func_2"));
diff --git a/src/tint/resolver/source_variable_test.cc b/src/tint/resolver/source_variable_test.cc
index f9fe2fb..cd943f3 100644
--- a/src/tint/resolver/source_variable_test.cc
+++ b/src/tint/resolver/source_variable_test.cc
@@ -81,7 +81,7 @@
}
TEST_F(ResolverSourceVariableTest, GlobalOverride) {
- auto* a = Override("a", ty.f32(), Expr(1.f));
+ auto* a = Override("a", ty.f32(), Expr(1_f));
auto* expr = Expr(a);
WrapInFunction(expr);
@@ -92,7 +92,7 @@
}
TEST_F(ResolverSourceVariableTest, GlobalConst) {
- auto* a = GlobalConst("a", ty.f32(), Expr(1.f));
+ auto* a = GlobalConst("a", ty.f32(), Expr(1_f));
auto* expr = Expr(a);
WrapInFunction(expr);
@@ -114,7 +114,7 @@
}
TEST_F(ResolverSourceVariableTest, FunctionLet) {
- auto* a = Let("a", ty.f32(), Expr(1.f));
+ auto* a = Let("a", ty.f32(), Expr(1_f));
auto* expr = Expr(a);
WrapInFunction(a, expr);
@@ -250,7 +250,7 @@
}
TEST_F(ResolverSourceVariableTest, Literal) {
- auto* expr = Expr(1.f);
+ auto* expr = Expr(1_f);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -259,7 +259,7 @@
}
TEST_F(ResolverSourceVariableTest, FunctionReturnValue) {
- auto* expr = Call("min", 1.f, 2.f);
+ auto* expr = Call("min", 1_f, 2_f);
WrapInFunction(expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@@ -269,7 +269,7 @@
TEST_F(ResolverSourceVariableTest, BinaryExpression) {
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone);
- auto* expr = Add(a, Expr(1.f));
+ auto* expr = Add(a, Expr(1_f));
WrapInFunction(a, expr);
EXPECT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/struct_pipeline_stage_use_test.cc b/src/tint/resolver/struct_pipeline_stage_use_test.cc
index 6b9ede9..1ca80df 100644
--- a/src/tint/resolver/struct_pipeline_stage_use_test.cc
+++ b/src/tint/resolver/struct_pipeline_stage_use_test.cc
@@ -53,7 +53,7 @@
TEST_F(ResolverPipelineStageUseTest, StructUsedAsNonEntryPointReturnType) {
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
- Func("foo", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0.f)))}, {});
+ Func("foo", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0_f)))}, {});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -106,7 +106,7 @@
TEST_F(ResolverPipelineStageUseTest, StructUsedAsFragmentShaderReturnType) {
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
- Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0.f)))},
+ Func("main", {}, ty.Of(s), {Return(Construct(ty.Of(s), Expr(0_f)))},
{Stage(ast::PipelineStage::kFragment)});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -169,7 +169,7 @@
auto* s = Structure("S", {Member("a", ty.f32(), {Location(0)})});
auto* s_alias = Alias("S_alias", ty.Of(s));
- Func("main", {}, ty.Of(s_alias), {Return(Construct(ty.Of(s_alias), Expr(0.f)))},
+ Func("main", {}, ty.Of(s_alias), {Return(Construct(ty.Of(s_alias), Expr(0_f)))},
{Stage(ast::PipelineStage::kFragment)});
ASSERT_TRUE(r()->Resolve()) << r()->error();
diff --git a/src/tint/resolver/type_constructor_validation_test.cc b/src/tint/resolver/type_constructor_validation_test.cc
index edfce46..4c37ee5 100644
--- a/src/tint/resolver/type_constructor_validation_test.cc
+++ b/src/tint/resolver/type_constructor_validation_test.cc
@@ -404,7 +404,7 @@
TEST_F(ResolverTypeConstructorValidationTest, ConversionConstructorInvalid_TooManyInitializers) {
auto* a = Var("a", ty.f32(), ast::StorageClass::kNone,
- Construct(Source{{12, 34}}, ty.f32(), Expr(1.0f), Expr(2.0f)));
+ Construct(Source{{12, 34}}, ty.f32(), Expr(1_f), Expr(2_f)));
WrapInFunction(a);
ASSERT_FALSE(r()->Resolve());
@@ -463,7 +463,7 @@
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_type_Mismatch_U32F32) {
// array<u32, 3u>(0u, 1.0f, 20u);
- auto* tc = array<u32, 3>(Expr(0_u), Expr(Source{{12, 34}}, 1.0f), Expr(20_u));
+ auto* tc = array<u32, 3>(Expr(0_u), Expr(Source{{12, 34}}, 1_f), Expr(20_u));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -650,7 +650,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Construct_f32_Success) {
- auto* expr = Construct<f32>(Expr(1.23f));
+ auto* expr = Construct<f32>(Expr(1.23_f));
WrapInFunction(expr);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -668,7 +668,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Convert_f32_to_i32_Success) {
- auto* expr = Construct<i32>(1.23f);
+ auto* expr = Construct<i32>(1.23_f);
WrapInFunction(expr);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -727,7 +727,7 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec2F32_Error_ScalarArgumentTypeMismatch) {
- auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_i), 1.0f);
+ auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_i), 1_f);
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -788,8 +788,8 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2_Error_TooManyArgumentsScalar) {
- auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f));
+ auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -807,7 +807,7 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec2_Error_TooManyArgumentsVectorAndScalar) {
- auto* tc = vec2<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f));
+ auto* tc = vec2<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -844,7 +844,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec2F32_Success_Scalar) {
- auto* tc = vec2<f32>(1.0f, 1.0f);
+ auto* tc = vec2<f32>(1_f, 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -969,7 +969,7 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec3F32_Error_ScalarArgumentTypeMismatch) {
- auto* tc = vec3<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1_i));
+ auto* tc = vec3<f32>(1_f, 1_f, Expr(Source{{12, 34}}, 1_i));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1021,7 +1021,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooFewArgumentsScalar) {
- auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f));
+ auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1029,8 +1029,8 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooManyArgumentsScalar) {
- auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f), Expr(Source{{12, 52}}, 1.0f));
+ auto* tc = vec3<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f), Expr(Source{{12, 52}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1056,8 +1056,8 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec3_Error_TooManyArgumentsVec2AndScalar) {
- auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f));
+ auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1065,7 +1065,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Error_TooManyArgumentsVec3) {
- auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1.0f));
+ auto* tc = vec3<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1102,7 +1102,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3F32_Success_Scalar) {
- auto* tc = vec3<f32>(1.0f, 1.0f, 1.0f);
+ auto* tc = vec3<f32>(1_f, 1_f, 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1190,7 +1190,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_Vec2AndScalar) {
- auto* tc = vec3<f32>(vec2<f32>(), 1.0f);
+ auto* tc = vec3<f32>(vec2<f32>(), 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1211,7 +1211,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec3_Success_ScalarAndVec2) {
- auto* tc = vec3<f32>(1.0f, vec2<f32>());
+ auto* tc = vec3<f32>(1_f, vec2<f32>());
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1273,7 +1273,7 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec4F32_Error_ScalarArgumentTypeMismatch) {
- auto* tc = vec4<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1_i), 1.0f);
+ auto* tc = vec4<f32>(1_f, 1_f, Expr(Source{{12, 34}}, 1_i), 1_f);
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1316,8 +1316,8 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooFewArgumentsScalar) {
- auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f));
+ auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1325,9 +1325,9 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Error_TooManyArgumentsScalar) {
- auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f), Expr(Source{{12, 52}}, 1.0f),
- Expr(Source{{12, 58}}, 1.0f));
+ auto* tc = vec4<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f), Expr(Source{{12, 52}}, 1_f),
+ Expr(Source{{12, 58}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1336,7 +1336,7 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec4_Error_TooFewArgumentsVec2AndScalar) {
- auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f));
+ auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1345,8 +1345,8 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2AndScalars) {
- auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f), Expr(Source{{12, 52}}, 1.0f));
+ auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f), Expr(Source{{12, 52}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1356,7 +1356,7 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2Vec2Scalar) {
auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec2<f32>()),
- Construct(Source{{12, 40}}, ty.vec2<f32>()), Expr(Source{{12, 46}}, 1.0f));
+ Construct(Source{{12, 40}}, ty.vec2<f32>()), Expr(Source{{12, 46}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1384,8 +1384,8 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_Vec4_Error_TooManyArgumentsVec3AndScalars) {
- auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1.0f),
- Expr(Source{{12, 46}}, 1.0f));
+ auto* tc = vec4<f32>(Construct(Source{{12, 34}}, ty.vec3<f32>()), Expr(Source{{12, 40}}, 1_f),
+ Expr(Source{{12, 46}}, 1_f));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1445,7 +1445,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4F32_Success_Scalar) {
- auto* tc = vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f);
+ auto* tc = vec4<f32>(1_f, 1_f, 1_f, 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1493,7 +1493,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec2ScalarScalar) {
- auto* tc = vec4<f32>(vec2<f32>(), 1.0f, 1.0f);
+ auto* tc = vec4<f32>(vec2<f32>(), 1_f, 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1505,7 +1505,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarVec2Scalar) {
- auto* tc = vec4<f32>(1.0f, vec2<f32>(), 1.0f);
+ auto* tc = vec4<f32>(1_f, vec2<f32>(), 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1517,7 +1517,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarScalarVec2) {
- auto* tc = vec4<f32>(1.0f, 1.0f, vec2<f32>());
+ auto* tc = vec4<f32>(1_f, 1_f, vec2<f32>());
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1541,7 +1541,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_Vec3AndScalar) {
- auto* tc = vec4<f32>(vec3<f32>(), 1.0f);
+ auto* tc = vec4<f32>(vec3<f32>(), 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1553,7 +1553,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vec4_Success_ScalarAndVec3) {
- auto* tc = vec4<f32>(1.0f, vec3<f32>());
+ auto* tc = vec4<f32>(1_f, vec3<f32>());
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1590,10 +1590,9 @@
TEST_F(ResolverTypeConstructorValidationTest,
Expr_Constructor_NestedVectorConstructors_InnerError) {
- auto* tc =
- vec4<f32>(vec4<f32>(1.0f, 1.0f,
- vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 34}}, 1.0f))),
- 1.0f);
+ auto* tc = vec4<f32>(
+ vec4<f32>(1_f, 1_f, vec3<f32>(Expr(Source{{12, 34}}, 1_f), Expr(Source{{12, 34}}, 1_f))),
+ 1_f);
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1601,7 +1600,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_NestedVectorConstructors_Success) {
- auto* tc = vec4<f32>(vec3<f32>(vec2<f32>(1.0f, 1.0f), 1.0f), 1.0f);
+ auto* tc = vec4<f32>(vec3<f32>(vec2<f32>(1_f, 1_f), 1_f), 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1641,7 +1640,7 @@
// vec2<Float32>(1.0f, 1u)
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
- auto* tc = Construct(Source{{12, 34}}, vec_type, 1.0f, Expr(Source{{12, 40}}, 1_u));
+ auto* tc = Construct(Source{{12, 34}}, vec_type, 1_f, Expr(Source{{12, 40}}, 1_u));
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1655,7 +1654,7 @@
// vec2<Float32>(1.0f, 1.0f)
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
- auto* tc = Construct(Source{{12, 34}}, vec_type, 1.0f, 1.0f);
+ auto* tc = Construct(Source{{12, 34}}, vec_type, 1_f, 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1667,7 +1666,7 @@
// vec3<u32>(vec<Float32>(), 1.0f)
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
- auto* tc = vec3<u32>(Construct(Source{{12, 34}}, vec_type), 1.0f);
+ auto* tc = vec3<u32>(Construct(Source{{12, 34}}, vec_type), 1_f);
WrapInFunction(tc);
EXPECT_FALSE(r()->Resolve());
@@ -1682,7 +1681,7 @@
// vec3<f32>(vec<Float32>(), 1.0f)
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
- auto* tc = vec3<f32>(Construct(Source{{12, 34}}, vec_type), 1.0f);
+ auto* tc = vec3<f32>(Construct(Source{{12, 34}}, vec_type), 1_f);
WrapInFunction(tc);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1692,7 +1691,7 @@
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), Expr(true), Expr(false));
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_i), Expr(2_i));
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_u), Expr(2_u));
- auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1.0f), Expr(2.0f));
+ auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), Expr(1_f), Expr(2_f));
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1719,7 +1718,7 @@
auto* vec2_bool = Construct(create<ast::Vector>(nullptr, 2), vec2<bool>(true, false));
auto* vec2_i32 = Construct(create<ast::Vector>(nullptr, 2), vec2<i32>(1_i, 2_i));
auto* vec2_u32 = Construct(create<ast::Vector>(nullptr, 2), vec2<u32>(1_u, 2_u));
- auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1.0f, 2.0f));
+ auto* vec2_f32 = Construct(create<ast::Vector>(nullptr, 2), vec2<f32>(1_f, 2_f));
WrapInFunction(vec2_bool, vec2_i32, vec2_u32, vec2_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1747,7 +1746,7 @@
Construct(create<ast::Vector>(nullptr, 3), Expr(true), Expr(false), Expr(true));
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), Expr(2_i), Expr(3_i));
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), Expr(2_u), Expr(3_u));
- auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1.0f), Expr(2.0f), Expr(3.0f));
+ auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_f), Expr(2_f), Expr(3_f));
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1774,7 +1773,7 @@
auto* vec3_bool = Construct(create<ast::Vector>(nullptr, 3), vec3<bool>(true, false, true));
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), vec3<i32>(1_i, 2_i, 3_i));
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), vec3<u32>(1_u, 2_u, 3_u));
- auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), vec3<f32>(1.0f, 2.0f, 3.0f));
+ auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), vec3<f32>(1_f, 2_f, 3_f));
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1802,7 +1801,7 @@
Construct(create<ast::Vector>(nullptr, 3), Expr(true), vec2<bool>(false, true));
auto* vec3_i32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_i), vec2<i32>(2_i, 3_i));
auto* vec3_u32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_u), vec2<u32>(2_u, 3_u));
- auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1.0f), vec2<f32>(2.0f, 3.0f));
+ auto* vec3_f32 = Construct(create<ast::Vector>(nullptr, 3), Expr(1_f), vec2<f32>(2_f, 3_f));
WrapInFunction(vec3_bool, vec3_i32, vec3_u32, vec3_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1833,7 +1832,7 @@
auto* vec4_u32 =
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), Expr(2_u), Expr(3_u), Expr(4_u));
auto* vec4_f32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1.0f), Expr(2.0f), Expr(3.0f), Expr(4.0f));
+ Construct(create<ast::Vector>(nullptr, 4), Expr(1_f), Expr(2_f), Expr(3_f), Expr(4_f));
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1861,7 +1860,7 @@
Construct(create<ast::Vector>(nullptr, 4), vec4<bool>(true, false, true, false));
auto* vec4_i32 = Construct(create<ast::Vector>(nullptr, 4), vec4<i32>(1_i, 2_i, 3_i, 4_i));
auto* vec4_u32 = Construct(create<ast::Vector>(nullptr, 4), vec4<u32>(1_u, 2_u, 3_u, 4_u));
- auto* vec4_f32 = Construct(create<ast::Vector>(nullptr, 4), vec4<f32>(1.0f, 2.0f, 3.0f, 4.0f));
+ auto* vec4_f32 = Construct(create<ast::Vector>(nullptr, 4), vec4<f32>(1_f, 2_f, 3_f, 4_f));
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1892,7 +1891,7 @@
auto* vec4_u32 =
Construct(create<ast::Vector>(nullptr, 4), Expr(1_u), vec3<u32>(2_u, 3_u, 4_u));
auto* vec4_f32 =
- Construct(create<ast::Vector>(nullptr, 4), Expr(1.0f), vec3<f32>(2.0f, 3.0f, 4.0f));
+ Construct(create<ast::Vector>(nullptr, 4), Expr(1_f), vec3<f32>(2_f, 3_f, 4_f));
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1923,7 +1922,7 @@
auto* vec4_u32 =
Construct(create<ast::Vector>(nullptr, 4), vec2<u32>(1_u, 2_u), vec2<u32>(3_u, 4_u));
auto* vec4_f32 =
- Construct(create<ast::Vector>(nullptr, 4), vec2<f32>(1.0f, 2.0f), vec2<f32>(3.0f, 4.0f));
+ Construct(create<ast::Vector>(nullptr, 4), vec2<f32>(1_f, 2_f), vec2<f32>(3_f, 4_f));
WrapInFunction(vec4_bool, vec4_i32, vec4_u32, vec4_f32);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@@ -1984,7 +1983,7 @@
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec3ElementTypeFromScalarAndVec2Mismatch) {
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 3),
Expr(Source{{1, 2}}, 1_i), //
- Construct(Source{{1, 3}}, ty.vec2<f32>(), 2.0f, 3.0f)));
+ Construct(Source{{1, 3}}, ty.vec2<f32>(), 2_f, 3_f)));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(
@@ -1996,9 +1995,9 @@
TEST_F(ResolverTypeConstructorValidationTest, CannotInferVec4ElementTypeFromScalarsMismatch) {
WrapInFunction(Construct(Source{{1, 1}}, create<ast::Vector>(nullptr, 4),
- Expr(Source{{1, 2}}, 1_i), //
- Expr(Source{{1, 3}}, 2_i), //
- Expr(Source{{1, 4}}, 3.0f), //
+ Expr(Source{{1, 2}}, 1_i), //
+ Expr(Source{{1, 3}}, 2_i), //
+ Expr(Source{{1, 4}}, 3_f), //
Expr(Source{{1, 5}}, 4_i)));
EXPECT_FALSE(r()->Resolve());
@@ -2720,7 +2719,7 @@
}
TEST_F(ResolverTypeConstructorValidationTest, TypeConstructorAsStatement) {
- WrapInFunction(CallStmt(Construct(Source{{12, 34}}, ty.vec2<f32>(), 1.f, 2.f)));
+ WrapInFunction(CallStmt(Construct(Source{{12, 34}}, ty.vec2<f32>(), 1_f, 2_f)));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: type constructor evaluated but not used");
diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc
index 7fcf004..90e18e1 100644
--- a/src/tint/resolver/type_validation_test.cc
+++ b/src/tint/resolver/type_validation_test.cc
@@ -91,7 +91,7 @@
// const<private> global_var: f32;
AST().AddGlobalVariable(create<ast::Variable>(
Source{{12, 34}}, Symbols().Register("global_var"), ast::StorageClass::kPrivate,
- ast::Access::kUndefined, ty.f32(), true, false, Expr(1.23f), ast::AttributeList{}));
+ ast::Access::kUndefined, ty.f32(), true, false, Expr(1.23_f), ast::AttributeList{}));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: global constants shouldn't have a storage class");
@@ -108,9 +108,9 @@
// var global_var0 : f32 = 0.1;
// var global_var1 : i32 = 0;
- Global("global_var0", ty.f32(), ast::StorageClass::kPrivate, Expr(0.1f));
+ Global("global_var0", ty.f32(), ast::StorageClass::kPrivate, Expr(0.1_f));
- Global(Source{{12, 34}}, "global_var1", ty.f32(), ast::StorageClass::kPrivate, Expr(1.0f));
+ Global(Source{{12, 34}}, "global_var1", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@@ -121,11 +121,11 @@
// }
// var a: f32 = 2.1;
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
Func("my_func", ast::VariableList{}, ty.void_(), {Decl(var)});
- Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
+ Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@@ -135,12 +135,12 @@
// if (true) { var a : f32 = 2.0; }
// var a : f32 = 3.14;
// }
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* cond = Expr(true);
auto* body = Block(Decl(var));
- auto* var_a_float = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(3.1f));
+ auto* var_a_float = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(3.1_f));
auto* outer_body = Block(If(cond, body), Decl(Source{{12, 34}}, var_a_float));
@@ -168,9 +168,9 @@
TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass) {
// func0 { var a : f32 = 2.0; return; }
// func1 { var a : f32 = 3.0; return; }
- auto* var0 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var0 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
- auto* var1 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1.0f));
+ auto* var1 = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
Func("func0", ast::VariableList{}, ty.void_(),
ast::StatementList{
@@ -266,7 +266,7 @@
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
// var<private> a : array<f32, 10.0>;
- Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10.f)), ast::StorageClass::kPrivate);
+ Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
}
@@ -282,7 +282,7 @@
TEST_F(ResolverTypeValidationTest, ArraySize_FloatConstant) {
// let size = 10.0;
// var<private> a : array<f32, size>;
- GlobalConst("size", nullptr, Expr(10.f));
+ GlobalConst("size", nullptr, Expr(10_f));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: array size must be integer scalar");
diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc
index 65d73c4..9270065 100644
--- a/src/tint/resolver/validation_test.cc
+++ b/src/tint/resolver/validation_test.cc
@@ -116,7 +116,7 @@
TEST_F(ResolverValidationTest, Stmt_If_NonBool) {
// if (1.23f) {}
- WrapInFunction(If(Expr(Source{{12, 34}}, 1.23f), Block()));
+ WrapInFunction(If(Expr(Source{{12, 34}}, 1.23_f), Block()));
EXPECT_FALSE(r()->Resolve());
@@ -126,7 +126,7 @@
TEST_F(ResolverValidationTest, Stmt_ElseIf_NonBool) {
// else if (1.23f) {}
- WrapInFunction(If(Expr(true), Block(), Else(If(Expr(Source{{12, 34}}, 1.23f), Block()))));
+ WrapInFunction(If(Expr(true), Block(), Else(If(Expr(Source{{12, 34}}, 1.23_f), Block()))));
EXPECT_FALSE(r()->Resolve());
@@ -213,11 +213,11 @@
// return;
// }
- Global("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
+ Global("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
Func("my_func", ast::VariableList{}, ty.void_(),
{
- Assign(Expr(Source{{12, 34}}, "global_var"), 3.14f),
+ Assign(Expr(Source{{12, 34}}, "global_var"), 3.14_f),
Return(),
});
@@ -229,14 +229,14 @@
// if (true) { var a : f32 = 2.0; }
// a = 3.14;
// }
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* cond = Expr(true);
auto* body = Block(Decl(var));
SetSource(Source{{12, 34}});
auto* lhs = Expr(Source{{12, 34}}, "a");
- auto* rhs = Expr(3.14f);
+ auto* rhs = Expr(3.14_f);
auto* outer_body = Block(If(cond, body), Assign(lhs, rhs));
@@ -251,10 +251,10 @@
// var a : f32 = 2.0;
// if (true) { a = 3.14; }
// }
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* lhs = Expr(Source{{12, 34}}, "a");
- auto* rhs = Expr(3.14f);
+ auto* rhs = Expr(3.14_f);
auto* cond = Expr(true);
auto* body = Block(Assign(lhs, rhs));
@@ -271,11 +271,11 @@
// { var a : f32 = 2.0; }
// { a = 3.14; }
// }
- auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var = Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* first_body = Block(Decl(var));
auto* lhs = Expr(Source{{12, 34}}, "a");
- auto* rhs = Expr(3.14f);
+ auto* rhs = Expr(3.14_f);
auto* second_body = Block(Assign(lhs, rhs));
auto* outer_body = Block(first_body, second_body);
@@ -966,7 +966,7 @@
// for (; 1.0f; ) {
// }
- WrapInFunction(For(nullptr, Expr(Source{{12, 34}}, 1.0f), nullptr, Block()));
+ WrapInFunction(For(nullptr, Expr(Source{{12, 34}}, 1_f), nullptr, Block()));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: for-loop condition must be bool, got f32");
diff --git a/src/tint/resolver/var_let_test.cc b/src/tint/resolver/var_let_test.cc
index a59855a..4c62bdd 100644
--- a/src/tint/resolver/var_let_test.cc
+++ b/src/tint/resolver/var_let_test.cc
@@ -99,7 +99,7 @@
auto* i_c = Expr(1_i);
auto* u_c = Expr(1_u);
- auto* f_c = Expr(1.f);
+ auto* f_c = Expr(1_f);
auto* b_c = Expr(true);
auto* s_c = Construct(ty.Of(S), Expr(1_i));
auto* a_c = Construct(ty.Of(A), Expr(1_i));
@@ -165,7 +165,7 @@
auto* i_c = Expr(1_i);
auto* u_c = Expr(1_u);
- auto* f_c = Expr(1.f);
+ auto* f_c = Expr(1_f);
auto* b_c = Expr(true);
auto* s_c = Construct(ty.Of(S), Expr(1_i));
auto* a_c = Construct(ty.Of(A), Expr(1_i));
diff --git a/src/tint/resolver/var_let_validation_test.cc b/src/tint/resolver/var_let_validation_test.cc
index 99cb802..e1dc343 100644
--- a/src/tint/resolver/var_let_validation_test.cc
+++ b/src/tint/resolver/var_let_validation_test.cc
@@ -140,7 +140,7 @@
TEST_F(ResolverVarLetValidationTest, LocalLetRedeclared) {
// let l : f32 = 1.;
// let l : i32 = 0;
- auto* l1 = Let("l", ty.f32(), Expr(1.f));
+ auto* l1 = Let("l", ty.f32(), Expr(1_f));
auto* l2 = Let(Source{{12, 34}}, "l", ty.i32(), Expr(0_i));
WrapInFunction(l1, l2);
@@ -156,9 +156,9 @@
// return 0;
// }
- Global("v", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1f));
+ Global("v", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
- WrapInFunction(Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2.0f)));
+ WrapInFunction(Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2_f)));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@@ -183,9 +183,9 @@
// var v : f32 = 3.14;
// if (true) { var v : f32 = 2.0; }
// }
- auto* var_a_float = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(3.1f));
+ auto* var_a_float = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(3.1_f));
- auto* var = Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2.0f));
+ auto* var = Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2_f));
auto* cond = Expr(true);
auto* body = Block(Decl(var));
@@ -274,7 +274,7 @@
TEST_F(ResolverVarLetValidationTest, InvalidStorageClassForInitializer) {
// var<workgroup> v : f32 = 1.23;
- Global(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23f));
+ Global(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23_f));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
diff --git a/src/tint/transform/canonicalize_entry_point_io.cc b/src/tint/transform/canonicalize_entry_point_io.cc
index aeafa1b..44d577b 100644
--- a/src/tint/transform/canonicalize_entry_point_io.cc
+++ b/src/tint/transform/canonicalize_entry_point_io.cc
@@ -374,7 +374,7 @@
void AddVertexPointSize() {
// Create a new output value and assign it a literal 1.0 value.
AddOutput("vertex_point_size", ctx.dst->create<sem::F32>(),
- {ctx.dst->Builtin(ast::Builtin::kPointSize)}, ctx.dst->Expr(1.f));
+ {ctx.dst->Builtin(ast::Builtin::kPointSize)}, ctx.dst->Expr(1_f));
}
/// Create an expression for gl_Position.[component]
@@ -580,7 +580,7 @@
ctx.dst->create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, GLPosition("y"));
wrapper_body.push_back(ctx.dst->Assign(pos_y, negate_pos_y));
- auto* two_z = ctx.dst->Mul(ctx.dst->Expr(2.0f), GLPosition("z"));
+ auto* two_z = ctx.dst->Mul(ctx.dst->Expr(2_f), GLPosition("z"));
auto* fixed_z = ctx.dst->Sub(two_z, GLPosition("w"));
wrapper_body.push_back(ctx.dst->Assign(GLPosition("z"), fixed_z));
}
diff --git a/src/tint/transform/decompose_strided_array_test.cc b/src/tint/transform/decompose_strided_array_test.cc
index cd9d63c..53b335e 100644
--- a/src/tint/transform/decompose_strided_array_test.cc
+++ b/src/tint/transform/decompose_strided_array_test.cc
@@ -350,8 +350,8 @@
{
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(32))),
b.Assign(b.MemberAccessor("s", "a"),
- b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
- b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
+ b.Construct(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
+ b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -404,8 +404,8 @@
{
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(4))),
b.Assign(b.MemberAccessor("s", "a"),
- b.Construct(b.ty.array<f32, 4u>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
- b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
+ b.Construct(b.ty.array<f32, 4u>(4), 1_f, 2_f, 3_f, 4_f)),
+ b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -458,8 +458,8 @@
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
b.Decl(b.Let("c", nullptr, b.Deref("b"))),
b.Decl(b.Let("d", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
- b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
- b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5.0f),
+ b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
+ b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -519,8 +519,8 @@
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR"))),
b.Assign(b.MemberAccessor("s", "a"),
- b.Construct(b.ty.type_name("ARR"), 1.0f, 2.0f, 3.0f, 4.0f)),
- b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
+ b.Construct(b.ty.type_name("ARR"), 1_f, 2_f, 3_f, 4_f)),
+ b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -612,7 +612,7 @@
3_i),
2_i),
1_i),
- 5.0f),
+ 5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),
diff --git a/src/tint/transform/decompose_strided_matrix_test.cc b/src/tint/transform/decompose_strided_matrix_test.cc
index 23b30d5..803ae73 100644
--- a/src/tint/transform/decompose_strided_matrix_test.cc
+++ b/src/tint/transform/decompose_strided_matrix_test.cc
@@ -354,7 +354,7 @@
b.Func("f", {}, b.ty.void_(),
{
b.Assign(b.MemberAccessor("s", "m"),
- b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
+ b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -411,7 +411,7 @@
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
- b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1.0f, 2.0f)),
+ b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1_f, 2_f)),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -468,21 +468,20 @@
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
- b.Func(
- "f", {}, b.ty.void_(),
- {
- b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
- b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
- b.Decl(b.Let("x", nullptr, b.Deref("b"))),
- b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
- b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
- b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
- b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5.0f, 6.0f)),
- },
- {
- b.Stage(ast::PipelineStage::kCompute),
- b.WorkgroupSize(1_i),
- });
+ b.Func("f", {}, b.ty.void_(),
+ {
+ b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
+ b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
+ b.Decl(b.Let("x", nullptr, b.Deref("b"))),
+ b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
+ b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
+ b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
+ b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5_f, 6_f)),
+ },
+ {
+ b.Stage(ast::PipelineStage::kCompute),
+ b.WorkgroupSize(1_i),
+ });
auto* expect = R"(
struct S {
@@ -595,7 +594,7 @@
b.Func("f", {}, b.ty.void_(),
{
b.Assign(b.MemberAccessor("s", "m"),
- b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
+ b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
},
{
b.Stage(ast::PipelineStage::kCompute),
diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc
index 47cc9ce..0bc507e 100644
--- a/src/tint/transform/multiplanar_external_texture.cc
+++ b/src/tint/transform/multiplanar_external_texture.cc
@@ -304,11 +304,11 @@
const ast::CallExpression* plane_1_call = nullptr;
if (call_type == sem::BuiltinType::kTextureSampleLevel) {
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
- single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0.0f);
+ single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
- plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0.0f);
+ plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
// textureSampleLevel(plane1, smp, coord.xy, 0.0);
- plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0.0f);
+ plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0_f);
} else if (call_type == sem::BuiltinType::kTextureLoad) {
// textureLoad(plane0, coords.xy, 0);
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
@@ -334,7 +334,7 @@
// params.yuvToRgbConversionMatrix;
b.Assign("color",
b.Mul(b.vec4<f32>(b.MemberAccessor(plane_0_call, "r"),
- b.MemberAccessor(plane_1_call, "rg"), 1.0f),
+ b.MemberAccessor(plane_1_call, "rg"), 1_f),
b.MemberAccessor("params", "yuvToRgbConversionMatrix")))))),
// color = gammaConversion(color, gammaDecodeParams);
b.Assign("color", b.Call("gammaCorrection", "color",
@@ -344,8 +344,8 @@
// color = gammaConversion(color, gammaEncodeParams);
b.Assign("color", b.Call("gammaCorrection", "color",
b.MemberAccessor("params", "gammaEncodeParams"))),
- // return vec4<f32>(color, 1.0f);
- b.Return(b.vec4<f32>("color", 1.0f))};
+ // return vec4<f32>(color, 1.f);
+ b.Return(b.vec4<f32>("color", 1_f))};
}
/// Creates the textureSampleExternal function if needed and returns a call
diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc
index 6d315f5..e297c90 100644
--- a/src/tint/transform/vertex_pulling.cc
+++ b/src/tint/transform/vertex_pulling.cc
@@ -361,19 +361,19 @@
case BaseType::kI32:
ty = ctx.dst->ty.i32();
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
- values.emplace_back(ctx.dst->Expr(i32((i == 3) ? 1 : 0)));
+ values.emplace_back(ctx.dst->Expr((i == 3) ? 1_i : 0_i));
}
break;
case BaseType::kU32:
ty = ctx.dst->ty.u32();
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
- values.emplace_back(ctx.dst->Expr(u32((i == 3) ? 1u : 0u)));
+ values.emplace_back(ctx.dst->Expr((i == 3) ? 1_u : 0_u));
}
break;
case BaseType::kF32:
ty = ctx.dst->ty.f32();
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
- values.emplace_back(ctx.dst->Expr((i == 3) ? 1.f : 0.f));
+ values.emplace_back(ctx.dst->Expr((i == 3) ? 1_f : 0_f));
}
break;
default:
diff --git a/src/tint/writer/append_vector.cc b/src/tint/writer/append_vector.cc
index d3d11c1..bc89d1f 100644
--- a/src/tint/writer/append_vector.cc
+++ b/src/tint/writer/append_vector.cc
@@ -51,7 +51,7 @@
} else if (ty->Is<sem::U32>()) {
expr = b.Expr(0_u);
} else if (ty->Is<sem::F32>()) {
- expr = b.Expr(0.0f);
+ expr = b.Expr(0_f);
} else if (ty->Is<sem::Bool>()) {
expr = b.Expr(false);
} else {
diff --git a/src/tint/writer/append_vector_test.cc b/src/tint/writer/append_vector_test.cc
index 5a9551e..46a135f 100644
--- a/src/tint/writer/append_vector_test.cc
+++ b/src/tint/writer/append_vector_test.cc
@@ -164,7 +164,7 @@
TEST_F(AppendVectorTest, Vec2i32_f32) {
auto* scalar_1 = Expr(1_i);
auto* scalar_2 = Expr(2_i);
- auto* scalar_3 = Expr(3.0f);
+ auto* scalar_3 = Expr(3_f);
auto* vec_12 = vec2<i32>(scalar_1, scalar_2);
WrapInFunction(vec_12, scalar_3);
diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc
index dd11c72..f52862b 100644
--- a/src/tint/writer/glsl/generator_impl.cc
+++ b/src/tint/writer/glsl/generator_impl.cc
@@ -72,6 +72,8 @@
#include "src/tint/writer/float_to_string.h"
#include "src/tint/writer/generate_external_texture_bindings.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace {
bool IsRelational(tint::ast::BinaryOp op) {
@@ -1296,7 +1298,7 @@
}
const ast::Expression* GeneratorImpl::CreateF32Zero(const sem::Statement* stmt) {
- auto* zero = builder_.Expr(0.0f);
+ auto* zero = builder_.Expr(0_f);
auto* f32 = builder_.create<sem::F32>();
auto* sem_zero = builder_.create<sem::Expression>(zero, f32, stmt, sem::Constant{},
/* has_side_effects */ false);
diff --git a/src/tint/writer/glsl/generator_impl_binary_test.cc b/src/tint/writer/glsl/generator_impl_binary_test.cc
index 970a2b3..07456d9 100644
--- a/src/tint/writer/glsl/generator_impl_binary_test.cc
+++ b/src/tint/writer/glsl/generator_impl_binary_test.cc
@@ -123,8 +123,8 @@
BinaryData{"(left % right)", ast::BinaryOp::kModulo}));
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
- auto* rhs = Expr(1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
+ auto* rhs = Expr(1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -140,8 +140,8 @@
}
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
- auto* lhs = Expr(1.f);
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = Expr(1_f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -159,7 +159,7 @@
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
- auto* rhs = Expr(1.f);
+ auto* rhs = Expr(1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
@@ -173,7 +173,7 @@
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
- auto* lhs = Expr(1.f);
+ auto* lhs = Expr(1_f);
auto* rhs = Expr("mat");
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -189,7 +189,7 @@
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
@@ -203,7 +203,7 @@
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
auto* rhs = Expr("mat");
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
diff --git a/src/tint/writer/glsl/generator_impl_builtin_test.cc b/src/tint/writer/glsl/generator_impl_builtin_test.cc
index 311abd9..1d80e6a 100644
--- a/src/tint/writer/glsl/generator_impl_builtin_test.cc
+++ b/src/tint/writer/glsl/generator_impl_builtin_test.cc
@@ -258,7 +258,7 @@
}
TEST_F(GlslGeneratorImplTest_Builtin, Select_Scalar) {
- auto* call = Call("select", 1.0f, 2.0f, true);
+ auto* call = Call("select", 1_f, 2_f, true);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@@ -280,7 +280,7 @@
}
TEST_F(GlslGeneratorImplTest_Builtin, Modf_Scalar) {
- auto* call = Call("modf", 1.0f);
+ auto* call = Call("modf", 1_f);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = SanitizeAndBuild();
@@ -346,7 +346,7 @@
}
TEST_F(GlslGeneratorImplTest_Builtin, Frexp_Scalar_i32) {
- auto* call = Call("frexp", 1.0f);
+ auto* call = Call("frexp", 1_f);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = SanitizeAndBuild();
diff --git a/src/tint/writer/glsl/generator_impl_call_test.cc b/src/tint/writer/glsl/generator_impl_call_test.cc
index 9b6a1c3..c8a1de2 100644
--- a/src/tint/writer/glsl/generator_impl_call_test.cc
+++ b/src/tint/writer/glsl/generator_impl_call_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/call_statement.h"
#include "src/tint/writer/glsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::glsl {
namespace {
using GlslGeneratorImplTest_Call = TestHelper;
TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
- Func("my_func", {}, ty.f32(), {Return(1.23f)});
+ Func("my_func", {}, ty.f32(), {Return(1.23_f)});
auto* call = Call("my_func");
WrapInFunction(call);
@@ -39,7 +41,7 @@
Param(Sym(), ty.f32()),
Param(Sym(), ty.f32()),
},
- ty.f32(), {Return(1.23f)});
+ ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
diff --git a/src/tint/writer/glsl/generator_impl_constructor_test.cc b/src/tint/writer/glsl/generator_impl_constructor_test.cc
index 41a7e61..4fa3c0a 100644
--- a/src/tint/writer/glsl/generator_impl_constructor_test.cc
+++ b/src/tint/writer/glsl/generator_impl_constructor_test.cc
@@ -62,7 +62,7 @@
}
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
- WrapInFunction(Construct<f32>(-1.2e-5f));
+ WrapInFunction(Construct<f32>(-1.2e-5_f));
GeneratorImpl& gen = Build();
@@ -98,7 +98,7 @@
}
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
- WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
+ WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
GeneratorImpl& gen = Build();
@@ -116,7 +116,7 @@
}
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float) {
- WrapInFunction(vec3<f32>(2.0f));
+ WrapInFunction(vec3<f32>(2_f));
GeneratorImpl& gen = Build();
@@ -152,7 +152,7 @@
}
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
- WrapInFunction(mat2x3<f32>(vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(3.f, 4.f, 5.f)));
+ WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
GeneratorImpl& gen = Build();
@@ -172,8 +172,8 @@
}
TEST_F(GlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
- WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.f, 2.f, 3.f),
- vec3<f32>(4.f, 5.f, 6.f), vec3<f32>(7.f, 8.f, 9.f)));
+ WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
+ vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
GeneratorImpl& gen = Build();
@@ -200,7 +200,7 @@
Member("c", ty.vec3<i32>()),
});
- WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
+ WrapInFunction(Construct(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
GeneratorImpl& gen = SanitizeAndBuild();
diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc
index 8b91cef..f352415 100644
--- a/src/tint/writer/glsl/generator_impl_function_test.cc
+++ b/src/tint/writer/glsl/generator_impl_function_test.cc
@@ -193,8 +193,8 @@
});
Func("vert_main", {}, ty.Of(interface_struct),
- {Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5f),
- Expr(0.25f)))},
+ {Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5_f),
+ Expr(0.25_f)))},
{Stage(ast::PipelineStage::kVertex)});
Func("frag_main", {Param("inputs", ty.Of(interface_struct))}, ty.void_(),
@@ -271,17 +271,17 @@
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
{Return(Construct(ty.Of(vertex_output_struct),
- Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1.f))))},
+ Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1_f))))},
{});
Func("vert_main1", {}, ty.Of(vertex_output_struct),
{Return(Construct(ty.Of(vertex_output_struct),
- Expr(Call("foo", Expr(0.5f)))))},
+ Expr(Call("foo", Expr(0.5_f)))))},
{Stage(ast::PipelineStage::kVertex)});
Func("vert_main2", {}, ty.Of(vertex_output_struct),
{Return(Construct(ty.Of(vertex_output_struct),
- Expr(Call("foo", Expr(0.25f)))))},
+ Expr(Call("foo", Expr(0.25_f)))))},
{Stage(ast::PipelineStage::kVertex)});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -336,7 +336,7 @@
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", {}, ty.void_(),
{
@@ -529,7 +529,7 @@
Func("frag_main", ast::VariableList{}, ty.void_(),
{
- Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
+ Assign(MemberAccessor("coord", "b"), Expr(2_f)),
Return(),
},
{
@@ -577,7 +577,7 @@
Func("frag_main", ast::VariableList{}, ty.void_(),
{
- Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
+ Assign(MemberAccessor("coord", "b"), Expr(2_f)),
Return(),
},
{
@@ -624,7 +624,7 @@
Return(MemberAccessor("coord", "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", ast::VariableList{}, ty.void_(),
{
@@ -673,7 +673,7 @@
Return(MemberAccessor("coord", "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", ast::VariableList{}, ty.void_(),
{
diff --git a/src/tint/writer/glsl/generator_impl_import_test.cc b/src/tint/writer/glsl/generator_impl_import_test.cc
index a4a6440..2843f98 100644
--- a/src/tint/writer/glsl/generator_impl_import_test.cc
+++ b/src/tint/writer/glsl/generator_impl_import_test.cc
@@ -35,7 +35,7 @@
auto param = GetParam();
auto* ident = Expr(param.name);
- auto* expr = Call(ident, 1.f);
+ auto* expr = Call(ident, 1_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -92,7 +92,7 @@
auto param = GetParam();
auto* ident = Expr(param.name);
- auto* expr = Call(ident, vec3<f32>(1.f, 2.f, 3.f));
+ auto* expr = Call(ident, vec3<f32>(1_f, 2_f, 3_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -132,7 +132,7 @@
TEST_P(GlslImportData_DualParam_ScalarTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.f, 2.f);
+ auto* expr = Call(param.name, 1_f, 2_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -154,7 +154,7 @@
TEST_P(GlslImportData_DualParam_VectorTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f));
+ auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -197,7 +197,7 @@
TEST_P(GlslImportData_TripleParam_ScalarTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.f, 2.f, 3.f);
+ auto* expr = Call(param.name, 1_f, 2_f, 3_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -216,8 +216,8 @@
TEST_P(GlslImportData_TripleParam_VectorTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f),
- vec3<f32>(7.f, 8.f, 9.f));
+ auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f),
+ vec3<f32>(7_f, 8_f, 9_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/glsl/generator_impl_loop_test.cc b/src/tint/writer/glsl/generator_impl_loop_test.cc
index de29622..5187daf 100644
--- a/src/tint/writer/glsl/generator_impl_loop_test.cc
+++ b/src/tint/writer/glsl/generator_impl_loop_test.cc
@@ -114,8 +114,8 @@
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
- auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
- Decl(Var("other", ty.f32())), //
+ auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
+ Decl(Var("other", ty.f32())), //
Break());
auto* continuing = Block(Assign("lhs", "rhs"));
auto* outer = Loop(body, continuing);
diff --git a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc
index 2fdc833..935df75 100644
--- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc
+++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc
@@ -739,7 +739,7 @@
SetupFunction({
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
- vec3<f32>(1.f, 2.f, 3.f)),
+ vec3<f32>(1_f, 2_f, 3_f)),
});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -797,7 +797,7 @@
SetupFunction({
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
"y"),
- Expr(1.f)),
+ Expr(1_f)),
});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -833,7 +833,7 @@
TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
auto* var =
- Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
+ Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
auto* expr = MemberAccessor("my_vec", "xyz");
WrapInFunction(var, expr);
@@ -844,7 +844,7 @@
TEST_F(GlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
auto* var =
- Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
+ Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
auto* expr = MemberAccessor("my_vec", "gbr");
WrapInFunction(var, expr);
diff --git a/src/tint/writer/glsl/generator_impl_module_constant_test.cc b/src/tint/writer/glsl/generator_impl_module_constant_test.cc
index 35e1dd2..223122a 100644
--- a/src/tint/writer/glsl/generator_impl_module_constant_test.cc
+++ b/src/tint/writer/glsl/generator_impl_module_constant_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/id_attribute.h"
#include "src/tint/writer/glsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::glsl {
namespace {
using GlslGeneratorImplTest_ModuleConstant = TestHelper;
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
- auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1.f, 2.f, 3.f));
+ auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
WrapInFunction(Decl(var));
GeneratorImpl& gen = Build();
@@ -31,7 +33,7 @@
}
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
- auto* var = Override("pos", ty.f32(), Expr(3.0f),
+ auto* var = Override("pos", ty.f32(), Expr(3_f),
ast::AttributeList{
Id(23),
});
@@ -63,11 +65,11 @@
}
TEST_F(GlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoId) {
- auto* a = Override("a", ty.f32(), Expr(3.0f),
+ auto* a = Override("a", ty.f32(), Expr(3_f),
ast::AttributeList{
Id(0),
});
- auto* b = Override("b", ty.f32(), Expr(2.0f));
+ auto* b = Override("b", ty.f32(), Expr(2_f));
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
index 874bfd0..6575c56 100644
--- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
+++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc
@@ -194,7 +194,7 @@
Member("b", ty.vec3<f32>()),
Member("c", ty.i32()),
});
- auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2.f, 3.f, 4.f), 4_i);
+ auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, 3_f, 4_f), 4_i);
auto* struct_access = MemberAccessor(struct_init, "b");
auto* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
diff --git a/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc b/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc
index a61cb17..faa675d 100644
--- a/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc
+++ b/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc
@@ -29,7 +29,7 @@
TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
- Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
+ Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1_i),
@@ -45,7 +45,7 @@
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
- Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
+ Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1_i),
diff --git a/src/tint/writer/hlsl/generator_impl_binary_test.cc b/src/tint/writer/hlsl/generator_impl_binary_test.cc
index 4d62885..446a5a8 100644
--- a/src/tint/writer/hlsl/generator_impl_binary_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_binary_test.cc
@@ -141,8 +141,8 @@
BinaryData::Types::Float}));
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorScalar) {
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
- auto* rhs = Expr(1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
+ auto* rhs = Expr(1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -158,8 +158,8 @@
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
- auto* lhs = Expr(1.f);
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = Expr(1_f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -177,7 +177,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
- auto* rhs = Expr(1.f);
+ auto* rhs = Expr(1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
@@ -191,7 +191,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
- auto* lhs = Expr(1.f);
+ auto* lhs = Expr(1_f);
auto* rhs = Expr("mat");
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -207,7 +207,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
WrapInFunction(expr);
@@ -221,7 +221,7 @@
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
auto* rhs = Expr("mat");
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc
index ada17f1..e4e6ba9 100644
--- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc
@@ -257,7 +257,7 @@
}
TEST_F(HlslGeneratorImplTest_Builtin, Select_Scalar) {
- auto* call = Call("select", 1.0f, 2.0f, true);
+ auto* call = Call("select", 1_f, 2_f, true);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@@ -279,7 +279,7 @@
}
TEST_F(HlslGeneratorImplTest_Builtin, Modf_Scalar) {
- auto* call = Call("modf", 1.0f);
+ auto* call = Call("modf", 1_f);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = SanitizeAndBuild();
@@ -331,7 +331,7 @@
}
TEST_F(HlslGeneratorImplTest_Builtin, Frexp_Scalar_i32) {
- auto* call = Call("frexp", 1.0f);
+ auto* call = Call("frexp", 1_f);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = SanitizeAndBuild();
diff --git a/src/tint/writer/hlsl/generator_impl_call_test.cc b/src/tint/writer/hlsl/generator_impl_call_test.cc
index e905e88..b72b0eb 100644
--- a/src/tint/writer/hlsl/generator_impl_call_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_call_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/call_statement.h"
#include "src/tint/writer/hlsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::hlsl {
namespace {
using HlslGeneratorImplTest_Call = TestHelper;
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
- Func("my_func", {}, ty.f32(), {Return(1.23f)});
+ Func("my_func", {}, ty.f32(), {Return(1.23_f)});
auto* call = Call("my_func");
WrapInFunction(call);
@@ -39,7 +41,7 @@
Param(Sym(), ty.f32()),
Param(Sym(), ty.f32()),
},
- ty.f32(), {Return(1.23f)});
+ ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
diff --git a/src/tint/writer/hlsl/generator_impl_constructor_test.cc b/src/tint/writer/hlsl/generator_impl_constructor_test.cc
index 46cfc4d..b44dc69 100644
--- a/src/tint/writer/hlsl/generator_impl_constructor_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_constructor_test.cc
@@ -62,7 +62,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Float) {
- WrapInFunction(Construct<f32>(-1.2e-5f));
+ WrapInFunction(Construct<f32>(-1.2e-5_f));
GeneratorImpl& gen = Build();
@@ -98,7 +98,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec) {
- WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
+ WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
GeneratorImpl& gen = Build();
@@ -116,7 +116,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float_Literal) {
- WrapInFunction(vec3<f32>(2.0f));
+ WrapInFunction(vec3<f32>(2_f));
GeneratorImpl& gen = Build();
@@ -125,7 +125,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Vec_SingleScalar_Float_Var) {
- auto* var = Var("v", nullptr, Expr(2.0f));
+ auto* var = Var("v", nullptr, Expr(2_f));
auto* cast = vec3<f32>(var);
WrapInFunction(var, cast);
@@ -176,7 +176,7 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Mat) {
- WrapInFunction(mat2x3<f32>(vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(3.f, 4.f, 5.f)));
+ WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
GeneratorImpl& gen = Build();
@@ -197,8 +197,8 @@
}
TEST_F(HlslGeneratorImplTest_Constructor, EmitConstructor_Type_Array) {
- WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.f, 2.f, 3.f),
- vec3<f32>(4.f, 5.f, 6.f), vec3<f32>(7.f, 8.f, 9.f)));
+ WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
+ vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
GeneratorImpl& gen = Build();
@@ -223,7 +223,7 @@
Member("c", ty.vec3<i32>()),
});
- WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
+ WrapInFunction(Construct(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
GeneratorImpl& gen = SanitizeAndBuild();
diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc
index 0525fa6..6a1c566 100644
--- a/src/tint/writer/hlsl/generator_impl_function_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_function_test.cc
@@ -192,8 +192,8 @@
});
Func("vert_main", {}, ty.Of(interface_struct),
- {Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5f),
- Expr(0.25f)))},
+ {Return(Construct(ty.Of(interface_struct), Construct(ty.vec4<f32>()), Expr(0.5_f),
+ Expr(0.25_f)))},
{Stage(ast::PipelineStage::kVertex)});
Func("frag_main", {Param("inputs", ty.Of(interface_struct))}, ty.void_(),
@@ -270,13 +270,13 @@
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
{Return(Construct(ty.Of(vertex_output_struct),
- Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1.f))))},
+ Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1_f))))},
{});
- Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.5f)))},
+ Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.5_f)))},
{Stage(ast::PipelineStage::kVertex)});
- Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.25f)))},
+ Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Call("foo", Expr(0.25_f)))},
{Stage(ast::PipelineStage::kVertex)});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -340,7 +340,7 @@
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", {}, ty.void_(),
{
@@ -490,7 +490,7 @@
Func("frag_main", ast::VariableList{}, ty.void_(),
{
- Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
+ Assign(MemberAccessor("coord", "b"), Expr(2_f)),
Return(),
},
{
@@ -524,7 +524,7 @@
Func("frag_main", ast::VariableList{}, ty.void_(),
{
- Assign(MemberAccessor("coord", "b"), Expr(2.0f)),
+ Assign(MemberAccessor("coord", "b"), Expr(2_f)),
Return(),
},
{
@@ -557,7 +557,7 @@
Return(MemberAccessor("coord", "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", ast::VariableList{}, ty.void_(),
{
@@ -599,7 +599,7 @@
Return(MemberAccessor("coord", "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", ast::VariableList{}, ty.void_(),
{
diff --git a/src/tint/writer/hlsl/generator_impl_import_test.cc b/src/tint/writer/hlsl/generator_impl_import_test.cc
index 73e3161..f7d544e 100644
--- a/src/tint/writer/hlsl/generator_impl_import_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_import_test.cc
@@ -35,7 +35,7 @@
auto param = GetParam();
auto* ident = Expr(param.name);
- auto* expr = Call(ident, 1.f);
+ auto* expr = Call(ident, 1_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -92,7 +92,7 @@
auto param = GetParam();
auto* ident = Expr(param.name);
- auto* expr = Call(ident, vec3<f32>(1.f, 2.f, 3.f));
+ auto* expr = Call(ident, vec3<f32>(1_f, 2_f, 3_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -132,7 +132,7 @@
TEST_P(HlslImportData_DualParam_ScalarTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.f, 2.f);
+ auto* expr = Call(param.name, 1_f, 2_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -154,7 +154,7 @@
TEST_P(HlslImportData_DualParam_VectorTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f));
+ auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -197,7 +197,7 @@
TEST_P(HlslImportData_TripleParam_ScalarTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.f, 2.f, 3.f);
+ auto* expr = Call(param.name, 1_f, 2_f, 3_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -217,8 +217,8 @@
TEST_P(HlslImportData_TripleParam_VectorTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f),
- vec3<f32>(7.f, 8.f, 9.f));
+ auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f),
+ vec3<f32>(7_f, 8_f, 9_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/hlsl/generator_impl_loop_test.cc b/src/tint/writer/hlsl/generator_impl_loop_test.cc
index 0bd1f75..0bf4090 100644
--- a/src/tint/writer/hlsl/generator_impl_loop_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_loop_test.cc
@@ -114,8 +114,8 @@
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
- auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
- Decl(Var("other", ty.f32())), //
+ auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
+ Decl(Var("other", ty.f32())), //
Break());
auto* continuing = Block(Assign("lhs", "rhs"));
diff --git a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc
index ad1e973..7f2933a 100644
--- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc
@@ -644,7 +644,7 @@
// };
//
// var<storage> data : Pre;
- // data.c[2].b = vec3<f32>(1.f, 2.f, 3.f);
+ // data.c[2].b = vec3<f32>(1_f, 2_f, 3_f);
auto* inner = Structure("Inner", {
Member("a", ty.vec3<f32>()),
@@ -657,7 +657,7 @@
SetupFunction({
Assign(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
- vec3<f32>(1.f, 2.f, 3.f)),
+ vec3<f32>(1_f, 2_f, 3_f)),
});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -698,7 +698,7 @@
SetupFunction({
Assign(MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("data", "c"), 2_i), "b"),
"y"),
- Expr(1.f)),
+ Expr(1_f)),
});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -717,7 +717,7 @@
TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_xyz) {
auto* var =
- Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
+ Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
auto* expr = MemberAccessor("my_vec", "xyz");
WrapInFunction(var, expr);
@@ -728,7 +728,7 @@
TEST_F(HlslGeneratorImplTest_MemberAccessor, Swizzle_gbr) {
auto* var =
- Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1.f, 2.f, 3.f, 4.f));
+ Var("my_vec", ty.vec4<f32>(), ast::StorageClass::kNone, vec4<f32>(1_f, 2_f, 3_f, 4_f));
auto* expr = MemberAccessor("my_vec", "gbr");
WrapInFunction(var, expr);
diff --git a/src/tint/writer/hlsl/generator_impl_module_constant_test.cc b/src/tint/writer/hlsl/generator_impl_module_constant_test.cc
index 14e8e93..2c96744 100644
--- a/src/tint/writer/hlsl/generator_impl_module_constant_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_module_constant_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/id_attribute.h"
#include "src/tint/writer/hlsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::hlsl {
namespace {
using HlslGeneratorImplTest_ModuleConstant = TestHelper;
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
- auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1.f, 2.f, 3.f));
+ auto* var = Let("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
WrapInFunction(Decl(var));
GeneratorImpl& gen = Build();
@@ -31,7 +33,7 @@
}
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
- auto* var = Override("pos", ty.f32(), Expr(3.0f),
+ auto* var = Override("pos", ty.f32(), Expr(3_f),
ast::AttributeList{
Id(23),
});
@@ -63,11 +65,11 @@
}
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoId) {
- auto* a = Override("a", ty.f32(), Expr(3.0f),
+ auto* a = Override("a", ty.f32(), Expr(3_f),
ast::AttributeList{
Id(0),
});
- auto* b = Override("b", ty.f32(), Expr(2.0f));
+ auto* b = Override("b", ty.f32(), Expr(2_f));
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
index b68c950..66df535 100644
--- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc
@@ -219,7 +219,7 @@
Member("b", ty.vec3<f32>()),
Member("c", ty.i32()),
});
- auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2.f, 3.f, 4.f), 4_i);
+ auto* struct_init = Construct(ty.Of(str), 1_i, vec3<f32>(2_f, 3_f, 4_f), 4_i);
auto* struct_access = MemberAccessor(struct_init, "b");
auto* pos = Var("pos", ty.vec3<f32>(), ast::StorageClass::kNone, struct_access);
diff --git a/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc b/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc
index 466c871..826a545 100644
--- a/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc
+++ b/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc
@@ -29,7 +29,7 @@
TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
- Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
+ Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1_i),
@@ -45,7 +45,7 @@
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
- Func("main", {}, ty.void_(), {Assign("wg", 1.2f)},
+ Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{
Stage(ast::PipelineStage::kCompute),
WorkgroupSize(1_i),
diff --git a/src/tint/writer/msl/generator_impl_call_test.cc b/src/tint/writer/msl/generator_impl_call_test.cc
index 9fc7b8f..93c9b83 100644
--- a/src/tint/writer/msl/generator_impl_call_test.cc
+++ b/src/tint/writer/msl/generator_impl_call_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/call_statement.h"
#include "src/tint/writer/msl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::msl {
namespace {
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
- Func("my_func", {}, ty.f32(), {Return(1.23f)});
+ Func("my_func", {}, ty.f32(), {Return(1.23_f)});
auto* call = Call("my_func");
WrapInFunction(call);
@@ -39,7 +41,7 @@
Param(Sym(), ty.f32()),
Param(Sym(), ty.f32()),
},
- ty.f32(), {Return(1.23f)});
+ ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
diff --git a/src/tint/writer/msl/generator_impl_constructor_test.cc b/src/tint/writer/msl/generator_impl_constructor_test.cc
index feb9de1..fa2e113 100644
--- a/src/tint/writer/msl/generator_impl_constructor_test.cc
+++ b/src/tint/writer/msl/generator_impl_constructor_test.cc
@@ -53,7 +53,7 @@
TEST_F(MslGeneratorImplTest, EmitConstructor_Float) {
// Use a number close to 1<<30 but whose decimal representation ends in 0.
- WrapInFunction(Expr(static_cast<float>((1 << 30) - 4)));
+ WrapInFunction(Expr(f32((1 << 30) - 4)));
GeneratorImpl& gen = Build();
@@ -62,7 +62,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Float) {
- WrapInFunction(Construct<f32>(-1.2e-5f));
+ WrapInFunction(Construct<f32>(-1.2e-5_f));
GeneratorImpl& gen = Build();
@@ -98,7 +98,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Vec) {
- WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
+ WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
GeneratorImpl& gen = Build();
@@ -116,8 +116,7 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Mat) {
- WrapInFunction(
- Construct(ty.mat2x3<f32>(), vec3<f32>(1.0f, 2.0f, 3.0f), vec3<f32>(3.0f, 4.0f, 5.0f)));
+ WrapInFunction(Construct(ty.mat2x3<f32>(), vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
GeneratorImpl& gen = Build();
@@ -139,8 +138,8 @@
}
TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Array) {
- WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.0f, 2.0f, 3.0f),
- vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f)));
+ WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
+ vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
GeneratorImpl& gen = Build();
@@ -156,7 +155,7 @@
Member("c", ty.vec3<i32>()),
});
- WrapInFunction(Construct(ty.Of(str), 1_i, 2.0f, vec3<i32>(3_i, 4_i, 5_i)));
+ WrapInFunction(Construct(ty.Of(str), 1_i, 2_f, vec3<i32>(3_i, 4_i, 5_i)));
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/msl/generator_impl_function_test.cc b/src/tint/writer/msl/generator_impl_function_test.cc
index 063fda8..5eb4905 100644
--- a/src/tint/writer/msl/generator_impl_function_test.cc
+++ b/src/tint/writer/msl/generator_impl_function_test.cc
@@ -177,7 +177,7 @@
});
Func("vert_main", {}, ty.Of(interface_struct),
- {Return(Construct(ty.Of(interface_struct), Expr(0.5f), Expr(0.25f),
+ {Return(Construct(ty.Of(interface_struct), Expr(0.5_f), Expr(0.25_f),
Construct(ty.vec4<f32>())))},
{Stage(ast::PipelineStage::kVertex)});
@@ -257,13 +257,13 @@
Func("foo", {Param("x", ty.f32())}, ty.Of(vertex_output_struct),
{Return(Construct(ty.Of(vertex_output_struct),
- Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1.f))))},
+ Construct(ty.vec4<f32>(), "x", "x", "x", Expr(1_f))))},
{});
- Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.5f))))},
+ Func("vert_main1", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.5_f))))},
{Stage(ast::PipelineStage::kVertex)});
- Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.25f))))},
+ Func("vert_main2", {}, ty.Of(vertex_output_struct), {Return(Expr(Call("foo", Expr(0.25_f))))},
{Stage(ast::PipelineStage::kVertex)});
GeneratorImpl& gen = SanitizeAndBuild();
@@ -415,7 +415,7 @@
Return(MemberAccessor(MemberAccessor(ubo, "coord"), "x")),
});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", {}, ty.void_(),
{
@@ -467,7 +467,7 @@
Func("sub_func", params, ty.f32(), body, {});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", ast::VariableList{}, ty.void_(),
ast::StatementList{
@@ -520,7 +520,7 @@
Func("sub_func", params, ty.f32(), body, {});
- auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1.0f));
+ auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, Call("sub_func", 1_f));
Func("frag_main", ast::VariableList{}, ty.void_(),
ast::StatementList{
diff --git a/src/tint/writer/msl/generator_impl_import_test.cc b/src/tint/writer/msl/generator_impl_import_test.cc
index fa5519a..8a6d2d0 100644
--- a/src/tint/writer/msl/generator_impl_import_test.cc
+++ b/src/tint/writer/msl/generator_impl_import_test.cc
@@ -33,7 +33,7 @@
using MslImportData_SingleParamTest = TestParamHelper<MslImportData>;
TEST_P(MslImportData_SingleParamTest, FloatScalar) {
auto param = GetParam();
- auto* call = Call(param.name, 1.f);
+ auto* call = Call(param.name, 1_f);
// The resolver will set the builtin data for the ident
WrapInFunction(call);
@@ -87,7 +87,7 @@
}
TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_ScalarLength) {
- auto* expr = Call("length", 2.f);
+ auto* expr = Call("length", 2_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -100,7 +100,7 @@
using MslImportData_DualParam_ScalarTest = TestParamHelper<MslImportData>;
TEST_P(MslImportData_DualParam_ScalarTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.0f, 2.0f);
+ auto* expr = Call(param.name, 1_f, 2_f);
WrapInFunction(expr);
@@ -119,7 +119,7 @@
MslImportData{"step", "step"}));
TEST_F(MslGeneratorImplTest, MslImportData_DualParam_ScalarDistance) {
- auto* expr = Call("distance", 2.f, 3.f);
+ auto* expr = Call("distance", 2_f, 3_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -133,7 +133,7 @@
TEST_P(MslImportData_DualParam_VectorTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f));
+ auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -175,7 +175,7 @@
TEST_P(MslImportData_TripleParam_ScalarTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.f, 2.f, 3.f);
+ auto* expr = Call(param.name, 1_f, 2_f, 3_f);
WrapInFunction(expr);
GeneratorImpl& gen = Build();
@@ -195,8 +195,8 @@
TEST_P(MslImportData_TripleParam_VectorTest, Float) {
auto param = GetParam();
- auto* expr = Call(param.name, vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(4.f, 5.f, 6.f),
- vec3<f32>(7.f, 8.f, 9.f));
+ auto* expr = Call(param.name, vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(4_f, 5_f, 6_f),
+ vec3<f32>(7_f, 8_f, 9_f));
WrapInFunction(expr);
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/msl/generator_impl_loop_test.cc b/src/tint/writer/msl/generator_impl_loop_test.cc
index 1df7486..248e711 100644
--- a/src/tint/writer/msl/generator_impl_loop_test.cc
+++ b/src/tint/writer/msl/generator_impl_loop_test.cc
@@ -109,8 +109,8 @@
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
- auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4f))), //
- Decl(Var("other", ty.f32())), //
+ auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
+ Decl(Var("other", ty.f32())), //
Break());
auto* continuing = Block(Assign("lhs", "rhs"));
diff --git a/src/tint/writer/msl/generator_impl_module_constant_test.cc b/src/tint/writer/msl/generator_impl_module_constant_test.cc
index 59cc2eb..2b70da4 100644
--- a/src/tint/writer/msl/generator_impl_module_constant_test.cc
+++ b/src/tint/writer/msl/generator_impl_module_constant_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/id_attribute.h"
#include "src/tint/writer/msl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::msl {
namespace {
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
- auto* var = GlobalConst("pos", ty.array<f32, 3>(), array<f32, 3>(1.f, 2.f, 3.f));
+ auto* var = GlobalConst("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
GeneratorImpl& gen = Build();
@@ -30,7 +32,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
- auto* var = Override("pos", ty.f32(), Expr(3.f),
+ auto* var = Override("pos", ty.f32(), Expr(3_f),
ast::AttributeList{
Id(23),
});
diff --git a/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc
index cd8190f..be55cae 100644
--- a/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc
+++ b/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc
@@ -16,6 +16,8 @@
#include "src/tint/ast/variable_decl_statement.h"
#include "src/tint/writer/msl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::msl {
namespace {
@@ -122,7 +124,7 @@
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
- GlobalConst("initializer", ty.f32(), Expr(0.f));
+ GlobalConst("initializer", ty.f32(), Expr(0_f));
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
WrapInFunction(Expr("a"));
diff --git a/src/tint/writer/spirv/builder_accessor_expression_test.cc b/src/tint/writer/spirv/builder_accessor_expression_test.cc
index 67ee185..82fbfd7 100644
--- a/src/tint/writer/spirv/builder_accessor_expression_test.cc
+++ b/src/tint/writer/spirv/builder_accessor_expression_test.cc
@@ -312,7 +312,7 @@
Member("b", ty.f32()),
});
- auto* var = Let("ident", ty.Of(s), Construct(ty.Of(s), 0.f, 0.f));
+ auto* var = Let("ident", ty.Of(s), Construct(ty.Of(s), 0_f, 0_f));
auto* expr = MemberAccessor("ident", "b");
WrapInFunction(var, expr);
@@ -353,7 +353,7 @@
auto* s_type = Structure("my_struct", {Member("inner", ty.Of(inner_struct))});
auto* var = Let("ident", ty.Of(s_type),
- Construct(ty.Of(s_type), Construct(ty.Of(inner_struct), 0.f, 0.f)));
+ Construct(ty.Of(s_type), Construct(ty.Of(inner_struct), 0_f, 0_f)));
auto* expr = MemberAccessor(MemberAccessor("ident", "inner"), "b");
WrapInFunction(var, expr);
@@ -443,7 +443,7 @@
auto* s_type = Structure("my_struct", {Member("inner", ty.Of(inner_struct))});
auto* var = Var("ident", ty.Of(s_type));
- auto* expr = Assign(MemberAccessor(MemberAccessor("ident", "inner"), "a"), Expr(2.0f));
+ auto* expr = Assign(MemberAccessor(MemberAccessor("ident", "inner"), "a"), Expr(2_f));
WrapInFunction(var, expr);
spirv::Builder& b = Build();
@@ -753,8 +753,8 @@
// pos[1u]
auto* var = Let("pos", ty.array(ty.vec2<f32>(), 3_u),
- Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0.0f, 0.5f),
- vec2<f32>(-0.5f, -0.5f), vec2<f32>(0.5f, -0.5f)));
+ Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0_f, 0.5_f),
+ vec2<f32>(-0.5_f, -0.5_f), vec2<f32>(0.5_f, -0.5_f)));
auto* expr = IndexAccessor("pos", 1_u);
WrapInFunction(var, expr);
@@ -796,8 +796,8 @@
// pos[2u][1u]
auto* var = Let("pos", ty.array(ty.vec2<f32>(), 3_u),
- Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0.0f, 0.5f),
- vec2<f32>(-0.5f, -0.5f), vec2<f32>(0.5f, -0.5f)));
+ Construct(ty.array(ty.vec2<f32>(), 3_u), vec2<f32>(0_f, 0.5_f),
+ vec2<f32>(-0.5_f, -0.5_f), vec2<f32>(0.5_f, -0.5_f)));
auto* expr = IndexAccessor(IndexAccessor("pos", 2_u), 1_u);
WrapInFunction(var, expr);
@@ -837,7 +837,7 @@
// let pos : vec2<f32> = vec2<f32>(0.0, 0.5);
// pos[1]
- auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0.0f, 0.5f));
+ auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0_f, 0.5_f));
auto* expr = IndexAccessor("pos", 1_u);
WrapInFunction(var, expr);
@@ -867,7 +867,7 @@
// idx : i32
// pos[idx]
- auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0.0f, 0.5f));
+ auto* var = Let("pos", ty.vec2<f32>(), vec2<f32>(0_f, 0.5_f));
auto* idx = Var("idx", ty.i32());
auto* expr = IndexAccessor("pos", idx);
@@ -902,7 +902,7 @@
// let a : array<f32, 3u>;
// a[2i]
- auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
+ auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0_f, 0.5_f, 1_f));
auto* expr = IndexAccessor("a", 2_i);
WrapInFunction(var, expr);
@@ -937,7 +937,7 @@
// idx : i32
// a[idx]
- auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0.0f, 0.5f, 1.0f));
+ auto* var = Let("a", ty.array<f32, 3>(), Construct(ty.array<f32, 3>(), 0_f, 0.5_f, 1_f));
auto* idx = Var("idx", ty.i32());
auto* expr = IndexAccessor("a", idx);
@@ -986,8 +986,8 @@
// a[idx]
auto* var = Let("a", ty.mat2x2<f32>(),
- Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1.f, 2.f),
- Construct(ty.vec2<f32>(), 3.f, 4.f)));
+ Construct(ty.mat2x2<f32>(), Construct(ty.vec2<f32>(), 1_f, 2_f),
+ Construct(ty.vec2<f32>(), 3_f, 4_f)));
auto* idx = Var("idx", ty.i32());
auto* expr = IndexAccessor("a", idx);
diff --git a/src/tint/writer/spirv/builder_assign_test.cc b/src/tint/writer/spirv/builder_assign_test.cc
index 1e02e27..11ac42f 100644
--- a/src/tint/writer/spirv/builder_assign_test.cc
+++ b/src/tint/writer/spirv/builder_assign_test.cc
@@ -25,7 +25,7 @@
TEST_F(BuilderTest, Assign_Var) {
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
- auto* assign = Assign("var", 1.f);
+ auto* assign = Assign("var", 1_f);
WrapInFunction(assign);
@@ -53,7 +53,7 @@
TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) {
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
- auto* assign = Assign("var", Expr(1.f));
+ auto* assign = Assign("var", Expr(1_f));
WrapInFunction(assign);
@@ -99,7 +99,7 @@
}
TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) {
- auto* init = vec3<f32>(vec2<f32>(1.f, 2.f), 3.f);
+ auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
@@ -136,7 +136,7 @@
}
TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
- auto* init = vec3<f32>(1.f, 2.f, 3.f);
+ auto* init = vec3<f32>(1_f, 2_f, 3_f);
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
@@ -183,7 +183,7 @@
auto* v = Var("ident", ty.Of(s));
- auto* assign = Assign(MemberAccessor("ident", "b"), Expr(4.f));
+ auto* assign = Assign(MemberAccessor("ident", "b"), Expr(4_f));
WrapInFunction(v, assign);
@@ -215,7 +215,7 @@
TEST_F(BuilderTest, Assign_Vector) {
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
- auto* val = vec3<f32>(1.f, 1.f, 3.f);
+ auto* val = vec3<f32>(1_f, 1_f, 3_f);
auto* assign = Assign("var", val);
WrapInFunction(assign);
@@ -249,7 +249,7 @@
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
- auto* assign = Assign(MemberAccessor("var", "y"), Expr(1.f));
+ auto* assign = Assign(MemberAccessor("var", "y"), Expr(1_f));
WrapInFunction(assign);
@@ -284,7 +284,7 @@
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
- auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1.f));
+ auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1_f));
WrapInFunction(assign);
diff --git a/src/tint/writer/spirv/builder_binary_expression_test.cc b/src/tint/writer/spirv/builder_binary_expression_test.cc
index 17ca134..debe63c 100644
--- a/src/tint/writer/spirv/builder_binary_expression_test.cc
+++ b/src/tint/writer/spirv/builder_binary_expression_test.cc
@@ -195,8 +195,8 @@
TEST_P(BinaryArithFloatTest, Scalar) {
auto param = GetParam();
- auto* lhs = Expr(3.2f);
- auto* rhs = Expr(4.5f);
+ auto* lhs = Expr(3.2_f);
+ auto* rhs = Expr(4.5_f);
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
@@ -218,8 +218,8 @@
TEST_P(BinaryArithFloatTest, Vector) {
auto param = GetParam();
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
@@ -426,8 +426,8 @@
TEST_P(BinaryCompareFloatTest, Scalar) {
auto param = GetParam();
- auto* lhs = Expr(3.2f);
- auto* rhs = Expr(4.5f);
+ auto* lhs = Expr(3.2_f);
+ auto* rhs = Expr(4.5_f);
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
@@ -450,8 +450,8 @@
TEST_P(BinaryCompareFloatTest, Vector) {
auto param = GetParam();
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(param.op, lhs, rhs);
@@ -483,8 +483,8 @@
BinaryData{ast::BinaryOp::kNotEqual, "OpFOrdNotEqual"}));
TEST_F(BuilderTest, Binary_Multiply_VectorScalar) {
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
- auto* rhs = Expr(1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
+ auto* rhs = Expr(1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -506,8 +506,8 @@
}
TEST_F(BuilderTest, Binary_Multiply_ScalarVector) {
- auto* lhs = Expr(1.f);
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = Expr(1_f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, rhs);
@@ -531,7 +531,7 @@
TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) {
auto* var = Var("mat", ty.mat3x3<f32>());
- auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), Expr(1.f));
+ auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), Expr(1_f));
WrapInFunction(var, expr);
@@ -558,7 +558,7 @@
TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) {
auto* var = Var("mat", ty.mat3x3<f32>());
- auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr(1.f), Expr("mat"));
+ auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr(1_f), Expr("mat"));
WrapInFunction(var, expr);
@@ -584,7 +584,7 @@
TEST_F(BuilderTest, Binary_Multiply_MatrixVector) {
auto* var = Var("mat", ty.mat3x3<f32>());
- auto* rhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("mat"), rhs);
@@ -613,7 +613,7 @@
TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) {
auto* var = Var("mat", ty.mat3x3<f32>());
- auto* lhs = vec3<f32>(1.f, 1.f, 1.f);
+ auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, lhs, Expr("mat"));
@@ -899,7 +899,7 @@
static const ast::Expression* MakeVectorExpr(ProgramBuilder* builder, Type type) {
switch (type) {
case Type::f32:
- return builder->vec3<f32>(1.f, 1.f, 1.f);
+ return builder->vec3<f32>(1_f, 1_f, 1_f);
case Type::i32:
return builder->vec3<i32>(1_i, 1_i, 1_i);
case Type::u32:
@@ -910,7 +910,7 @@
static const ast::Expression* MakeScalarExpr(ProgramBuilder* builder, Type type) {
switch (type) {
case Type::f32:
- return builder->Expr(1.f);
+ return builder->Expr(1_f);
case Type::i32:
return builder->Expr(1_i);
case Type::u32:
diff --git a/src/tint/writer/spirv/builder_bitcast_expression_test.cc b/src/tint/writer/spirv/builder_bitcast_expression_test.cc
index 073d000..9dff5f6 100644
--- a/src/tint/writer/spirv/builder_bitcast_expression_test.cc
+++ b/src/tint/writer/spirv/builder_bitcast_expression_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::spirv {
namespace {
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Bitcast) {
- auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(2.4f));
+ auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(2.4_f));
WrapInFunction(bitcast);
@@ -40,7 +42,7 @@
}
TEST_F(BuilderTest, Bitcast_DuplicateType) {
- auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(2.4f));
+ auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(2.4_f));
WrapInFunction(bitcast);
diff --git a/src/tint/writer/spirv/builder_block_test.cc b/src/tint/writer/spirv/builder_block_test.cc
index ea70b6c..85a2371 100644
--- a/src/tint/writer/spirv/builder_block_test.cc
+++ b/src/tint/writer/spirv/builder_block_test.cc
@@ -15,6 +15,8 @@
#include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::spirv {
namespace {
@@ -23,9 +25,9 @@
TEST_F(BuilderTest, Block) {
// Note, this test uses shadow variables which aren't allowed in WGSL but
// serves to prove the block code is pushing new scopes as needed.
- auto* inner = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 2.f));
- auto* outer = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 1.f),
- inner, Assign("var", 3.f));
+ auto* inner = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 2_f));
+ auto* outer = Block(Decl(Var("var", ty.f32(), ast::StorageClass::kNone)), Assign("var", 1_f),
+ inner, Assign("var", 3_f));
WrapInFunction(outer);
diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc
index 04dde77..6d1316e 100644
--- a/src/tint/writer/spirv/builder_builtin_test.cc
+++ b/src/tint/writer/spirv/builder_builtin_test.cc
@@ -463,8 +463,8 @@
create<ast::GroupAttribute>(0),
});
- auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1.0f, 2.0f), 2.0f);
- auto* expr2 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1.0f, 2.0f), 2.0f);
+ auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
+ auto* expr2 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
Func("f1", {}, ty.void_(), {CallStmt(expr1)}, {});
Func("f2", {}, ty.void_(), {CallStmt(expr2)}, {});
@@ -539,7 +539,7 @@
using Builtin_Builtin_SingleParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(Builtin_Builtin_SingleParam_Float_Test, Call_Scalar) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.0f);
+ auto* expr = Call(param.name, 1_f);
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -566,7 +566,7 @@
TEST_P(Builtin_Builtin_SingleParam_Float_Test, Call_Vector) {
auto param = GetParam();
- auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call(param.name, vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -620,7 +620,7 @@
BuiltinData{"trunc", "Trunc"}));
TEST_F(BuiltinBuilderTest, Call_Length_Scalar) {
- auto* expr = Call("length", 1.0f);
+ auto* expr = Call("length", 1_f);
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -645,7 +645,7 @@
}
TEST_F(BuiltinBuilderTest, Call_Length_Vector) {
- auto* expr = Call("length", vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call("length", vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -672,7 +672,7 @@
}
TEST_F(BuiltinBuilderTest, Call_Normalize) {
- auto* expr = Call("normalize", vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call("normalize", vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -701,7 +701,7 @@
using Builtin_Builtin_DualParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(Builtin_Builtin_DualParam_Float_Test, Call_Scalar) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.0f, 1.0f);
+ auto* expr = Call(param.name, 1_f, 1_f);
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -728,7 +728,7 @@
TEST_P(Builtin_Builtin_DualParam_Float_Test, Call_Vector) {
auto param = GetParam();
- auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call(param.name, vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -763,7 +763,7 @@
BuiltinData{"step", "Step"}));
TEST_F(BuiltinBuilderTest, Call_Reflect_Vector) {
- auto* expr = Call("reflect", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call("reflect", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -790,7 +790,7 @@
}
TEST_F(BuiltinBuilderTest, Call_Distance_Scalar) {
- auto* expr = Call("distance", 1.0f, 1.0f);
+ auto* expr = Call("distance", 1_f, 1_f);
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -815,7 +815,7 @@
}
TEST_F(BuiltinBuilderTest, Call_Distance_Vector) {
- auto* expr = Call("distance", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call("distance", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -842,7 +842,7 @@
}
TEST_F(BuiltinBuilderTest, Call_Cross) {
- auto* expr = Call("cross", vec3<f32>(1.0f, 1.0f, 1.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
+ auto* expr = Call("cross", vec3<f32>(1_f, 1_f, 1_f), vec3<f32>(1_f, 1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -871,7 +871,7 @@
using Builtin_Builtin_ThreeParam_Float_Test = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(Builtin_Builtin_ThreeParam_Float_Test, Call_Scalar) {
auto param = GetParam();
- auto* expr = Call(param.name, 1.0f, 1.0f, 1.0f);
+ auto* expr = Call(param.name, 1_f, 1_f, 1_f);
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -898,8 +898,7 @@
TEST_P(Builtin_Builtin_ThreeParam_Float_Test, Call_Vector) {
auto param = GetParam();
- auto* expr =
- Call(param.name, vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call(param.name, vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -934,8 +933,7 @@
BuiltinData{"smoothstep", "SmoothStep"}));
TEST_F(BuiltinBuilderTest, Call_FaceForward_Vector) {
- auto* expr =
- Call("faceForward", vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f), vec2<f32>(1.0f, 1.0f));
+ auto* expr = Call("faceForward", vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f), vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(),
{
Assign(Phony(), expr),
@@ -1312,7 +1310,7 @@
testing::Values(BuiltinData{"clamp", "UClamp"}));
TEST_F(BuiltinBuilderTest, Call_Modf) {
- auto* expr = Call("modf", vec2<f32>(1.0f, 2.0f));
+ auto* expr = Call("modf", vec2<f32>(1_f, 2_f));
Func("a_func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@@ -1350,7 +1348,7 @@
}
TEST_F(BuiltinBuilderTest, Call_Frexp) {
- auto* expr = Call("frexp", vec2<f32>(1.0f, 2.0f));
+ auto* expr = Call("frexp", vec2<f32>(1_f, 2_f));
Func("a_func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
spirv::Builder& b = Build();
@@ -2104,8 +2102,8 @@
auto param = GetParam();
bool pack4 = param.name == "pack4x8snorm" || param.name == "pack4x8unorm";
- auto* call = pack4 ? Call(param.name, vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f))
- : Call(param.name, vec2<f32>(1.0f, 1.0f));
+ auto* call = pack4 ? Call(param.name, vec4<f32>(1_f, 1_f, 1_f, 1_f))
+ : Call(param.name, vec2<f32>(1_f, 1_f));
auto* func = Func("a_func", {}, ty.void_(), {CallStmt(call)});
spirv::Builder& b = Build();
diff --git a/src/tint/writer/spirv/builder_call_test.cc b/src/tint/writer/spirv/builder_call_test.cc
index 782b008..b81ca96 100644
--- a/src/tint/writer/spirv/builder_call_test.cc
+++ b/src/tint/writer/spirv/builder_call_test.cc
@@ -17,6 +17,8 @@
#include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::spirv {
namespace {
@@ -28,7 +30,7 @@
func_params.push_back(Param("b", ty.f32()));
auto* a_func = Func("a_func", func_params, ty.f32(), {Return(Add("a", "b"))});
- auto* func = Func("main", {}, ty.void_(), {Assign(Phony(), Call("a_func", 1.f, 1.f))});
+ auto* func = Func("main", {}, ty.void_(), {Assign(Phony(), Call("a_func", 1_f, 1_f))});
spirv::Builder& b = Build();
@@ -66,7 +68,7 @@
auto* a_func = Func("a_func", func_params, ty.f32(), {Return(Add("a", "b"))});
- auto* func = Func("main", {}, ty.void_(), {CallStmt(Call("a_func", 1.f, 1.f))});
+ auto* func = Func("main", {}, ty.void_(), {CallStmt(Call("a_func", 1_f, 1_f))});
spirv::Builder& b = Build();
diff --git a/src/tint/writer/spirv/builder_constructor_expression_test.cc b/src/tint/writer/spirv/builder_constructor_expression_test.cc
index 41409af..ec69cfb 100644
--- a/src/tint/writer/spirv/builder_constructor_expression_test.cc
+++ b/src/tint/writer/spirv/builder_constructor_expression_test.cc
@@ -23,7 +23,7 @@
using SpvBuilderConstructorTest = TestHelper;
TEST_F(SpvBuilderConstructorTest, Const) {
- auto* c = Expr(42.2f);
+ auto* c = Expr(42.2_f);
auto* g = Global("g", ty.f32(), c, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -50,7 +50,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type) {
- auto* t = vec3<f32>(1.0f, 1.0f, 3.0f);
+ auto* t = vec3<f32>(1_f, 1_f, 3_f);
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -94,7 +94,7 @@
// cast<Int>(2.3f)
auto* alias = Alias("Int", ty.i32());
- auto* cast = Construct(ty.Of(alias), 2.3f);
+ auto* cast = Construct(ty.Of(alias), 2.3_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -114,7 +114,7 @@
TEST_F(SpvBuilderConstructorTest, Type_IdentifierExpression_Param) {
auto* var = Var("ident", ty.f32());
- auto* t = vec2<f32>(1.0f, "ident");
+ auto* t = vec2<f32>(1_f, "ident");
WrapInFunction(var, t);
spirv::Builder& b = Build();
@@ -213,7 +213,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_F32_With_F32) {
- auto* cast = Construct<f32>(2.0f);
+ auto* cast = Construct<f32>(2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -269,7 +269,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Literal) {
- auto* cast = vec2<f32>(2.0f);
+ auto* cast = vec2<f32>(2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -286,7 +286,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_Var) {
- auto* var = Var("v", nullptr, Expr(2.0f));
+ auto* var = Var("v", nullptr, Expr(2_f));
auto* cast = vec2<f32>(var);
WrapInFunction(var, cast);
@@ -309,7 +309,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_F32_F32) {
- auto* cast = vec2<f32>(2.0f, 2.0f);
+ auto* cast = vec2<f32>(2_f, 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -325,7 +325,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec2_With_Vec2) {
- auto* value = vec2<f32>(2.0f, 2.0f);
+ auto* value = vec2<f32>(2_f, 2_f);
auto* cast = vec2<f32>(value);
WrapInFunction(cast);
@@ -343,7 +343,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32) {
- auto* cast = vec3<f32>(2.0f);
+ auto* cast = vec3<f32>(2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -375,7 +375,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_F32_F32) {
- auto* cast = vec3<f32>(2.0f, 2.0f, 2.0f);
+ auto* cast = vec3<f32>(2_f, 2_f, 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -391,7 +391,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_F32_Vec2) {
- auto* cast = vec3<f32>(2.0f, vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec3<f32>(2_f, vec2<f32>(2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -413,7 +413,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec2_F32) {
- auto* cast = vec3<f32>(vec2<f32>(2.0f, 2.0f), 2.0f);
+ auto* cast = vec3<f32>(vec2<f32>(2_f, 2_f), 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -435,7 +435,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec3_With_Vec3) {
- auto* value = vec3<f32>(2.0f, 2.0f, 2.0f);
+ auto* value = vec3<f32>(2_f, 2_f, 2_f);
auto* cast = vec3<f32>(value);
WrapInFunction(cast);
@@ -469,7 +469,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32) {
- auto* cast = vec4<f32>(2.0f);
+ auto* cast = vec4<f32>(2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -485,7 +485,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_F32_F32) {
- auto* cast = vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f);
+ auto* cast = vec4<f32>(2_f, 2_f, 2_f, 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -501,7 +501,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_F32_Vec2) {
- auto* cast = vec4<f32>(2.0f, 2.0f, vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec4<f32>(2_f, 2_f, vec2<f32>(2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -523,7 +523,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec2_F32) {
- auto* cast = vec4<f32>(2.0f, vec2<f32>(2.0f, 2.0f), 2.0f);
+ auto* cast = vec4<f32>(2_f, vec2<f32>(2_f, 2_f), 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -545,7 +545,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_F32_F32) {
- auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), 2.0f, 2.0f);
+ auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), 2_f, 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -567,7 +567,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec2_Vec2) {
- auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -591,7 +591,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_F32_Vec3) {
- auto* cast = vec4<f32>(2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* cast = vec4<f32>(2_f, vec3<f32>(2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -614,7 +614,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec3_F32) {
- auto* cast = vec4<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), 2.0f);
+ auto* cast = vec4<f32>(vec3<f32>(2_f, 2_f, 2_f), 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -637,7 +637,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec4) {
- auto* value = vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f);
+ auto* value = vec4<f32>(2_f, 2_f, 2_f, 2_f);
auto* cast = vec4<f32>(value);
WrapInFunction(cast);
@@ -655,7 +655,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_F32_With_F32) {
- auto* ctor = Construct<f32>(2.0f);
+ auto* ctor = Construct<f32>(2_f);
GlobalConst("g", ty.f32(), ctor);
spirv::Builder& b = SanitizeAndBuild();
@@ -670,7 +670,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_U32_With_F32) {
- auto* ctor = Construct<u32>(1.5f);
+ auto* ctor = Construct<u32>(1.5_f);
GlobalConst("g", ty.u32(), ctor);
spirv::Builder& b = SanitizeAndBuild();
@@ -685,7 +685,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_F32) {
- auto* cast = vec2<f32>(2.0f);
+ auto* cast = vec2<f32>(2_f);
auto* g = Global("g", ty.vec2<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -701,7 +701,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_Vec2) {
- auto* cast = vec2<f32>(vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec2<f32>(vec2<f32>(2_f, 2_f));
GlobalConst("a", ty.vec2<f32>(), cast);
spirv::Builder& b = SanitizeAndBuild();
@@ -719,7 +719,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec3) {
- auto* cast = vec3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* cast = vec3<f32>(vec3<f32>(2_f, 2_f, 2_f));
GlobalConst("a", ty.vec3<f32>(), cast);
spirv::Builder& b = SanitizeAndBuild();
@@ -737,7 +737,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec4) {
- auto* cast = vec4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
+ auto* cast = vec4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f));
GlobalConst("a", ty.vec4<f32>(), cast);
spirv::Builder& b = SanitizeAndBuild();
@@ -755,7 +755,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32) {
- auto* cast = vec3<f32>(2.0f);
+ auto* cast = vec3<f32>(2_f);
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -771,7 +771,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32_Vec2) {
- auto* cast = vec3<f32>(2.0f, vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec3<f32>(2_f, vec2<f32>(2_f, 2_f));
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -794,7 +794,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec2_F32) {
- auto* cast = vec3<f32>(vec2<f32>(2.0f, 2.0f), 2.0f);
+ auto* cast = vec3<f32>(vec2<f32>(2_f, 2_f), 2_f);
auto* g = Global("g", ty.vec3<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -817,7 +817,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32) {
- auto* cast = vec4<f32>(2.0f);
+ auto* cast = vec4<f32>(2_f);
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -833,7 +833,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_F32_Vec2) {
- auto* cast = vec4<f32>(2.0f, 2.0f, vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec4<f32>(2_f, 2_f, vec2<f32>(2_f, 2_f));
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -856,7 +856,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec2_F32) {
- auto* cast = vec4<f32>(2.0f, vec2<f32>(2.0f, 2.0f), 2.0f);
+ auto* cast = vec4<f32>(2_f, vec2<f32>(2_f, 2_f), 2_f);
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -879,7 +879,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_F32_F32) {
- auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), 2.0f, 2.0f);
+ auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), 2_f, 2_f);
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -902,7 +902,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_Vec2) {
- auto* cast = vec4<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
+ auto* cast = vec4<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -927,7 +927,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec3) {
- auto* cast = vec4<f32>(2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* cast = vec4<f32>(2_f, vec3<f32>(2_f, 2_f, 2_f));
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -952,7 +952,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec3_F32) {
- auto* cast = vec4<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), 2.0f);
+ auto* cast = vec4<f32>(vec3<f32>(2_f, 2_f, 2_f), 2_f);
auto* g = Global("g", ty.vec4<f32>(), cast, ast::StorageClass::kPrivate);
spirv::Builder& b = Build();
@@ -977,7 +977,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat2x2_With_Vec2_Vec2) {
- auto* cast = mat2x2<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
+ auto* cast = mat2x2<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -995,7 +995,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat3x2_With_Vec2_Vec2_Vec2) {
- auto* cast = mat3x2<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f));
+ auto* cast = mat3x2<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1013,8 +1013,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat4x2_With_Vec2_Vec2_Vec2_Vec2) {
- auto* cast = mat4x2<f32>(vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f), vec2<f32>(2.0f, 2.0f),
- vec2<f32>(2.0f, 2.0f));
+ auto* cast = mat4x2<f32>(vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f), vec2<f32>(2_f, 2_f),
+ vec2<f32>(2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1032,7 +1032,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat2x3_With_Vec3_Vec3) {
- auto* cast = mat2x3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* cast = mat2x3<f32>(vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1050,8 +1050,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat3x3_With_Vec3_Vec3_Vec3) {
- auto* cast = mat3x3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f),
- vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* cast =
+ mat3x3<f32>(vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1069,8 +1069,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat4x3_With_Vec3_Vec3_Vec3_Vec3) {
- auto* cast = mat4x3<f32>(vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f),
- vec3<f32>(2.0f, 2.0f, 2.0f), vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* cast = mat4x3<f32>(vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f),
+ vec3<f32>(2_f, 2_f, 2_f), vec3<f32>(2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1088,7 +1088,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat2x4_With_Vec4_Vec4) {
- auto* cast = mat2x4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
+ auto* cast = mat2x4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1106,8 +1106,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat3x4_With_Vec4_Vec4_Vec4) {
- auto* cast = mat3x4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f),
- vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
+ auto* cast = mat3x4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f),
+ vec4<f32>(2_f, 2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1125,8 +1125,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Mat4x4_With_Vec4_Vec4_Vec4_Vec4) {
- auto* cast = mat4x4<f32>(vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f),
- vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f), vec4<f32>(2.0f, 2.0f, 2.0f, 2.0f));
+ auto* cast = mat4x4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f),
+ vec4<f32>(2_f, 2_f, 2_f, 2_f), vec4<f32>(2_f, 2_f, 2_f, 2_f));
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1144,7 +1144,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Array_5_F32) {
- auto* cast = array<f32, 5>(2.0f, 2.0f, 2.0f, 2.0f, 2.0f);
+ auto* cast = array<f32, 5>(2_f, 2_f, 2_f, 2_f, 2_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1162,8 +1162,8 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) {
- auto* first = vec3<f32>(1.f, 2.f, 3.f);
- auto* second = vec3<f32>(1.f, 2.f, 3.f);
+ auto* first = vec3<f32>(1_f, 2_f, 3_f);
+ auto* second = vec3<f32>(1_f, 2_f, 3_f);
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), first, second);
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1184,8 +1184,8 @@
}
TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoVectors) {
- auto* v1 = vec3<f32>(2.0f, 2.0f, 2.0f);
- auto* v2 = vec3<f32>(2.0f, 2.0f, 2.0f);
+ auto* v1 = vec3<f32>(2_f, 2_f, 2_f);
+ auto* v2 = vec3<f32>(2_f, 2_f, 2_f);
ast::StatementList stmts = {
WrapInStatement(v1),
WrapInStatement(v2),
@@ -1206,8 +1206,8 @@
}
TEST_F(SpvBuilderConstructorTest, CommonInitializer_TwoArrays) {
- auto* a1 = array<f32, 3>(2.0f, 2.0f, 2.0f);
- auto* a2 = array<f32, 3>(2.0f, 2.0f, 2.0f);
+ auto* a1 = array<f32, 3>(2_f, 2_f, 2_f);
+ auto* a2 = array<f32, 3>(2_f, 2_f, 2_f);
ast::StatementList stmts = {
WrapInStatement(a1),
WrapInStatement(a2),
@@ -1233,8 +1233,8 @@
// Test that initializers of different types with the same values produce
// different OpConstantComposite instructions.
// crbug.com/tint/777
- auto* a1 = array<f32, 2>(1.0f, 2.0f);
- auto* a2 = vec2<f32>(1.0f, 2.0f);
+ auto* a1 = array<f32, 2>(1_f, 2_f);
+ auto* a2 = vec2<f32>(1_f, 2_f);
ast::StatementList stmts = {
WrapInStatement(a1),
WrapInStatement(a2),
@@ -1264,7 +1264,7 @@
Member("b", ty.vec3<f32>()),
});
- auto* t = Construct(ty.Of(s), 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
+ auto* t = Construct(ty.Of(s), 2_f, vec3<f32>(2_f, 2_f, 2_f));
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1463,7 +1463,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) {
- auto* cast = Construct<i32>(2.4f);
+ auto* cast = Construct<i32>(2.4_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1481,7 +1481,7 @@
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) {
- auto* cast = Construct<u32>(2.4f);
+ auto* cast = Construct<u32>(2.4_f);
WrapInFunction(cast);
spirv::Builder& b = Build();
@@ -1692,7 +1692,7 @@
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstConstructors) {
// vec3<f32>(1.0, 2.0, 3.0) -> true
- auto* t = vec3<f32>(1.f, 2.f, 3.f);
+ auto* t = vec3<f32>(1_f, 2_f, 3_f);
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1704,8 +1704,8 @@
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalArrayWithAllConstConstructors) {
// array<vec3<f32>, 2u>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(1.0, 2.0, 3.0))
// -> true
- auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), vec3<f32>(1.f, 2.f, 3.f),
- vec3<f32>(1.f, 2.f, 3.f));
+ auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), vec3<f32>(1_f, 2_f, 3_f),
+ vec3<f32>(1_f, 2_f, 3_f));
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1717,7 +1717,7 @@
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithMatchingTypeConstructors) {
// vec2<f32>(f32(1.0), f32(2.0)) -> false
- auto* t = vec2<f32>(Construct<f32>(1.f), Construct<f32>(2.f));
+ auto* t = vec2<f32>(Construct<f32>(1_f), Construct<f32>(2_f));
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1741,7 +1741,7 @@
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_VectorWithAllConstConstructors) {
// vec3<f32>(1.0, 2.0, 3.0) -> true
- auto* t = vec3<f32>(1.f, 2.f, 3.f);
+ auto* t = vec3<f32>(1_f, 2_f, 3_f);
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1770,8 +1770,8 @@
// array<vec3<f32>, 2u>(vec3<f32>(1.0, 2.0, 3.0), vec3<f32>(1.0, 2.0, 3.0))
// -> true
- auto* first = vec3<f32>(1.f, 2.f, 3.f);
- auto* second = vec3<f32>(1.f, 2.f, 3.f);
+ auto* first = vec3<f32>(1_f, 2_f, 3_f);
+ auto* second = vec3<f32>(1_f, 2_f, 3_f);
auto* t = Construct(ty.array(ty.vec3<f32>(), 2_u), first, second);
WrapInFunction(t);
@@ -1810,7 +1810,7 @@
Member("b", ty.vec3<f32>()),
});
- auto* t = Construct(ty.Of(s), 2.f, vec3<f32>(2.f, 2.f, 2.f));
+ auto* t = Construct(ty.Of(s), 2_f, vec3<f32>(2_f, 2_f, 2_f));
WrapInFunction(t);
spirv::Builder& b = Build();
@@ -1843,8 +1843,8 @@
// }
// let y = vec3<f32>(1.0, 2.0, 3.0); // Reuses the ID 'x'
- WrapInFunction(If(true, Block(Decl(Let("x", nullptr, vec3<f32>(1.f, 2.f, 3.f))))),
- Decl(Let("y", nullptr, vec3<f32>(1.f, 2.f, 3.f))));
+ WrapInFunction(If(true, Block(Decl(Let("x", nullptr, vec3<f32>(1_f, 2_f, 3_f))))),
+ Decl(Let("y", nullptr, vec3<f32>(1_f, 2_f, 3_f))));
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
@@ -1887,9 +1887,9 @@
// }
// let y = vec3<f32>(one, 2.0, 3.0); // Mustn't reuse the ID 'x'
- WrapInFunction(Decl(Var("one", nullptr, Expr(1.f))),
- If(true, Block(Decl(Let("x", nullptr, vec3<f32>("one", 2.f, 3.f))))),
- Decl(Let("y", nullptr, vec3<f32>("one", 2.f, 3.f))));
+ WrapInFunction(Decl(Var("one", nullptr, Expr(1_f))),
+ If(true, Block(Decl(Let("x", nullptr, vec3<f32>("one", 2_f, 3_f))))),
+ Decl(Let("y", nullptr, vec3<f32>("one", 2_f, 3_f))));
spirv::Builder& b = SanitizeAndBuild();
ASSERT_TRUE(b.Build());
diff --git a/src/tint/writer/spirv/builder_entry_point_test.cc b/src/tint/writer/spirv/builder_entry_point_test.cc
index a38bb8e..50398a3 100644
--- a/src/tint/writer/spirv/builder_entry_point_test.cc
+++ b/src/tint/writer/spirv/builder_entry_point_test.cc
@@ -118,8 +118,8 @@
create<ast::BinaryExpression>(ast::BinaryOp::kGreaterThan, Expr("loc_in"), Expr(10_u));
Func("frag_main", ast::VariableList{loc_in}, ty.f32(),
ast::StatementList{
- If(cond, Block(Return(0.5f))),
- Return(1.0f),
+ If(cond, Block(Return(0.5_f))),
+ Return(1_f),
},
ast::AttributeList{
Stage(ast::PipelineStage::kFragment),
@@ -204,7 +204,7 @@
Member("pos", ty.vec4<f32>(), ast::AttributeList{Builtin(ast::Builtin::kPosition)}),
});
- auto* vert_retval = Construct(ty.Of(interface), 42.f, Construct(ty.vec4<f32>()));
+ auto* vert_retval = Construct(ty.Of(interface), 42_f, Construct(ty.vec4<f32>()));
Func("vert_main", ast::VariableList{}, ty.Of(interface), {Return(vert_retval)},
{Stage(ast::PipelineStage::kVertex)});
diff --git a/src/tint/writer/spirv/builder_function_attribute_test.cc b/src/tint/writer/spirv/builder_function_attribute_test.cc
index f4fdf6e..e5bb43d 100644
--- a/src/tint/writer/spirv/builder_function_attribute_test.cc
+++ b/src/tint/writer/spirv/builder_function_attribute_test.cc
@@ -244,7 +244,7 @@
TEST_F(BuilderTest, Decoration_ExecutionMode_FragDepth) {
Func("main", ast::VariableList{}, ty.f32(),
ast::StatementList{
- Return(Expr(1.f)),
+ Return(Expr(1_f)),
},
ast::AttributeList{Stage(ast::PipelineStage::kFragment)},
ast::AttributeList{
diff --git a/src/tint/writer/spirv/builder_function_variable_test.cc b/src/tint/writer/spirv/builder_function_variable_test.cc
index a3989a0..da72233 100644
--- a/src/tint/writer/spirv/builder_function_variable_test.cc
+++ b/src/tint/writer/spirv/builder_function_variable_test.cc
@@ -15,6 +15,8 @@
#include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::spirv {
namespace {
@@ -42,7 +44,7 @@
}
TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
- auto* init = vec3<f32>(1.f, 1.f, 3.f);
+ auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = Var("var", ty.vec3<f32>(), ast::StorageClass::kFunction, init);
WrapInFunction(v);
@@ -71,7 +73,7 @@
}
TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) {
- auto* init = vec2<f32>(1.f, Add(3.f, 3.f));
+ auto* init = vec2<f32>(1_f, Add(3_f, 3_f));
auto* v = Var("var", ty.vec2<f32>(), ast::StorageClass::kNone, init);
WrapInFunction(v);
@@ -105,7 +107,7 @@
// var v : f32 = 1.0;
// var v2 : f32 = v; // Should generate the load and store automatically.
- auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1.f));
+ auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
auto* v2 = Var("v2", ty.f32(), ast::StorageClass::kNone, Expr("v"));
WrapInFunction(v, v2);
@@ -140,7 +142,7 @@
// var v : f32 = 1.0;
// let v2 : f32 = v; // Should generate the load
- auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1.f));
+ auto* v = Var("v", ty.f32(), ast::StorageClass::kNone, Expr(1_f));
auto* v2 = Var("v2", ty.f32(), ast::StorageClass::kNone, Expr("v"));
WrapInFunction(v, v2);
@@ -172,7 +174,7 @@
}
TEST_F(BuilderTest, FunctionVar_Const) {
- auto* init = vec3<f32>(1.f, 1.f, 3.f);
+ auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = Let("var", ty.vec3<f32>(), init);
diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc
index 727c573..249c048 100644
--- a/src/tint/writer/spirv/builder_global_variable_test.cc
+++ b/src/tint/writer/spirv/builder_global_variable_test.cc
@@ -17,6 +17,8 @@
#include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::spirv {
namespace {
@@ -38,7 +40,7 @@
}
TEST_F(BuilderTest, GlobalVar_WithConstructor) {
- auto* init = vec3<f32>(1.f, 1.f, 3.f);
+ auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate, init);
@@ -60,7 +62,7 @@
}
TEST_F(BuilderTest, GlobalVar_Const) {
- auto* init = vec3<f32>(1.f, 1.f, 3.f);
+ auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
@@ -80,7 +82,7 @@
}
TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
- auto* init = vec3<f32>(ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)});
+ auto* init = vec3<f32>(1_f, 2_f, 3_f);
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
@@ -99,7 +101,7 @@
}
TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
- auto* init = vec3<f32>(vec2<f32>(1.f, 2.f), 3.f);
+ auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
@@ -201,7 +203,7 @@
}
TEST_F(BuilderTest, GlobalVar_Override_Scalar) {
- auto* v = Override("var", ty.f32(), Expr(2.f),
+ auto* v = Override("var", ty.f32(), Expr(2_f),
ast::AttributeList{
Id(0),
});
diff --git a/src/tint/writer/spirv/builder_ident_expression_test.cc b/src/tint/writer/spirv/builder_ident_expression_test.cc
index 540b5c1..e2e9826 100644
--- a/src/tint/writer/spirv/builder_ident_expression_test.cc
+++ b/src/tint/writer/spirv/builder_ident_expression_test.cc
@@ -23,7 +23,7 @@
using BuilderTest = TestHelper;
TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
- auto* init = vec3<f32>(1.f, 1.f, 3.f);
+ auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
@@ -67,7 +67,7 @@
}
TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
- auto* init = vec3<f32>(1.f, 1.f, 3.f);
+ auto* init = vec3<f32>(1_f, 1_f, 3_f);
auto* v = Let("var", ty.vec3<f32>(), init);
diff --git a/src/tint/writer/spirv/builder_return_test.cc b/src/tint/writer/spirv/builder_return_test.cc
index 635db28..0027311 100644
--- a/src/tint/writer/spirv/builder_return_test.cc
+++ b/src/tint/writer/spirv/builder_return_test.cc
@@ -15,6 +15,8 @@
#include "src/tint/writer/spirv/spv_dump.h"
#include "src/tint/writer/spirv/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::spirv {
namespace {
@@ -35,7 +37,7 @@
}
TEST_F(BuilderTest, Return_WithValue) {
- auto* val = vec3<f32>(1.f, 1.f, 3.f);
+ auto* val = vec3<f32>(1_f, 1_f, 3_f);
auto* ret = Return(val);
Func("test", {}, ty.vec3<f32>(), {ret}, {});
diff --git a/src/tint/writer/spirv/builder_unary_op_expression_test.cc b/src/tint/writer/spirv/builder_unary_op_expression_test.cc
index c34ae32..fa80828 100644
--- a/src/tint/writer/spirv/builder_unary_op_expression_test.cc
+++ b/src/tint/writer/spirv/builder_unary_op_expression_test.cc
@@ -39,7 +39,7 @@
}
TEST_F(BuilderTest, UnaryOp_Negation_Float) {
- auto* expr = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr(1.f));
+ auto* expr = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr(1_f));
WrapInFunction(expr);
spirv::Builder& b = Build();
diff --git a/src/tint/writer/wgsl/generator_impl_call_test.cc b/src/tint/writer/wgsl/generator_impl_call_test.cc
index 0736ad8..6a7e077 100644
--- a/src/tint/writer/wgsl/generator_impl_call_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_call_test.cc
@@ -15,13 +15,15 @@
#include "src/tint/ast/call_statement.h"
#include "src/tint/writer/wgsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::wgsl {
namespace {
using WgslGeneratorImplTest = TestHelper;
TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
- Func("my_func", {}, ty.f32(), {Return(1.23f)});
+ Func("my_func", {}, ty.f32(), {Return(1.23_f)});
auto* call = Call("my_func");
WrapInFunction(call);
@@ -39,7 +41,7 @@
Param(Sym(), ty.f32()),
Param(Sym(), ty.f32()),
},
- ty.f32(), {Return(1.23f)});
+ ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
diff --git a/src/tint/writer/wgsl/generator_impl_constructor_test.cc b/src/tint/writer/wgsl/generator_impl_constructor_test.cc
index 5776883..7a147c2 100644
--- a/src/tint/writer/wgsl/generator_impl_constructor_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_constructor_test.cc
@@ -62,7 +62,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Float) {
- WrapInFunction(Construct<f32>(Expr(-1.2e-5f)));
+ WrapInFunction(Construct<f32>(Expr(-1.2e-5_f)));
GeneratorImpl& gen = Build();
@@ -98,7 +98,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Vec) {
- WrapInFunction(vec3<f32>(1.f, 2.f, 3.f));
+ WrapInFunction(vec3<f32>(1_f, 2_f, 3_f));
GeneratorImpl& gen = Build();
@@ -107,7 +107,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Mat) {
- WrapInFunction(mat2x3<f32>(vec3<f32>(1.f, 2.f, 3.f), vec3<f32>(3.f, 4.f, 5.f)));
+ WrapInFunction(mat2x3<f32>(vec3<f32>(1_f, 2_f, 3_f), vec3<f32>(3_f, 4_f, 5_f)));
GeneratorImpl& gen = Build();
@@ -117,8 +117,8 @@
}
TEST_F(WgslGeneratorImplTest, EmitConstructor_Type_Array) {
- WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1.0f, 2.0f, 3.0f),
- vec3<f32>(4.0f, 5.0f, 6.0f), vec3<f32>(7.0f, 8.0f, 9.0f)));
+ WrapInFunction(Construct(ty.array(ty.vec3<f32>(), 3_u), vec3<f32>(1_f, 2_f, 3_f),
+ vec3<f32>(4_f, 5_f, 6_f), vec3<f32>(7_f, 8_f, 9_f)));
GeneratorImpl& gen = Build();
diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc
index 79a95d5..da91948 100644
--- a/src/tint/writer/wgsl/generator_impl_function_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_function_test.cc
@@ -123,7 +123,7 @@
TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_ReturnValue) {
auto* func = Func("frag_main", ast::VariableList{}, ty.f32(),
ast::StatementList{
- Return(1.f),
+ Return(1_f),
},
ast::AttributeList{
Stage(ast::PipelineStage::kFragment),
diff --git a/src/tint/writer/wgsl/generator_impl_literal_test.cc b/src/tint/writer/wgsl/generator_impl_literal_test.cc
index 64d97a4..353bd36 100644
--- a/src/tint/writer/wgsl/generator_impl_literal_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_literal_test.cc
@@ -16,6 +16,8 @@
#include "src/tint/writer/wgsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::wgsl {
namespace {
@@ -23,7 +25,7 @@
// - 0 sign if sign is 0, 1 otherwise
// - 'exponent_bits' is placed in the exponent space.
// So, the exponent bias must already be included.
-float MakeFloat(int sign, int biased_exponent, int mantissa) {
+f32 MakeFloat(int sign, int biased_exponent, int mantissa) {
const uint32_t sign_bit = sign ? 0x80000000u : 0u;
// The binary32 exponent is 8 bits, just below the sign.
const uint32_t exponent_bits = (biased_exponent & 0xffu) << 23;
@@ -35,11 +37,11 @@
static_assert(sizeof(result) == sizeof(bits),
"expected float and uint32_t to be the same size");
std::memcpy(&result, &bits, sizeof(bits));
- return result;
+ return f32(result);
}
struct FloatData {
- float value;
+ f32 value;
std::string expected;
};
inline std::ostream& operator<<(std::ostream& out, FloatData data) {
@@ -62,15 +64,15 @@
INSTANTIATE_TEST_SUITE_P(Zero,
WgslGenerator_FloatLiteralTest,
- ::testing::ValuesIn(std::vector<FloatData>{{0.0f, "0.0"},
+ ::testing::ValuesIn(std::vector<FloatData>{{0_f, "0.0"},
{MakeFloat(0, 0, 0), "0.0"},
{MakeFloat(1, 0, 0), "-0.0"}}));
INSTANTIATE_TEST_SUITE_P(Normal,
WgslGenerator_FloatLiteralTest,
- ::testing::ValuesIn(std::vector<FloatData>{{1.0f, "1.0"},
- {-1.0f, "-1.0"},
- {101.375, "101.375"}}));
+ ::testing::ValuesIn(std::vector<FloatData>{{1_f, "1.0"},
+ {-1_f, "-1.0"},
+ {101.375_f, "101.375"}}));
INSTANTIATE_TEST_SUITE_P(Subnormal,
WgslGenerator_FloatLiteralTest,
diff --git a/src/tint/writer/wgsl/generator_impl_variable_test.cc b/src/tint/writer/wgsl/generator_impl_variable_test.cc
index 8ebe6c5..80f6259 100644
--- a/src/tint/writer/wgsl/generator_impl_variable_test.cc
+++ b/src/tint/writer/wgsl/generator_impl_variable_test.cc
@@ -14,6 +14,8 @@
#include "src/tint/writer/wgsl/test_helper.h"
+using namespace tint::number_suffixes; // NOLINT
+
namespace tint::writer::wgsl {
namespace {
@@ -99,7 +101,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
- auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(1.0f));
+ auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f));
GeneratorImpl& gen = Build();
@@ -109,7 +111,7 @@
}
TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
- auto* v = Let("a", ty.f32(), Expr(1.0f));
+ auto* v = Let("a", ty.f32(), Expr(1_f));
WrapInFunction(Decl(v));
GeneratorImpl& gen = Build();