[opengtl-commits] [715] add two tests related to vectors and functions

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 715
Author:   cyrille
Date:     2009-04-09 15:21:26 +0200 (Thu, 09 Apr 2009)

Log Message:
-----------
add two tests related to vectors and functions

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/tests/vectors/CMakeLists.txt

Added Paths:
-----------
    trunk/OpenGTL/OpenShiva/tests/vectors/functioncalling.shiva
    trunk/OpenGTL/OpenShiva/tests/vectors/functionreturning.shiva


Modified: trunk/OpenGTL/OpenShiva/tests/vectors/CMakeLists.txt
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/vectors/CMakeLists.txt	2009-04-09 13:12:29 UTC (rev 714)
+++ trunk/OpenGTL/OpenShiva/tests/vectors/CMakeLists.txt	2009-04-09 13:21:26 UTC (rev 715)
@@ -5,6 +5,8 @@
   copy4.shiva
   operations.shiva
   coumpoundcreation.shiva
+  functioncalling.shiva
+  functionreturning.shiva
   )
 
 FOREACH( TEST_FILE ${TESTS_FILES} )

Added: trunk/OpenGTL/OpenShiva/tests/vectors/functioncalling.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/vectors/functioncalling.shiva	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/tests/vectors/functioncalling.shiva	2009-04-09 13:21:26 UTC (rev 715)
@@ -0,0 +1,28 @@
+kernel MyKernel
+{
+  void evaluatePixel(output pixel result)
+  {
+  }
+  int ret(float4 v4)
+  {
+    int count = 0;
+    if( v4[0] != 2.0 ) ++count;
+    if( v4[1] != 1.0 ) ++count;
+    if( v4[2] != 4.0 ) ++count;
+    if( v4[3] != -12.0 ) ++count;
+    return count;
+  }
+  int runTest()
+  {
+    int count = 0;
+    float4 v4 = float4(2.0, 1.0, 4.0, -12.0);
+    count += ret( v4 );
+    float4 v3 = { 2.0, 1.0, 4.0, -12.0 };
+    count += ret( v3 );
+    
+    count += ret( float4(2.0, 1.0, 4.0, -12.0) );
+    count += ret( {2.0, 1.0, 4.0, -12.0} );
+    
+    return count;
+  }
+}

Added: trunk/OpenGTL/OpenShiva/tests/vectors/functionreturning.shiva
===================================================================
--- trunk/OpenGTL/OpenShiva/tests/vectors/functionreturning.shiva	                        (rev 0)
+++ trunk/OpenGTL/OpenShiva/tests/vectors/functionreturning.shiva	2009-04-09 13:21:26 UTC (rev 715)
@@ -0,0 +1,36 @@
+kernel MyKernel
+{
+  void evaluatePixel(output pixel result)
+  {
+  }
+  float2 ret2()
+  {
+    return float2(2.0, 4.0);
+  }
+  float3 ret3()
+  {
+    return float3(2.5, 3.0, -1.0);
+  }
+  float4 ret(float4 v)
+  {
+    return v;
+  }
+  int runTest()
+  {
+    int count = 0;
+    float2 v2 = ret2();
+    if( v2[0] != 2.0 ) ++count;
+    if( v2[1] != 4.0 ) ++count;
+    float3 v3 = ret3();
+    if( v3[0] != 2.5 ) ++count;
+    if( v3[1] != 3.0 ) ++count;
+    if( v3[2] != -1.0 ) ++count;
+    float4 v4 = ret( float4(2.0, 1.0, 4.0, -12.0) );
+    if( v4[0] != 2.0 ) ++count;
+    if( v4[1] != 1.0 ) ++count;
+    if( v4[2] != 4.0 ) ++count;
+    if( v4[3] != -12.0 ) ++count;
+    
+    return count;
+  }
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/