From 2f17549702b5596689257b73a69a8a1d6d7c10b9 Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 28 Oct 2021 15:00:39 +0000 Subject: [PATCH] resolver: Add test for sem::Function::CallSites() Fixed: tint:835 Change-Id: I22bc5d478061afbc279a0e881e4c1eeb0183c68a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67645 Kokoro: Kokoro Reviewed-by: Ben Clayton --- src/resolver/resolver_test.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/resolver/resolver_test.cc b/src/resolver/resolver_test.cc index b460267b2c..198109f98b 100644 --- a/src/resolver/resolver_test.cc +++ b/src/resolver/resolver_test.cc @@ -930,6 +930,30 @@ TEST_F(ResolverTest, Function_ReturnStatements) { EXPECT_TRUE(func_sem->ReturnType()->Is()); } +TEST_F(ResolverTest, Function_CallSites) { + auto* foo = Func("foo", ast::VariableList{}, ty.void_(), {}); + + auto* call_1 = Call("foo"); + auto* call_2 = Call("foo"); + auto* bar = Func("bar", ast::VariableList{}, ty.void_(), + { + WrapInStatement(call_1), + WrapInStatement(call_2), + }); + + EXPECT_TRUE(r()->Resolve()) << r()->error(); + + auto* foo_sem = Sem().Get(foo); + ASSERT_NE(foo_sem, nullptr); + ASSERT_EQ(foo_sem->CallSites().size(), 2u); + EXPECT_EQ(foo_sem->CallSites()[0], call_1); + EXPECT_EQ(foo_sem->CallSites()[1], call_2); + + auto* bar_sem = Sem().Get(bar); + ASSERT_NE(bar_sem, nullptr); + EXPECT_EQ(bar_sem->CallSites().size(), 0u); +} + TEST_F(ResolverTest, Function_WorkgroupSize_NotSet) { // [[stage(compute), workgroup_size(1)]] // fn main() {}