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 "gtest/gtest.h" 16 #include "src/ast/discard_statement.h" 17 #include "src/context.h" 18 #include "src/type_determiner.h" 19 #include "src/writer/spirv/builder.h" 20 #include "src/writer/spirv/spv_dump.h" 21 22 namespace tint { 23 namespace writer { 24 namespace spirv { 25 namespace { 26 27 using BuilderTest = testing::Test; 28 TEST_F(BuilderTest,Discard)29TEST_F(BuilderTest, Discard) { 30 ast::DiscardStatement expr; 31 32 ast::Module mod; 33 Builder b(&mod); 34 b.push_function(Function{}); 35 EXPECT_EQ(b.GenerateStatement(&expr), 1u) << b.error(); 36 EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(OpKill 37 )"); 38 } 39 40 } // namespace 41 } // namespace spirv 42 } // namespace writer 43 } // namespace tint 44