ProgramBuilder: Remove Literal() helpers
Now that all LiteralExpressions derive from Expression, and Expr() already handles literals, there's no reason to have this duplicated functionality. Bug: tint:888 Change-Id: I677b04a3cc325311ef25f6b9983fee7548e830f4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/69105 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
9de93ca105
commit
2194a842ba
|
@ -66,7 +66,7 @@ TEST_F(SwitchStatementTest, Assert_Null_Condition) {
|
|||
ProgramBuilder b;
|
||||
CaseStatementList cases;
|
||||
cases.push_back(
|
||||
b.create<CaseStatement>(CaseSelectorList{b.Literal(1)}, b.Block()));
|
||||
b.create<CaseStatement>(CaseSelectorList{b.Expr(1)}, b.Block()));
|
||||
b.create<SwitchStatement>(nullptr, cases);
|
||||
},
|
||||
"internal compiler error");
|
||||
|
@ -89,7 +89,7 @@ TEST_F(SwitchStatementTest, Assert_DifferentProgramID_Condition) {
|
|||
b1.create<SwitchStatement>(b2.Expr(true), CaseStatementList{
|
||||
b1.create<CaseStatement>(
|
||||
CaseSelectorList{
|
||||
b1.Literal(1),
|
||||
b1.Expr(1),
|
||||
},
|
||||
b1.Block()),
|
||||
});
|
||||
|
@ -105,7 +105,7 @@ TEST_F(SwitchStatementTest, Assert_DifferentProgramID_CaseStatement) {
|
|||
b1.create<SwitchStatement>(b1.Expr(true), CaseStatementList{
|
||||
b2.create<CaseStatement>(
|
||||
CaseSelectorList{
|
||||
b2.Literal(1),
|
||||
b2.Expr(1),
|
||||
},
|
||||
b2.Block()),
|
||||
});
|
||||
|
|
|
@ -1037,7 +1037,7 @@ class ProgramBuilder {
|
|||
/// @param source the source information
|
||||
/// @param value the boolean value
|
||||
/// @return a Scalar constructor for the given value
|
||||
const ast::LiteralExpression* Expr(const Source& source, bool value) {
|
||||
const ast::BoolLiteralExpression* Expr(const Source& source, bool value) {
|
||||
return create<ast::BoolLiteralExpression>(source, value);
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1063,7 @@ class ProgramBuilder {
|
|||
/// @param source the source information
|
||||
/// @param value the integer value
|
||||
/// @return a Scalar constructor for the given value
|
||||
const ast::LiteralExpression* Expr(const Source& source, i32 value) {
|
||||
const ast::SintLiteralExpression* Expr(const Source& source, i32 value) {
|
||||
return create<ast::SintLiteralExpression>(source, value);
|
||||
}
|
||||
|
||||
|
@ -1124,58 +1124,6 @@ class ProgramBuilder {
|
|||
/// @return `list`
|
||||
ast::ExpressionList ExprList(ast::ExpressionList list) { return list; }
|
||||
|
||||
/// @param source the source location for the literal
|
||||
/// @param val the boolan value
|
||||
/// @return a boolean literal with the given value
|
||||
const ast::BoolLiteralExpression* Literal(const Source& source, bool val) {
|
||||
return create<ast::BoolLiteralExpression>(source, val);
|
||||
}
|
||||
|
||||
/// @param val the boolan value
|
||||
/// @return a boolean literal with the given value
|
||||
const ast::BoolLiteralExpression* Literal(bool val) {
|
||||
return create<ast::BoolLiteralExpression>(val);
|
||||
}
|
||||
|
||||
/// @param source the source location for the literal
|
||||
/// @param val the float value
|
||||
/// @return a float literal with the given value
|
||||
const ast::FloatLiteralExpression* Literal(const Source& source, f32 val) {
|
||||
return create<ast::FloatLiteralExpression>(source, val);
|
||||
}
|
||||
|
||||
/// @param val the float value
|
||||
/// @return a float literal with the given value
|
||||
const ast::FloatLiteralExpression* Literal(f32 val) {
|
||||
return create<ast::FloatLiteralExpression>(val);
|
||||
}
|
||||
|
||||
/// @param source the source location for the literal
|
||||
/// @param val the unsigned int value
|
||||
/// @return a ast::UintLiteral with the given value
|
||||
const ast::UintLiteralExpression* Literal(const Source& source, u32 val) {
|
||||
return create<ast::UintLiteralExpression>(source, val);
|
||||
}
|
||||
|
||||
/// @param val the unsigned int value
|
||||
/// @return a ast::UintLiteral with the given value
|
||||
const ast::UintLiteralExpression* Literal(u32 val) {
|
||||
return create<ast::UintLiteralExpression>(val);
|
||||
}
|
||||
|
||||
/// @param source the source location for the literal
|
||||
/// @param val the integer value
|
||||
/// @return the ast::SintLiteral with the given value
|
||||
const ast::SintLiteralExpression* Literal(const Source& source, i32 val) {
|
||||
return create<ast::SintLiteralExpression>(source, val);
|
||||
}
|
||||
|
||||
/// @param val the integer value
|
||||
/// @return the ast::SintLiteral with the given value
|
||||
const ast::SintLiteralExpression* Literal(i32 val) {
|
||||
return create<ast::SintLiteralExpression>(val);
|
||||
}
|
||||
|
||||
/// @param args the arguments for the type constructor
|
||||
/// @return an `ast::TypeConstructorExpression` of type `ty`, with the values
|
||||
/// of `args` converted to `ast::Expression`s using `Expr()`
|
||||
|
|
|
@ -318,9 +318,8 @@ TEST_F(ResolverCompoundStatementTest, Switch) {
|
|||
auto* stmt_a = Ignore(1);
|
||||
auto* stmt_b = Ignore(1);
|
||||
auto* stmt_c = Ignore(1);
|
||||
auto* swi =
|
||||
Switch(expr, Case(Literal(1), Block(stmt_a)),
|
||||
Case(Literal(2), Block(stmt_b)), DefaultCase(Block(stmt_c)));
|
||||
auto* swi = Switch(expr, Case(Expr(1), Block(stmt_a)),
|
||||
Case(Expr(2), Block(stmt_b)), DefaultCase(Block(stmt_c)));
|
||||
WrapInFunction(swi);
|
||||
|
||||
ASSERT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
|
|
@ -52,7 +52,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchWithoutDefault_Fail) {
|
|||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch(Source{{12, 34}}, "a", //
|
||||
Case(Literal(1))));
|
||||
Case(Expr(1))));
|
||||
|
||||
WrapInFunction(block);
|
||||
|
||||
|
@ -70,10 +70,10 @@ TEST_F(ResolverControlBlockValidationTest, SwitchWithTwoDefault_Fail) {
|
|||
// }
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
DefaultCase(), //
|
||||
Case(Literal(1)), //
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
DefaultCase(), //
|
||||
Case(Expr(1)), //
|
||||
DefaultCase(Source{{12, 34}})));
|
||||
|
||||
WrapInFunction(block);
|
||||
|
@ -155,9 +155,9 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break) {
|
|||
auto* decl = Decl(Source{{12, 34}},
|
||||
Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2)));
|
||||
|
||||
WrapInFunction( //
|
||||
Loop(Block(Switch(1, //
|
||||
Case(Literal(1), Block(Break(), decl)), //
|
||||
WrapInFunction( //
|
||||
Loop(Block(Switch(1, //
|
||||
Case(Expr(1), Block(Break(), decl)), //
|
||||
DefaultCase()))));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -176,7 +176,7 @@ TEST_F(ResolverControlBlockValidationTest, UnreachableCode_break_InBlocks) {
|
|||
|
||||
WrapInFunction(Loop(
|
||||
Block(Switch(1, //
|
||||
Case(Literal(1), Block(Block(Block(Block(Break()))), decl)),
|
||||
Case(Expr(1), Block(Block(Block(Block(Break()))), decl)),
|
||||
DefaultCase()))));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -192,10 +192,9 @@ TEST_F(ResolverControlBlockValidationTest,
|
|||
// }
|
||||
auto* var = Var("a", ty.i32(), ast::StorageClass::kNone, Expr(2));
|
||||
|
||||
auto* block =
|
||||
Block(Decl(var), Switch("a", //
|
||||
Case(Source{{12, 34}}, {Literal(1u)}), //
|
||||
DefaultCase()));
|
||||
auto* block = Block(Decl(var), Switch("a", //
|
||||
Case(Source{{12, 34}}, {Expr(1u)}), //
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -213,9 +212,9 @@ TEST_F(ResolverControlBlockValidationTest,
|
|||
// }
|
||||
auto* var = Var("a", ty.u32(), ast::StorageClass::kNone, Expr(2u));
|
||||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Source{{12, 34}}, {Literal(-1)}), //
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Source{{12, 34}}, {Expr(-1)}), //
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
|
||||
|
@ -237,11 +236,11 @@ TEST_F(ResolverControlBlockValidationTest,
|
|||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Literal(0u)),
|
||||
Case(Expr(0u)),
|
||||
Case({
|
||||
Literal(Source{{12, 34}}, 2u),
|
||||
Literal(3u),
|
||||
Literal(Source{{56, 78}}, 2u),
|
||||
Expr(Source{{12, 34}}, 2u),
|
||||
Expr(3u),
|
||||
Expr(Source{{56, 78}}, 2u),
|
||||
}),
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
|
@ -264,12 +263,12 @@ TEST_F(ResolverControlBlockValidationTest,
|
|||
|
||||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
Case(Literal(Source{{12, 34}}, -10)),
|
||||
Case(Expr(Source{{12, 34}}, -10)),
|
||||
Case({
|
||||
Literal(0),
|
||||
Literal(1),
|
||||
Literal(2),
|
||||
Literal(Source{{56, 78}}, -10),
|
||||
Expr(0),
|
||||
Expr(1),
|
||||
Expr(2),
|
||||
Expr(Source{{56, 78}}, -10),
|
||||
}),
|
||||
DefaultCase()));
|
||||
WrapInFunction(block);
|
||||
|
@ -310,7 +309,7 @@ TEST_F(ResolverControlBlockValidationTest, SwitchCase_Pass) {
|
|||
auto* block = Block(Decl(var), //
|
||||
Switch("a", //
|
||||
DefaultCase(Source{{12, 34}}), //
|
||||
Case(Literal(5))));
|
||||
Case(Expr(5))));
|
||||
WrapInFunction(block);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
|
|
@ -582,7 +582,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_BadType) {
|
|||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Literal(Source{{12, 34}}, 64.f))});
|
||||
WorkgroupSize(Expr(Source{{12, 34}}, 64.f))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -596,7 +596,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_Negative) {
|
|||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Literal(Source{{12, 34}}, -2))});
|
||||
WorkgroupSize(Expr(Source{{12, 34}}, -2))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -609,7 +609,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Literal_Zero) {
|
|||
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute),
|
||||
WorkgroupSize(Literal(Source{{12, 34}}, 0))});
|
||||
WorkgroupSize(Expr(Source{{12, 34}}, 0))});
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
|
|
@ -248,7 +248,7 @@ TEST_F(ResolverTest, Stmt_Switch) {
|
|||
auto* lhs = Expr("v");
|
||||
auto* rhs = Expr(2.3f);
|
||||
auto* case_block = Block(Assign(lhs, rhs));
|
||||
auto* stmt = Switch(Expr(2), Case(Literal(3), case_block), DefaultCase());
|
||||
auto* stmt = Switch(Expr(2), Case(Expr(3), case_block), DefaultCase());
|
||||
WrapInFunction(v, stmt);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
|
|
@ -424,7 +424,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_type_match) {
|
||||
// array<u32, 3>(0u, 10u. 20u);
|
||||
auto* tc = array<u32, 3>(Literal(0u), Literal(10u), Literal(20u));
|
||||
auto* tc = array<u32, 3>(Expr(0u), Expr(10u), Expr(20u));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve());
|
||||
|
@ -433,8 +433,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_type_Mismatch_U32F32) {
|
||||
// array<u32, 3>(0u, 1.0f, 20u);
|
||||
auto* tc =
|
||||
array<u32, 3>(Literal(0u), Literal(Source{{12, 34}}, 1.0f), Literal(20u));
|
||||
auto* tc = array<u32, 3>(Expr(0u), Expr(Source{{12, 34}}, 1.0f), Expr(20u));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -446,7 +445,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_ScalarArgumentTypeMismatch_F32I32) {
|
||||
// array<f32, 1>(1);
|
||||
auto* tc = array<f32, 1>(Literal(Source{{12, 34}}, 1));
|
||||
auto* tc = array<f32, 1>(Expr(Source{{12, 34}}, 1));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -458,8 +457,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_ScalarArgumentTypeMismatch_U32I32) {
|
||||
// array<u32, 6>(1, 0u, 0u, 0u, 0u, 0u);
|
||||
auto* tc = array<u32, 1>(Literal(Source{{12, 34}}, 1), Literal(0u),
|
||||
Literal(0u), Literal(0u), Literal(0u));
|
||||
auto* tc = array<u32, 1>(Expr(Source{{12, 34}}, 1), Expr(0u), Expr(0u),
|
||||
Expr(0u), Expr(0u));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -471,9 +470,9 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Array_ScalarArgumentTypeMismatch_Vec2) {
|
||||
// array<i32, 3>(1, vec2<i32>());
|
||||
auto* tc = array<i32, 3>(Literal(1),
|
||||
create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<i32>(), ExprList()));
|
||||
auto* tc =
|
||||
array<i32, 3>(Expr(1), create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<i32>(), ExprList()));
|
||||
WrapInFunction(tc);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -545,7 +544,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
Expr_Constructor_Array_TooFewElements) {
|
||||
// array<i32, 4>(1, 2, 3);
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* tc = array<i32, 4>(Literal(1), Literal(2), Literal(3));
|
||||
auto* tc = array<i32, 4>(Expr(1), Expr(2), Expr(3));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -558,8 +557,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
Expr_Constructor_Array_TooManyElements) {
|
||||
// array<i32, 4>(1, 2, 3, 4, 5);
|
||||
SetSource(Source::Location({12, 34}));
|
||||
auto* tc =
|
||||
array<i32, 4>(Literal(1), Literal(2), Literal(3), Literal(4), Literal(5));
|
||||
auto* tc = array<i32, 4>(Expr(1), Expr(2), Expr(3), Expr(4), Expr(5));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -571,7 +569,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Array_Runtime) {
|
||||
// array<i32>(1);
|
||||
auto* tc = array(ty.i32(), nullptr, Literal(Source{{12, 34}}, 1));
|
||||
auto* tc = array(ty.i32(), nullptr, Expr(Source{{12, 34}}, 1));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -594,7 +592,7 @@ namespace VectorConstructor {
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2F32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<f32>(Literal(Source{{12, 34}}, 1), 1.0f);
|
||||
auto* tc = vec2<f32>(Expr(Source{{12, 34}}, 1), 1.0f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -605,7 +603,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2U32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<u32>(1u, Literal(Source{{12, 34}}, 1));
|
||||
auto* tc = vec2<u32>(1u, Expr(Source{{12, 34}}, 1));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -616,7 +614,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2I32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<i32>(Literal(Source{{12, 34}}, 1u), 1);
|
||||
auto* tc = vec2<i32>(Expr(Source{{12, 34}}, 1u), 1);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -627,7 +625,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2Bool_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec2<bool>(true, Literal(Source{{12, 34}}, 1));
|
||||
auto* tc = vec2<bool>(true, Expr(Source{{12, 34}}, 1));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -662,9 +660,9 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec2_Error_TooManyArgumentsScalar) {
|
||||
auto* tc = vec2<f32>(Literal(Source{{12, 34}}, 1.0f),
|
||||
Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f));
|
||||
auto* tc =
|
||||
vec2<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
|
||||
Expr(Source{{12, 46}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -691,7 +689,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
Expr_Constructor_Vec2_Error_TooManyArgumentsVectorAndScalar) {
|
||||
auto* tc = vec2<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
Literal(Source{{12, 40}}, 1.0f));
|
||||
Expr(Source{{12, 40}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -805,7 +803,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3F32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<f32>(1.0f, 1.0f, Literal(Source{{12, 34}}, 1));
|
||||
auto* tc = vec3<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -816,7 +814,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3U32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<u32>(1u, Literal(Source{{12, 34}}, 1), 1u);
|
||||
auto* tc = vec3<u32>(1u, Expr(Source{{12, 34}}, 1), 1u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -827,7 +825,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3I32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<i32>(1, Literal(Source{{12, 34}}, 1u), 1);
|
||||
auto* tc = vec3<i32>(1, Expr(Source{{12, 34}}, 1u), 1);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -838,7 +836,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3Bool_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec3<bool>(true, Literal(Source{{12, 34}}, 1), false);
|
||||
auto* tc = vec3<bool>(true, Expr(Source{{12, 34}}, 1), false);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -861,8 +859,8 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3_Error_TooFewArgumentsScalar) {
|
||||
auto* tc = vec3<f32>(Literal(Source{{12, 34}}, 1.0f),
|
||||
Literal(Source{{12, 40}}, 1.0f));
|
||||
auto* tc =
|
||||
vec3<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -873,9 +871,9 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3_Error_TooManyArgumentsScalar) {
|
||||
auto* tc = vec3<f32>(
|
||||
Literal(Source{{12, 34}}, 1.0f), Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f), Literal(Source{{12, 52}}, 1.0f));
|
||||
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));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -912,10 +910,10 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec3_Error_TooManyArgumentsVec2AndScalar) {
|
||||
auto* tc = vec3<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f));
|
||||
auto* tc =
|
||||
vec3<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
Expr(Source{{12, 40}}, 1.0f), Expr(Source{{12, 46}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -928,7 +926,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
Expr_Constructor_Vec3_Error_TooManyArgumentsVec3) {
|
||||
auto* tc = vec3<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec3<f32>(), ExprList()),
|
||||
Literal(Source{{12, 40}}, 1.0f));
|
||||
Expr(Source{{12, 40}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1068,7 +1066,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4F32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<f32>(1.0f, 1.0f, Literal(Source{{12, 34}}, 1), 1.0f);
|
||||
auto* tc = vec4<f32>(1.0f, 1.0f, Expr(Source{{12, 34}}, 1), 1.0f);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1079,7 +1077,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4U32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<u32>(1u, 1u, Literal(Source{{12, 34}}, 1), 1u);
|
||||
auto* tc = vec4<u32>(1u, 1u, Expr(Source{{12, 34}}, 1), 1u);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1090,7 +1088,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4I32_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<i32>(1, 1, Literal(Source{{12, 34}}, 1u), 1);
|
||||
auto* tc = vec4<i32>(1, 1, Expr(Source{{12, 34}}, 1u), 1);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1101,7 +1099,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4Bool_Error_ScalarArgumentTypeMismatch) {
|
||||
auto* tc = vec4<bool>(true, false, Literal(Source{{12, 34}}, 1), true);
|
||||
auto* tc = vec4<bool>(true, false, Expr(Source{{12, 34}}, 1), true);
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1112,9 +1110,9 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4_Error_TooFewArgumentsScalar) {
|
||||
auto* tc = vec4<f32>(Literal(Source{{12, 34}}, 1.0f),
|
||||
Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f));
|
||||
auto* tc =
|
||||
vec4<f32>(Expr(Source{{12, 34}}, 1.0f), Expr(Source{{12, 40}}, 1.0f),
|
||||
Expr(Source{{12, 46}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1125,10 +1123,10 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4_Error_TooManyArgumentsScalar) {
|
||||
auto* tc = vec4<f32>(
|
||||
Literal(Source{{12, 34}}, 1.0f), Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f), Literal(Source{{12, 52}}, 1.0f),
|
||||
Literal(Source{{12, 58}}, 1.0f));
|
||||
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));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1141,7 +1139,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
Expr_Constructor_Vec4_Error_TooFewArgumentsVec2AndScalar) {
|
||||
auto* tc = vec4<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
Literal(Source{{12, 40}}, 1.0f));
|
||||
Expr(Source{{12, 40}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1152,11 +1150,11 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4_Error_TooManyArgumentsVec2AndScalars) {
|
||||
auto* tc = vec4<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f),
|
||||
Literal(Source{{12, 52}}, 1.0f));
|
||||
auto* tc =
|
||||
vec4<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
Expr(Source{{12, 40}}, 1.0f), Expr(Source{{12, 46}}, 1.0f),
|
||||
Expr(Source{{12, 52}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1171,7 +1169,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
Source{{12, 34}}, ty.vec2<f32>(), ExprList()),
|
||||
create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 40}}, ty.vec2<f32>(), ExprList()),
|
||||
Literal(Source{{12, 46}}, 1.0f));
|
||||
Expr(Source{{12, 46}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1210,10 +1208,10 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
|
||||
TEST_F(ResolverTypeConstructorValidationTest,
|
||||
Expr_Constructor_Vec4_Error_TooManyArgumentsVec3AndScalars) {
|
||||
auto* tc = vec4<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec3<f32>(), ExprList()),
|
||||
Literal(Source{{12, 40}}, 1.0f),
|
||||
Literal(Source{{12, 46}}, 1.0f));
|
||||
auto* tc =
|
||||
vec4<f32>(create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, ty.vec3<f32>(), ExprList()),
|
||||
Expr(Source{{12, 40}}, 1.0f), Expr(Source{{12, 46}}, 1.0f));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1505,8 +1503,7 @@ TEST_F(ResolverTypeConstructorValidationTest,
|
|||
// vec2<Float32>(1.0f, 1u)
|
||||
auto* vec_type = ty.vec(ty.Of(f32_alias), 2);
|
||||
auto* tc = create<ast::TypeConstructorExpression>(
|
||||
Source{{12, 34}}, vec_type,
|
||||
ExprList(1.0f, Literal(Source{{12, 40}}, 1u)));
|
||||
Source{{12, 34}}, vec_type, ExprList(1.0f, Expr(Source{{12, 40}}, 1u)));
|
||||
WrapInFunction(tc);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
@ -1696,7 +1693,7 @@ TEST_P(MatrixConstructorTest,
|
|||
|
||||
ast::ExpressionList args;
|
||||
for (uint32_t i = 1; i <= param.columns; i++) {
|
||||
args.push_back(Literal(Source{{12, i}}, 1u));
|
||||
args.push_back(Expr(Source{{12, i}}, 1u));
|
||||
}
|
||||
|
||||
auto* matrix_type = ty.mat<f32>(param.columns, param.rows);
|
||||
|
|
|
@ -129,7 +129,7 @@ TEST_F(ResolverValidationTest, Stmt_Error_Unknown) {
|
|||
TEST_F(ResolverValidationTest, Stmt_If_NonBool) {
|
||||
// if (1.23f) {}
|
||||
|
||||
WrapInFunction(If(Literal(Source{{12, 34}}, 1.23f), Block()));
|
||||
WrapInFunction(If(Expr(Source{{12, 34}}, 1.23f), Block()));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
||||
|
@ -141,7 +141,7 @@ TEST_F(ResolverValidationTest, Stmt_Else_NonBool) {
|
|||
// else (1.23f) {}
|
||||
|
||||
WrapInFunction(
|
||||
If(Expr(true), Block(), Else(Literal(Source{{12, 34}}, 1.23f), Block())));
|
||||
If(Expr(true), Block(), Else(Expr(Source{{12, 34}}, 1.23f), Block())));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
|
||||
|
@ -931,7 +931,7 @@ TEST_F(ResolverValidationTest, Stmt_BreakInLoop) {
|
|||
TEST_F(ResolverValidationTest, Stmt_BreakInSwitch) {
|
||||
WrapInFunction(Loop(Block(Switch(
|
||||
Expr(1),
|
||||
Case(Literal(1), Block(create<ast::BreakStatement>(Source{{12, 34}}))),
|
||||
Case(Expr(1), Block(create<ast::BreakStatement>(Source{{12, 34}}))),
|
||||
DefaultCase()))));
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace {
|
|||
using GlslGeneratorImplTest_Case = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block(create<ast::BreakStatement>())),
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
|
@ -39,7 +39,7 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case) {
|
|||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block()), DefaultCase());
|
||||
auto* s = Switch(1, Case(Expr(5), Block()), DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -54,9 +54,8 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
|||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
||||
auto* s =
|
||||
Switch(1, Case(Literal(5), Block(create<ast::FallthroughStatement>())),
|
||||
DefaultCase());
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::FallthroughStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -71,9 +70,9 @@ TEST_F(GlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
|||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
||||
auto* s = Switch(
|
||||
1, Case({Literal(5), Literal(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
auto* s =
|
||||
Switch(1, Case({Expr(5), Expr(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) {
|
|||
auto* def = create<ast::CaseStatement>(ast::CaseSelectorList{}, def_body);
|
||||
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(Literal(5));
|
||||
case_val.push_back(Expr(5));
|
||||
|
||||
auto* case_body = Block(create<ast::BreakStatement>());
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace {
|
|||
using HlslGeneratorImplTest_Case = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block(create<ast::BreakStatement>())),
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
|
@ -39,7 +39,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block()), DefaultCase());
|
||||
auto* s = Switch(1, Case(Expr(5), Block()), DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -55,9 +55,9 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
||||
auto* s =
|
||||
Switch(1, //
|
||||
Case(Literal(4), Block(create<ast::FallthroughStatement>())), //
|
||||
Case(Literal(5), Block(create<ast::ReturnStatement>())), //
|
||||
Switch(1, //
|
||||
Case(Expr(4), Block(create<ast::FallthroughStatement>())), //
|
||||
Case(Expr(5), Block(create<ast::ReturnStatement>())), //
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
|
@ -77,9 +77,9 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) {
|
||||
auto* s = Switch(
|
||||
1, Case({Literal(5), Literal(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
auto* s =
|
||||
Switch(1, Case({Expr(5), Expr(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -23,9 +23,9 @@ using HlslGeneratorImplTest_Switch = TestHelper;
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
|
||||
Global("cond", ty.i32(), ast::StorageClass::kPrivate);
|
||||
auto* s = Switch( //
|
||||
Expr("cond"), //
|
||||
Case(Literal(5), Block(Break())), //
|
||||
auto* s = Switch( //
|
||||
Expr("cond"), //
|
||||
Case(Expr(5), Block(Break())), //
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Case) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block(create<ast::BreakStatement>())),
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
|
@ -39,7 +39,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block()), DefaultCase());
|
||||
auto* s = Switch(1, Case(Expr(5), Block()), DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -54,9 +54,8 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) {
|
||||
auto* s =
|
||||
Switch(1, Case(Literal(5), Block(create<ast::FallthroughStatement>())),
|
||||
DefaultCase());
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::FallthroughStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -71,9 +70,9 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
||||
auto* s = Switch(
|
||||
1, Case({Literal(5), Literal(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
auto* s =
|
||||
Switch(1, Case({Expr(5), Expr(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) {
|
|||
auto* def = create<ast::CaseStatement>(ast::CaseSelectorList{}, def_body);
|
||||
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(Literal(5));
|
||||
case_val.push_back(Expr(5));
|
||||
|
||||
auto* case_body = Block(create<ast::BreakStatement>());
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@ TEST_F(BuilderTest, Switch_WithCase) {
|
|||
auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* expr = Switch("a", /**/
|
||||
Case(Literal(1), Block(Assign("v", 1))),
|
||||
Case(Literal(2), Block(Assign("v", 2))), DefaultCase());
|
||||
Case(Expr(1), Block(Assign("v", 1))),
|
||||
Case(Expr(2), Block(Assign("v", 2))), DefaultCase());
|
||||
WrapInFunction(expr);
|
||||
|
||||
auto* func = Func("a_func", {}, ty.void_(), ast::StatementList{},
|
||||
|
@ -119,8 +119,8 @@ TEST_F(BuilderTest, Switch_WithCase_Unsigned) {
|
|||
auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate);
|
||||
auto* a = Global("a", ty.u32(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* expr = Switch("a", Case(Literal(1u), Block(Assign("v", 1))),
|
||||
Case(Literal(2u), Block(Assign("v", 2))), DefaultCase());
|
||||
auto* expr = Switch("a", Case(Expr(1u), Block(Assign("v", 1))),
|
||||
Case(Expr(2u), Block(Assign("v", 2))), DefaultCase());
|
||||
|
||||
WrapInFunction(expr);
|
||||
|
||||
|
@ -244,11 +244,11 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
|
|||
auto* default_body = Block(Assign("v", Expr(3)));
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(Literal(1));
|
||||
selector_1.push_back(Expr(1));
|
||||
|
||||
ast::CaseSelectorList selector_2;
|
||||
selector_2.push_back(Literal(2));
|
||||
selector_2.push_back(Literal(3));
|
||||
selector_2.push_back(Expr(2));
|
||||
selector_2.push_back(Expr(3));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
@ -326,10 +326,10 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
|
|||
auto* default_body = Block(Assign("v", Expr(3)));
|
||||
|
||||
ast::CaseSelectorList selector_1;
|
||||
selector_1.push_back(Literal(1));
|
||||
selector_1.push_back(Expr(1));
|
||||
|
||||
ast::CaseSelectorList selector_2;
|
||||
selector_2.push_back(Literal(2));
|
||||
selector_2.push_back(Expr(2));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(selector_1, case_1_body));
|
||||
|
@ -398,13 +398,12 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) {
|
|||
auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate);
|
||||
auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate);
|
||||
|
||||
auto* expr =
|
||||
Switch("a", /**/
|
||||
Case(Literal(1),
|
||||
Block(/**/
|
||||
If(Expr(true), Block(create<ast::BreakStatement>())),
|
||||
Assign("v", 1))),
|
||||
DefaultCase());
|
||||
auto* expr = Switch(
|
||||
"a", /**/
|
||||
Case(Expr(1), Block(/**/
|
||||
If(Expr(true), Block(create<ast::BreakStatement>())),
|
||||
Assign("v", 1))),
|
||||
DefaultCase());
|
||||
|
||||
WrapInFunction(expr);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Case) {
|
||||
auto* s = Switch(1, Case(Literal(5), Block(create<ast::BreakStatement>())),
|
||||
auto* s = Switch(1, Case(Expr(5), Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
|
@ -38,9 +38,9 @@ TEST_F(WgslGeneratorImplTest, Emit_Case) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
||||
auto* s = Switch(
|
||||
1, Case({Literal(5), Literal(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
auto* s =
|
||||
Switch(1, Case({Expr(5), Expr(6)}, Block(create<ast::BreakStatement>())),
|
||||
DefaultCase());
|
||||
WrapInFunction(s);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) {
|
|||
auto* def = create<ast::CaseStatement>(ast::CaseSelectorList{}, def_body);
|
||||
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(Literal(5));
|
||||
case_val.push_back(Expr(5));
|
||||
|
||||
auto* case_body = Block(create<ast::BreakStatement>());
|
||||
|
||||
|
|
Loading…
Reference in New Issue