9using namespace shader::parser;
10using namespace shader;
13TEST(shader_tool, StructMethods)
74S _function(_ref(S ,this_), int i);
75int _size(const S this_);
78 S S_ctor_() {S r;r.member=0;r.this_member=0;r.another_member=0;return r;}
88 S _function(_ref(S ,this_), int i)
95 int _size(const S this_)
115 auto [
output, _, error] = process_test_string(input);
124 float fn1() { return a; }
125 float fn2() { int fn2; return fn1(); }
126 static float fn3() { int a; return a; }
138float _fn1(_ref(A ,this_));
139float _fn2(_ref(A ,this_));
143 A A_ctor_() {A r;r.a=0;r.b=0u;return r;}
146 float _fn1(_ref(A ,this_)) { return this_.a; }
147 float _fn2(_ref(A ,this_)) { int fn2; return _fn1(this_); }
148 float A_fn3() { int a; return a; }
151 auto [
output, _, error] = process_test_string(input);
159 float fn1(int a) { return a; }
162 auto [
output, _, error] = process_test_string(input);
163 EXPECT_EQ(error,
"Class member shadowing.");
169 float fn1() { int a; return a; }
172 auto [
output, _, error] = process_test_string(input);
173 EXPECT_EQ(error,
"Class member shadowing.");
185 auto [
output, _, error] = process_test_string(input);
186 EXPECT_EQ(error,
"Method name matching swizzles accessor are forbidden.");
190TEST(shader_tool, DefaultArguments)
194int func(int a, int b = 0)
200int func(int a, int b )
213 auto [
output, _, error] = process_test_string(input);
219int func(int a = 0, const int b = 0)
225int func(int a , const int b )
244 auto [
output, _, error] = process_test_string(input);
250int2 func(int2 a = int2(0, 0)) {
262 return func(int2(0, 0));
266 auto [
output, _, error] = process_test_string(input);
272void func(int a = 0) {
288 auto [
output, _, error] = process_test_string(input);
295int func(int a, int b = 0)
307int func(int a, int b )
318 auto [
output, _, error] = process_test_string(input, Language::BSL);
324int func(int a = 0, const int b = 2)
337int func(int a , const int b )
349 auto [
output, _, error] = process_test_string(input, Language::BSL);
355TEST(shader_tool, FunctionOverloads)
359 string input = R
"(struct A {};
362void f(int a, float b) {}
363void f(float2 a, float b) {}
379 string expect = R
"(struct A {int _pad;
383A A_ctor_() {A r;r._pad=0;return r;}
390void f4(int a, float b) {
393void f5(float2 a, float b) {
#define EXPECT_EQ(result, expect)
TEST(shader_tool, ExpressionParser)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)