• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Tint Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/ast/call_statement.h"
16 
17 #include "gtest/gtest-spi.h"
18 #include "src/ast/test_helper.h"
19 
20 namespace tint {
21 namespace ast {
22 namespace {
23 
24 using CallStatementTest = TestHelper;
25 
TEST_F(CallStatementTest,Creation)26 TEST_F(CallStatementTest, Creation) {
27   auto* expr = create<CallExpression>(Expr("func"), ExpressionList{});
28 
29   auto* c = create<CallStatement>(expr);
30   EXPECT_EQ(c->expr, expr);
31 }
32 
TEST_F(CallStatementTest,IsCall)33 TEST_F(CallStatementTest, IsCall) {
34   auto* c = create<CallStatement>(Call("f"));
35   EXPECT_TRUE(c->Is<CallStatement>());
36 }
37 
TEST_F(CallStatementTest,Assert_Null_Call)38 TEST_F(CallStatementTest, Assert_Null_Call) {
39   EXPECT_FATAL_FAILURE(
40       {
41         ProgramBuilder b;
42         b.create<CallStatement>(nullptr);
43       },
44       "internal compiler error");
45 }
46 
TEST_F(CallStatementTest,Assert_DifferentProgramID_Call)47 TEST_F(CallStatementTest, Assert_DifferentProgramID_Call) {
48   EXPECT_FATAL_FAILURE(
49       {
50         ProgramBuilder b1;
51         ProgramBuilder b2;
52         b1.create<CallStatement>(
53             b2.create<CallExpression>(b2.Expr("func"), ExpressionList{}));
54       },
55       "internal compiler error");
56 }
57 
58 }  // namespace
59 }  // namespace ast
60 }  // namespace tint
61