[validation] Add Disabled test for detecting recursion

This CL adds a disabled test for validating following rule:
v-0004: Recursion is not allowed

Bug: tint: 6
Change-Id: I35d51b08174ac23a4b1def9f762e80c5950a726d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/26942
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
Sarah Mashayekhi 2020-08-17 21:01:28 +00:00 committed by Commit Bot service account
parent dd99471420
commit 8fcf269d4b
1 changed files with 24 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include "src/ast/bool_literal.h"
#include "src/ast/break_statement.h"
#include "src/ast/call_expression.h"
#include "src/ast/call_statement.h"
#include "src/ast/case_statement.h"
#include "src/ast/cast_expression.h"
#include "src/ast/continue_statement.h"
@ -684,11 +685,33 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
mod()->AddFunction(std::move(func0));
mod()->AddFunction(std::move(func1));
EXPECT_TRUE(td()->Determine()) << td()->error();
EXPECT_TRUE(td()->Determine()) << td()->error();
tint::ValidatorImpl v;
EXPECT_TRUE(v.Validate(mod())) << v.error();
}
TEST_F(ValidatorTest, DISABLED_RecursionIsNotAllowed_Fail) {
// fn func() -> void {func(); return; }
ast::type::F32Type f32;
ast::type::VoidType void_type;
ast::ExpressionList call_params;
auto call_expr = std::make_unique<ast::CallExpression>(
Source{12, 34}, std::make_unique<ast::IdentifierExpression>("func"),
std::move(call_params));
ast::VariableList params0;
auto func0 =
std::make_unique<ast::Function>("func", std::move(params0), &f32);
auto body0 = std::make_unique<ast::BlockStatement>();
body0->append(std::make_unique<ast::CallStatement>(std::move(call_expr)));
body0->append(std::make_unique<ast::ReturnStatement>());
func0->set_body(std::move(body0));
mod()->AddFunction(std::move(func0));
EXPECT_TRUE(td()->Determine()) << td()->error();
tint::ValidatorImpl v;
EXPECT_FALSE(v.Validate(mod())) << v.error();
EXPECT_EQ(v.error(), "12:34: v-0004: recursion is not allowed: 'func'");
}
} // namespace
} // namespace tint