#NEWLINE# def testStructs( self ) : #NEWLINE# #INDENT# s = self . compileShader ( ( os . path . dirname ( __file__ ) + '/shaders/structs.osl' ) ) #NEWLINE# n = GafferOSL . OSLShader ( ) #NEWLINE# n . loadShader ( s ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] . keys ( ) , [ 'i' , 'f' , 's' , 'ss' ] ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 'i' ] . defaultValue ( ) , 2 ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 'f' ] . defaultValue ( ) , 3 ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 'ss' ] . defaultValue ( ) , 'ss' ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 's' ] . keys ( ) , [ 'i' , 'f' , 'c' , 's' ] ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 's' ] [ 'i' ] . defaultValue ( ) , 1 ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 's' ] [ 'f' ] . defaultValue ( ) , 2 ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 's' ] [ 'c' ] . defaultValue ( ) , IECore . Color3f ( 1 , 2 , 3 ) ) #NEWLINE# self . assertEqual ( n [ 'parameters' ] [ 's' ] [ 's' ] . defaultValue ( ) , 's' ) #NEWLINE# n [ 'parameters' ] [ 's' ] [ 'i' ] . setValue ( 10 ) #NEWLINE# n [ 'parameters' ] [ 's' ] [ 'f' ] . setValue ( 21 ) #NEWLINE# n [ 'parameters' ] [ 's' ] [ 'c' ] . setValue ( IECore . Color3f ( 3 , 4 , 5 ) ) #NEWLINE# n [ 'parameters' ] [ 's' ] [ 's' ] . setValue ( 'ttt' ) #NEWLINE# state = n . state ( ) #NEWLINE# self . assertEqual ( len ( state [ 0 ] . parameters ) , 7 ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 'i' ] , IECore . IntData ( 2 ) ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 'f' ] , IECore . FloatData ( 3 ) ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 's.i' ] , IECore . IntData ( 10 ) ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 's.f' ] , IECore . FloatData ( 21 ) ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 's.c' ] , IECore . Color3fData ( IECore . Color3f ( 3 , 4 , 5 ) ) ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 's.s' ] , IECore . StringData ( 'ttt' ) ) #NEWLINE# self . assertTrue ( state [ 0 ] . parameters [ 'ss' ] , IECore . StringData ( 'ss' ) ) #NEWLINE# h1 = n . stateHash ( ) #NEWLINE# n [ 'parameters' ] [ 's' ] [ 'i' ] . setValue ( 100 ) #NEWLINE# h2 = n . stateHash ( ) #NEWLINE# self . assertNotEqual ( h1 , h2 ) #NEWLINE# s2 = self . compileShader ( ( os . path . dirname ( __file__ ) + '/shaders/outputTypes.osl' ) ) #NEWLINE# g = GafferOSL . OSLShader ( ) #NEWLINE# g . loadShader ( s2 ) #NEWLINE# n [ 'parameters' ] [ 's' ] [ 'i' ] . setInput ( g [ 'out' ] [ 'i' ] ) #NEWLINE# h3 = n . stateHash ( ) #NEWLINE# self . assertNotEqual ( h1 , h3 ) #NEWLINE# self . assertNotEqual ( h2 , h3 )