Add missing break, continue and return tests.
This CL adds tests for break, continue and return without attached expressions. Bug: tint:5 Change-Id: I8c4221e787af95f5597db3ea4e42b38962223bf4 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/18980 Reviewed-by: Ryan Harrison <rharrison@chromium.org>
This commit is contained in:
parent
0e2576250a
commit
327ed1bf8a
|
@ -41,9 +41,9 @@
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/ast/type/struct_type.h"
|
||||||
#include "src/ast/type/vector_type.h"
|
#include "src/ast/type/vector_type.h"
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
|
||||||
#include "src/ast/unary_derivative_expression.h"
|
#include "src/ast/unary_derivative_expression.h"
|
||||||
#include "src/ast/unary_method_expression.h"
|
#include "src/ast/unary_method_expression.h"
|
||||||
|
#include "src/ast/unary_op_expression.h"
|
||||||
#include "src/ast/unless_statement.h"
|
#include "src/ast/unless_statement.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
|
||||||
|
@ -381,9 +381,8 @@ bool TypeDeterminer::DetermineRelational(ast::RelationalExpression* expr) {
|
||||||
|
|
||||||
} else if (lhs_type->IsMatrix() && rhs_type->IsVector()) {
|
} else if (lhs_type->IsMatrix() && rhs_type->IsVector()) {
|
||||||
auto mat = lhs_type->AsMatrix();
|
auto mat = lhs_type->AsMatrix();
|
||||||
expr->set_result_type(
|
expr->set_result_type(ctx_.type_mgr().Get(
|
||||||
ctx_.type_mgr().Get(std::make_unique<ast::type::VectorType>(
|
std::make_unique<ast::type::VectorType>(mat->type(), mat->rows())));
|
||||||
mat->type(), mat->rows())));
|
|
||||||
} else if (lhs_type->IsVector() && rhs_type->IsMatrix()) {
|
} else if (lhs_type->IsVector() && rhs_type->IsMatrix()) {
|
||||||
auto mat = rhs_type->AsMatrix();
|
auto mat = rhs_type->AsMatrix();
|
||||||
expr->set_result_type(
|
expr->set_result_type(
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/struct_member.h"
|
#include "src/ast/struct_member.h"
|
||||||
#include "src/ast/switch_statement.h"
|
#include "src/ast/switch_statement.h"
|
||||||
#include "src/ast/unary_op_expression.h"
|
|
||||||
#include "src/ast/type/array_type.h"
|
#include "src/ast/type/array_type.h"
|
||||||
#include "src/ast/type/bool_type.h"
|
#include "src/ast/type/bool_type.h"
|
||||||
#include "src/ast/type/f32_type.h"
|
#include "src/ast/type/f32_type.h"
|
||||||
|
@ -52,6 +51,7 @@
|
||||||
#include "src/ast/type_constructor_expression.h"
|
#include "src/ast/type_constructor_expression.h"
|
||||||
#include "src/ast/unary_derivative_expression.h"
|
#include "src/ast/unary_derivative_expression.h"
|
||||||
#include "src/ast/unary_method_expression.h"
|
#include "src/ast/unary_method_expression.h"
|
||||||
|
#include "src/ast/unary_op_expression.h"
|
||||||
#include "src/ast/unless_statement.h"
|
#include "src/ast/unless_statement.h"
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
|
||||||
|
@ -105,6 +105,12 @@ TEST_F(TypeDeterminerTest, Stmt_Break) {
|
||||||
EXPECT_TRUE(cond_ptr->result_type()->IsI32());
|
EXPECT_TRUE(cond_ptr->result_type()->IsI32());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TypeDeterminerTest, Stmt_Break_WithoutCondition) {
|
||||||
|
ast::type::I32Type i32;
|
||||||
|
ast::BreakStatement brk;
|
||||||
|
EXPECT_TRUE(td()->DetermineResultType(&brk));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TypeDeterminerTest, Stmt_Case) {
|
TEST_F(TypeDeterminerTest, Stmt_Case) {
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
@ -145,6 +151,12 @@ TEST_F(TypeDeterminerTest, Stmt_Continue) {
|
||||||
EXPECT_TRUE(cond_ptr->result_type()->IsI32());
|
EXPECT_TRUE(cond_ptr->result_type()->IsI32());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TypeDeterminerTest, Stmt_Continue_WithoutStatement) {
|
||||||
|
ast::type::I32Type i32;
|
||||||
|
ast::ContinueStatement stmt;
|
||||||
|
EXPECT_TRUE(td()->DetermineResultType(&stmt));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TypeDeterminerTest, Stmt_Else) {
|
TEST_F(TypeDeterminerTest, Stmt_Else) {
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
@ -313,6 +325,12 @@ TEST_F(TypeDeterminerTest, Stmt_Return) {
|
||||||
EXPECT_TRUE(cond_ptr->result_type()->IsI32());
|
EXPECT_TRUE(cond_ptr->result_type()->IsI32());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TypeDeterminerTest, Stmt_Return_WithoutValue) {
|
||||||
|
ast::type::I32Type i32;
|
||||||
|
ast::ReturnStatement ret;
|
||||||
|
EXPECT_TRUE(td()->DetermineResultType(&ret));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TypeDeterminerTest, Stmt_Switch) {
|
TEST_F(TypeDeterminerTest, Stmt_Switch) {
|
||||||
ast::type::I32Type i32;
|
ast::type::I32Type i32;
|
||||||
ast::type::F32Type f32;
|
ast::type::F32Type f32;
|
||||||
|
|
Loading…
Reference in New Issue