1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 #include "Reactor.hpp"
17 #include "gtest/gtest.h"
21 int reference(int *p, int y)
26 for(int i = 0; i < 10; i++)
28 z += (2 << i) - (i / 3);
36 TEST(SubzeroReactorSample, SubzeroReactor)
38 Routine *routine = nullptr;
41 Function<Int(Pointer<Int>, Int)> function;
43 Pointer<Int> p = function.Arg<0>();
45 Int y = function.Arg<1>();
48 For(Int i = 0, i < 10, i++)
50 z += (2 << i) - (i / 3);
55 z = As<Int>(Float(Float4(v.xzxx).y));
62 routine = function(L"one");
66 int (*callable)(int*, int) = (int(*)(int*,int))routine->getEntry();
68 int result = callable(&one[1], 2);
69 EXPECT_EQ(result, reference(&one[1], 2));
76 int main(int argc, char **argv)
78 ::testing::InitGoogleTest(&argc, argv);
79 return RUN_ALL_TESTS();