diff options
| author | Yong He <yonghe@outlook.com> | 2017-12-28 17:43:45 -0500 |
|---|---|---|
| committer | Yong He <yonghe@outlook.com> | 2017-12-28 17:43:45 -0500 |
| commit | ee1ea355f2cde3a3bfb0ce0308129f3cf82a2971 (patch) | |
| tree | c48beaece1bc6f421706cda24b5424148d942321 /tests | |
| parent | bcfe8366d2f094bfabccc0014c7248bc46dbf514 (diff) | |
| parent | 9efd9597c50d4dbbf57a9285085aab044ed6c8c0 (diff) | |
Merge branch 'struct-in-generic'
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compute/assoctype-func-param.slang | 53 | ||||
| -rw-r--r-- | tests/compute/assoctype-func-param.slang.expected.txt | 4 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/compute/assoctype-func-param.slang b/tests/compute/assoctype-func-param.slang new file mode 100644 index 000000000..63acfb23a --- /dev/null +++ b/tests/compute/assoctype-func-param.slang @@ -0,0 +1,53 @@ +//TEST(compute):COMPARE_COMPUTE:-xslang -use-ir +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out + +// Test type checking of associatedtype and typedef + +RWStructuredBuffer<float> outputBuffer; + +interface IBase +{ + associatedtype SubTypeT; + associatedtype RetT; + RetT getVal(SubTypeT t); + SubTypeT setVal(RetT v); +} + +struct SubType<T> +{ + T x; +}; + +struct GenStruct<T> : IBase +{ + typedef T RetT; + typedef SubType<RetT> SubTypeT; + SubTypeT setVal(T val) + { + SubTypeT rs; + rs.x = val; + return rs; + } + T getVal(SubTypeT v) + { + return v.x; + } +}; + +U.RetT test<U:IBase>(U.RetT val) +{ + U obj; + U.SubTypeT sb = obj.setVal(val); + return obj.getVal(sb); +} + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + float inVal = float(tid); + /* wrong error message for the following line */ + float outVal = test<GenStruct<float> >(inVal); + outputBuffer[tid] = outVal.x; +}
\ No newline at end of file diff --git a/tests/compute/assoctype-func-param.slang.expected.txt b/tests/compute/assoctype-func-param.slang.expected.txt new file mode 100644 index 000000000..98798bd61 --- /dev/null +++ b/tests/compute/assoctype-func-param.slang.expected.txt @@ -0,0 +1,4 @@ +0 +3F800000 +40000000 +40400000
\ No newline at end of file |
