@@ -125,5 +125,53 @@ Method TestUnicode()
125
125
do $$$AssertEquals(unicode , result , " Passing unicode characters works" )
126
126
}
127
127
128
+ /// Test streams work
129
+ /// To do all variants of calling ExcuteCode and GetVariable
130
+ Method TestStreams ()
131
+ {
132
+ set stream = ##class (%Stream.TmpCharacter ).%New ()
133
+
134
+ do stream .Write (" '" )
135
+ for letter = " A" ," B" {
136
+ set str = $tr ($j (" " , $$$MaxStringLength), " " , letter )
137
+ do stream .Write (str )
138
+ }
139
+ do stream .Write (" '" )
140
+ set sc = ##class (isc.py.Main ).ExcuteCode (stream , " stream" )
141
+ do $$$AssertStatusOK(sc , " ExcuteCode" )
142
+
143
+ set hash = $system .Encryption .Base64Encode ($system .Encryption .MD5HashStream (stream ))
144
+ set length = stream .Size
145
+
146
+ set stream2 = ##class (%Stream.TmpCharacter ).%New ()
147
+
148
+ set sc = ##class (isc.py.Main ).GetVariable (" stream" , 1 , .stream2 )
149
+ do $$$AssertStatusOK(sc , " GetVariable" )
150
+
151
+ set length2 = stream2 .Size
152
+ set hash2 = $system .Encryption .Base64Encode ($system .Encryption .MD5HashStream (stream2 ))
153
+
154
+ do $$$AssertEquals(length , length2 , " Stream lengths match" )
155
+ do $$$AssertEquals(length2 , ($$$MaxStringLength * 2 + 2 ), " Expected stream length" )
156
+ do $$$AssertEquals(hash , hash2 , " Hashes match" )
157
+ }
158
+
159
+ Method TestMultiline ()
160
+ {
161
+ do ##class (isc.py.Main ).GetStatus ()
162
+ do ##class (isc.py.Callout ).SimpleString (" def cube(num):" _ $c (10 ) _
163
+ " return num*num*num" )
164
+
165
+ set sc = ##class (isc.py.Main ).GetStatus ()
166
+ do $$$AssertStatusOK(sc , " def executed" )
167
+
168
+ set num = 6
169
+ set cube = ##class (isc.py.Callout ).SimpleString (" x=cube(" _ num _ " )" , " x" )
170
+
171
+ do $$$AssertEquals(num **3 , cube , " defined function works" )
172
+
173
+ do ##class (isc.py.Callout ).SimpleString (" del cube" )
174
+ }
175
+
128
176
}
129
177
0 commit comments