Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | package; |
| 21 | |
| 22 | import haxe.Int32; |
| 23 | import haxe.Int64; |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 24 | import haxe.io.Bytes; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 25 | import haxe.Timer; |
| 26 | import haxe.ds.IntMap; |
| 27 | import haxe.ds.StringMap; |
| 28 | import haxe.ds.ObjectMap; |
| 29 | |
| 30 | import org.apache.thrift.*; |
| 31 | import org.apache.thrift.helper.*; |
| 32 | import org.apache.thrift.protocol.*; |
| 33 | import org.apache.thrift.transport.*; |
| 34 | import org.apache.thrift.server.*; |
| 35 | import org.apache.thrift.meta_data.*; |
| 36 | |
| 37 | #if cpp |
| 38 | import cpp.vm.Thread; |
| 39 | #else |
| 40 | // no thread support (yet) |
| 41 | #end |
| 42 | |
| 43 | import thrift.test.*; // generated code |
| 44 | |
| 45 | |
| 46 | class TestResults { |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 47 | private var successCnt : Int = 0; |
| 48 | private var errorCnt : Int = 0; |
| 49 | private var failedTests : String = ""; |
| 50 | private var print_direct : Bool = false; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 51 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 52 | public static var EXITCODE_SUCCESS = 0x00; // no errors bits set |
| 53 | // |
| 54 | public static var EXITCODE_FAILBIT_BASETYPES = 0x01; |
| 55 | public static var EXITCODE_FAILBIT_STRUCTS = 0x02; |
| 56 | public static var EXITCODE_FAILBIT_CONTAINERS = 0x04; |
| 57 | public static var EXITCODE_FAILBIT_EXCEPTIONS = 0x08; |
| 58 | // |
| 59 | public static var EXITCODE_ALL_FAILBITS = 0x0F; |
| 60 | // |
| 61 | private var testsExecuted : Int = 0; |
| 62 | private var testsFailed : Int = 0; |
| 63 | private var currentTest : Int = 0; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 64 | |
| 65 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 66 | public function new(direct : Bool) { |
| 67 | print_direct = direct; |
| 68 | } |
| 69 | |
| 70 | public function StartTestGroup( groupBit : Int) : Void { |
| 71 | currentTest = groupBit; |
| 72 | testsExecuted |= groupBit; |
| 73 | } |
| 74 | |
| 75 | public function Expect( expr : Bool, msg : String) : Void { |
| 76 | if ( expr) { |
| 77 | ++successCnt; |
| 78 | } else { |
| 79 | ++errorCnt; |
| 80 | testsFailed |= currentTest; |
| 81 | failedTests += "\n " + msg; |
| 82 | if( print_direct) { |
| 83 | trace('FAIL: $msg'); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | public function CalculateExitCode() : Int { |
| 89 | var notExecuted : Int = EXITCODE_ALL_FAILBITS & (~testsExecuted); |
| 90 | return testsFailed | notExecuted; |
| 91 | } |
| 92 | |
| 93 | public function PrintSummary() : Void { |
| 94 | var total = successCnt + errorCnt; |
| 95 | var sp = (100 * successCnt) / total; |
| 96 | var ep = (100 * errorCnt) / total; |
| 97 | |
| 98 | trace('==========================='); |
| 99 | trace('Tests executed $total'); |
| 100 | trace('Tests succeeded $successCnt ($sp%)'); |
| 101 | trace('Tests failed $errorCnt ($ep%)'); |
| 102 | if ( errorCnt > 0) |
| 103 | { |
| 104 | trace('==========================='); |
| 105 | trace('FAILED TESTS: $failedTests'); |
| 106 | } |
| 107 | trace('==========================='); |
| 108 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | |
| 112 | class TestClient { |
| 113 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 114 | public static function Execute(args : Arguments) : Void |
| 115 | { |
| 116 | var exitCode = 0xFF; |
| 117 | try |
| 118 | { |
| 119 | var difft = Timer.stamp(); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 120 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 121 | if( args.numThreads > 1) { |
| 122 | var threads = new List<Thread>(); |
| 123 | for( test in 0 ... args.numThreads) { |
| 124 | threads.add( StartThread( args)); |
| 125 | } |
| 126 | exitCode = 0; |
| 127 | for( thread in threads) { |
| 128 | exitCode |= Thread.readMessage(true); |
| 129 | } |
| 130 | } else { |
| 131 | var rslt = new TestResults(true); |
| 132 | RunClient(args,rslt); |
| 133 | rslt.PrintSummary(); |
| 134 | exitCode = rslt.CalculateExitCode(); |
| 135 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 136 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 137 | difft = Timer.stamp() - difft; |
| 138 | trace('total test time: $difft seconds'); |
| 139 | } |
| 140 | catch (e : TException) |
| 141 | { |
| 142 | trace('$e'); |
| 143 | exitCode = 0xFF; |
| 144 | } |
| 145 | catch (e : Dynamic) |
| 146 | { |
| 147 | trace('$e'); |
| 148 | exitCode = 0xFF; |
| 149 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 150 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 151 | #if sys |
| 152 | Sys.exit( exitCode); |
| 153 | #end |
| 154 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 155 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 156 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 157 | private static function StartThread(args : Arguments) : Thread { |
| 158 | var thread = Thread.create( |
| 159 | function() : Void { |
| 160 | var rslt = new TestResults(false); |
| 161 | var main : Thread = Thread.readMessage(true); |
| 162 | try |
| 163 | { |
| 164 | RunClient(args,rslt); |
| 165 | } |
| 166 | catch (e : TException) |
| 167 | { |
| 168 | rslt.Expect( false, '$e'); |
| 169 | trace('$e'); |
| 170 | } |
| 171 | catch (e : Dynamic) |
| 172 | { |
| 173 | rslt.Expect( false, '$e'); |
| 174 | trace('$e'); |
| 175 | } |
| 176 | main.sendMessage( rslt.CalculateExitCode()); |
| 177 | }); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 178 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 179 | thread.sendMessage(Thread.current()); |
| 180 | return thread; |
| 181 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 182 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 183 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 184 | public static function RunClient(args : Arguments, rslt : TestResults) |
| 185 | { |
| 186 | var transport : TTransport = null; |
| 187 | switch (args.transport) |
| 188 | { |
| 189 | case socket: |
| 190 | transport = new TSocket(args.host, args.port); |
| 191 | case http: |
| 192 | transport = new THttpClient(args.host); |
| 193 | default: |
| 194 | throw "Unhandled transport"; |
| 195 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 196 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 197 | // optional: layered transport |
| 198 | if ( args.framed) { |
| 199 | trace("- framed transport"); |
| 200 | transport = new TFramedTransport(transport); |
| 201 | } |
| 202 | if ( args.buffered) { |
| 203 | trace("- buffered transport"); |
Jens Geyer | d35f616 | 2014-11-29 19:23:03 +0100 | [diff] [blame] | 204 | transport = new TBufferedTransport(transport); |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 205 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 206 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 207 | // protocol |
| 208 | var protocol : TProtocol = null; |
| 209 | switch( args.protocol) |
| 210 | { |
| 211 | case binary: |
| 212 | trace("- binary protocol"); |
| 213 | protocol = new TBinaryProtocol(transport); |
| 214 | case json: |
| 215 | trace("- json protocol"); |
| 216 | protocol = new TJSONProtocol(transport); |
| 217 | default: |
| 218 | throw "Unhandled protocol"; |
| 219 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 220 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 221 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 222 | // run the test code |
| 223 | HaxeBasicsTest( args, rslt); |
| 224 | for( i in 0 ... args.numIterations) { |
| 225 | ClientTest( transport, protocol, args, rslt); |
| 226 | } |
| 227 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 228 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 229 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 230 | public static function HaxeBasicsTest( args : Arguments, rslt : TestResults) : Void |
| 231 | { |
| 232 | // We need to test a few basic things used in the ClientTest |
| 233 | // Anything else beyond this scope should go into /lib/haxe/ instead |
| 234 | rslt.StartTestGroup( 0); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 235 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 236 | var map32 = new IntMap<Int32>(); |
| 237 | var map64 = new Int64Map<Int32>(); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 238 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 239 | rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #1"); |
| 240 | rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #2"); |
| 241 | rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #3"); |
| 242 | rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #4"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 243 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 244 | map32.set( 42, 815); |
| 245 | map64.set( Int64.make(0,42), 815); |
| 246 | map32.set( -517, 23); |
| 247 | map64.set( Int64.make(-5,17), 23); |
| 248 | map32.set( 0, -123); |
| 249 | map64.set( Int64.make(0,0), -123); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 250 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 251 | rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #10"); |
| 252 | rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #11"); |
| 253 | rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #12"); |
| 254 | rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #13"); |
| 255 | rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #14"); |
| 256 | rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #15"); |
| 257 | rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #16"); |
| 258 | rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #Int64.make(-5,17)"); |
| 259 | rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #18"); |
| 260 | rslt.Expect( map32.remove( 4711) == map64.remove( Int64.make(47,11)), "Int64Map<Int32> Test #19"); |
| 261 | rslt.Expect( map32.remove( -517) == map64.remove( Int64.make(-5,17)), "Int64Map<Int32> Test #20"); |
| 262 | rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #21"); |
| 263 | rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #22"); |
| 264 | rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #23"); |
| 265 | rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #24"); |
| 266 | rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #25"); |
| 267 | rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #26"); |
| 268 | rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #27"); |
| 269 | rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #28"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 270 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 271 | map32.set( 42, 1); |
| 272 | map64.set( Int64.make(0,42), 1); |
| 273 | map32.set( -517, -2); |
| 274 | map64.set( Int64.make(-5,17), -2); |
| 275 | map32.set( 0, 3); |
| 276 | map64.set( Int64.make(0,0), 3); |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 277 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 278 | var c32 = 0; |
| 279 | for (key in map32.keys()) { |
| 280 | ++c32; |
| 281 | } |
| 282 | var c64 = 0; |
| 283 | for (key in map64.keys()) { |
| 284 | ++c64; |
| 285 | } |
| 286 | rslt.Expect( c32 == c64, "Int64Map<Int32> Test #30"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 287 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 288 | var s32 = map32.toString(); |
| 289 | var s64 = map64.toString(); |
| 290 | trace("Int64Map<Int32>.toString(): " + ' ("$s32" == "$s64")'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 291 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 292 | map32.remove( 42); |
| 293 | map64.remove( Int64.make(0,42)); |
| 294 | map32.remove( -517); |
| 295 | map64.remove( Int64.make(-5,17)); |
| 296 | map32.remove( 0); |
| 297 | map64.remove( Int64.make(0,0)); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 298 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 299 | rslt.Expect( map32.keys().hasNext() == map64.keys().hasNext(), "Int64Map<Int32> Test #90"); |
| 300 | rslt.Expect( map32.exists( 4711) == map64.exists( Int64.make(47,11)), "Int64Map<Int32> Test #91"); |
| 301 | rslt.Expect( map32.exists( -517) == map64.exists( Int64.make(-5,17)), "Int64Map<Int32> Test #92"); |
| 302 | rslt.Expect( map32.exists( 42) == map64.exists( Int64.make(0,42)), "Int64Map<Int32> Test #93"); |
| 303 | rslt.Expect( map32.exists( 0) == map64.exists( Int64.make(0,0)), "Int64Map<Int32> Test #94"); |
| 304 | rslt.Expect( map32.get( 4711) == map64.get( Int64.make(47,11)), "Int64Map<Int32> Test #95"); |
| 305 | rslt.Expect( map32.get( -517) == map64.get( Int64.make(-5,17)), "Int64Map<Int32> Test #96"); |
| 306 | rslt.Expect( map32.get( 42) == map64.get( Int64.make(0,42)), "Int64Map<Int32> Test #97"); |
| 307 | rslt.Expect( map32.get( 0) == map64.get( Int64.make(0,0)), "Int64Map<Int32> Test #98"); |
| 308 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 309 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 310 | |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 311 | public static function BytesToHex(data : Bytes) : String { |
| 312 | var hex = ""; |
| 313 | for ( i in 0 ... data.length) { |
| 314 | hex += StringTools.hex( data.get(i), 2); |
| 315 | } |
| 316 | return hex; |
| 317 | } |
| 318 | |
| 319 | public static function PrepareTestData(randomDist : Bool) : Bytes { |
| 320 | var retval = Bytes.alloc(0x100); |
| 321 | var initLen : Int = (retval.length > 0x100 ? 0x100 : retval.length); |
| 322 | |
| 323 | // linear distribution, unless random is requested |
| 324 | if (!randomDist) { |
| 325 | for (i in 0 ... initLen) { |
| 326 | retval.set(i, i % 0x100); |
| 327 | } |
| 328 | return retval; |
| 329 | } |
| 330 | |
| 331 | // random distribution |
| 332 | for (i in 0 ... initLen) { |
| 333 | retval.set(i, 0); |
| 334 | } |
| 335 | for (i in 1 ... initLen) { |
| 336 | while( true) { |
| 337 | var nextPos = Std.random(initLen); |
| 338 | if (retval.get(nextPos) == 0) { |
| 339 | retval.set( nextPos, i % 0x100); |
| 340 | break; |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | return retval; |
| 345 | } |
| 346 | |
| 347 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 348 | public static function ClientTest( transport : TTransport, protocol : TProtocol, |
| 349 | args : Arguments, rslt : TestResults) : Void |
| 350 | { |
| 351 | var client = new ThriftTestImpl(protocol,protocol); |
| 352 | try |
| 353 | { |
| 354 | if (!transport.isOpen()) |
| 355 | { |
| 356 | transport.open(); |
| 357 | } |
| 358 | } |
| 359 | catch (e : TException) |
| 360 | { |
| 361 | trace('$e'); |
| 362 | return; |
| 363 | } |
| 364 | catch (e : Dynamic) |
| 365 | { |
| 366 | trace('$e'); |
| 367 | return; |
| 368 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 369 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 370 | var start = Date.now(); |
| 371 | |
| 372 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_EXCEPTIONS); |
| 373 | |
| 374 | // if arg == "Xception" throw Xception with errorCode = 1001 and message = arg |
| 375 | trace('testException("Xception")'); |
| 376 | try { |
| 377 | client.testException("Xception"); |
| 378 | rslt.Expect( false, 'testException("Xception") should throw'); |
| 379 | } |
| 380 | catch (e : Xception) |
| 381 | { |
| 382 | rslt.Expect( e.message == "Xception", 'testException("Xception") - e.message == "Xception"'); |
| 383 | rslt.Expect( e.errorCode == 1001, 'testException("Xception") - e.errorCode == 1001'); |
| 384 | } |
| 385 | catch (e : Dynamic) |
| 386 | { |
| 387 | rslt.Expect( false, 'testException("Xception") - $e'); |
| 388 | } |
| 389 | |
| 390 | // if arg == "TException" throw TException |
| 391 | trace('testException("TException")'); |
| 392 | try { |
| 393 | client.testException("TException"); |
| 394 | rslt.Expect( false, 'testException("TException") should throw'); |
| 395 | } |
| 396 | catch (e : TException) |
| 397 | { |
| 398 | rslt.Expect( true, 'testException("TException") - $e'); |
| 399 | } |
| 400 | catch (e : Dynamic) |
| 401 | { |
| 402 | rslt.Expect( false, 'testException("TException") - $e'); |
| 403 | } |
| 404 | |
| 405 | // else do not throw anything |
| 406 | trace('testException("bla")'); |
| 407 | try { |
| 408 | client.testException("bla"); |
| 409 | rslt.Expect( true, 'testException("bla") should not throw'); |
| 410 | } |
| 411 | catch (e : Dynamic) |
| 412 | { |
| 413 | rslt.Expect( false, 'testException("bla") - $e'); |
| 414 | } |
| 415 | |
| 416 | |
| 417 | |
| 418 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES); |
| 419 | |
| 420 | trace('testVoid()'); |
| 421 | client.testVoid(); |
| 422 | trace(' = void'); |
| 423 | rslt.Expect(true,"testVoid()"); // bump counter |
| 424 | |
| 425 | trace('testString("Test")'); |
| 426 | var s = client.testString("Test"); |
| 427 | trace(' = "$s"'); |
| 428 | rslt.Expect(s == "Test", '$s == "Test"'); |
| 429 | |
| 430 | trace('testByte(1)'); |
| 431 | var i8 = client.testByte(1); |
| 432 | trace(' = $i8'); |
| 433 | rslt.Expect(i8 == 1, '$i8 == 1'); |
| 434 | |
| 435 | trace('testI32(-1)'); |
| 436 | var i32 = client.testI32(-1); |
| 437 | trace(' = $i32'); |
| 438 | rslt.Expect(i32 == -1, '$i32 == -1'); |
| 439 | |
| 440 | trace('testI64(-34359738368)'); |
| 441 | var i64 = client.testI64( Int64.make( 0xFFFFFFF8, 0x00000000)); // -34359738368 |
| 442 | trace(' = $i64'); |
| 443 | rslt.Expect( Int64.compare( i64, Int64.make( 0xFFFFFFF8, 0x00000000)) == 0, |
| 444 | Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0xFFFFFFF8, 0x00000000))); |
| 445 | |
| 446 | // edge case: the largest negative Int64 has no positive Int64 equivalent |
| 447 | trace('testI64(-9223372036854775808)'); |
| 448 | i64 = client.testI64( Int64.make( 0x80000000, 0x00000000)); // -9223372036854775808 |
| 449 | trace(' = $i64'); |
| 450 | rslt.Expect( Int64.compare( i64, Int64.make( 0x80000000, 0x00000000)) == 0, |
| 451 | Int64.toStr(i64) +" == "+Int64.toStr(Int64.make( 0x80000000, 0x00000000))); |
| 452 | |
| 453 | trace('testDouble(5.325098235)'); |
| 454 | var dub = client.testDouble(5.325098235); |
| 455 | trace(' = $dub'); |
| 456 | rslt.Expect(dub == 5.325098235, '$dub == 5.325098235'); |
| 457 | |
Jens Geyer | 43e195a | 2014-12-14 00:29:17 +0100 | [diff] [blame] | 458 | var binOut = PrepareTestData(true); |
| 459 | trace('testBinary('+BytesToHex(binOut)+')'); |
| 460 | try { |
| 461 | var binIn = client.testBinary(binOut); |
| 462 | trace('testBinary() = '+BytesToHex(binIn)); |
| 463 | rslt.Expect( binIn.length == binOut.length, '${binIn.length} == ${binOut.length}'); |
| 464 | var len = ((binIn.length < binOut.length) ? binIn.length : binOut.length); |
| 465 | for (ofs in 0 ... len) { |
| 466 | if (binIn.get(ofs) != binOut.get(ofs)) { |
| 467 | rslt.Expect( false, 'testBinary('+BytesToHex(binOut)+'): content mismatch at offset $ofs'); |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | catch (e : TApplicationException) { |
| 472 | trace('testBinary('+BytesToHex(binOut)+'): '+e.errorMsg); // may not be supported by the server |
| 473 | } |
| 474 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 475 | |
| 476 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS); |
| 477 | |
| 478 | trace('testStruct({"Zero", 1, -3, -5})'); |
| 479 | var o = new Xtruct(); |
| 480 | o.string_thing = "Zero"; |
| 481 | o.byte_thing = 1; |
| 482 | o.i32_thing = -3; |
| 483 | o.i64_thing = Int64.make(0,-5); |
| 484 | var i = client.testStruct(o); |
| 485 | trace(' = {"' + i.string_thing + '", ' + i.byte_thing +', ' |
| 486 | + i.i32_thing +', '+ Int64.toStr(i.i64_thing) + '}'); |
| 487 | rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing"); |
| 488 | rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing"); |
| 489 | rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing"); |
| 490 | rslt.Expect( i.i32_thing == o.i32_thing, "i.i64_thing == o.i64_thing"); |
| 491 | |
| 492 | trace('testNest({1, {\"Zero\", 1, -3, -5}, 5})'); |
| 493 | var o2 = new Xtruct2(); |
| 494 | o2.byte_thing = 1; |
| 495 | o2.struct_thing = o; |
| 496 | o2.i32_thing = 5; |
| 497 | var i2 = client.testNest(o2); |
| 498 | i = i2.struct_thing; |
| 499 | trace(" = {" + i2.byte_thing + ", {\"" + i.string_thing + "\", " |
| 500 | + i.byte_thing + ", " + i.i32_thing + ", " + Int64.toStr(i.i64_thing) + "}, " |
| 501 | + i2.i32_thing + "}"); |
| 502 | rslt.Expect( i2.byte_thing == o2.byte_thing, "i2.byte_thing == o2.byte_thing"); |
| 503 | rslt.Expect( i2.i32_thing == o2.i32_thing, "i2.i32_thing == o2.i32_thing"); |
| 504 | rslt.Expect( i.string_thing == o.string_thing, "i.string_thing == o.string_thing"); |
| 505 | rslt.Expect( i.byte_thing == o.byte_thing, "i.byte_thing == o.byte_thing"); |
| 506 | rslt.Expect( i.i32_thing == o.i32_thing, "i.i32_thing == o.i32_thing"); |
| 507 | rslt.Expect( Int64.compare( i.i64_thing, o.i64_thing) == 0, "i.i64_thing == o.i64_thing"); |
| 508 | |
| 509 | |
| 510 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS); |
| 511 | |
| 512 | var mapout = new IntMap< haxe.Int32>(); |
| 513 | for ( j in 0 ... 5) |
| 514 | { |
| 515 | mapout.set(j, j - 10); |
| 516 | } |
| 517 | trace("testMap({"); |
| 518 | var first : Bool = true; |
| 519 | for( key in mapout.keys()) |
| 520 | { |
| 521 | if (first) |
| 522 | { |
| 523 | first = false; |
| 524 | } |
| 525 | else |
| 526 | { |
| 527 | trace(", "); |
| 528 | } |
| 529 | trace(key + " => " + mapout.get(key)); |
| 530 | } |
| 531 | trace("})"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 532 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 533 | var mapin = client.testMap(mapout); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 534 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 535 | trace(" = {"); |
| 536 | first = true; |
| 537 | for( key in mapin.keys()) |
| 538 | { |
| 539 | if (first) |
| 540 | { |
| 541 | first = false; |
| 542 | } |
| 543 | else |
| 544 | { |
| 545 | trace(", "); |
| 546 | } |
| 547 | trace(key + " => " + mapin.get(key)); |
| 548 | rslt.Expect( mapin.get(key) == mapout.get(key), ' mapin.get($key) == mapout.get($key)'); |
| 549 | } |
| 550 | trace("}"); |
| 551 | for( key in mapout.keys()) |
| 552 | { |
| 553 | rslt.Expect(mapin.exists(key), 'mapin.exists($key)'); |
| 554 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 555 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 556 | var listout = new List<Int>(); |
| 557 | for (j in -2 ... 3) |
| 558 | { |
| 559 | listout.add(j); |
| 560 | } |
| 561 | trace("testList({"); |
| 562 | first = true; |
| 563 | for( j in listout) |
| 564 | { |
| 565 | if (first) |
| 566 | { |
| 567 | first = false; |
| 568 | } |
| 569 | else |
| 570 | { |
| 571 | trace(", "); |
| 572 | } |
| 573 | trace(j); |
| 574 | } |
| 575 | trace("})"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 576 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 577 | var listin = client.testList(listout); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 578 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 579 | trace(" = {"); |
| 580 | first = true; |
| 581 | for( j in listin) |
| 582 | { |
| 583 | if (first) |
| 584 | { |
| 585 | first = false; |
| 586 | } |
| 587 | else |
| 588 | { |
| 589 | trace(", "); |
| 590 | } |
| 591 | trace(j); |
| 592 | } |
| 593 | trace("}"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 594 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 595 | rslt.Expect(listin.length == listout.length, "listin.length == listout.length"); |
| 596 | var literout = listout.iterator(); |
| 597 | var literin = listin.iterator(); |
| 598 | while( literin.hasNext()) { |
| 599 | rslt.Expect(literin.next() == literout.next(), "literin[i] == literout[i]"); |
| 600 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 601 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 602 | //set |
| 603 | var setout = new IntSet(); |
| 604 | for (j in -2 ... 3) |
| 605 | { |
| 606 | setout.add(j); |
| 607 | } |
| 608 | trace("testSet({"); |
| 609 | first = true; |
| 610 | for( j in setout) |
| 611 | { |
| 612 | if (first) |
| 613 | { |
| 614 | first = false; |
| 615 | } |
| 616 | else |
| 617 | { |
| 618 | trace(", "); |
| 619 | } |
| 620 | trace(j); |
| 621 | } |
| 622 | trace("})"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 623 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 624 | var setin = client.testSet(setout); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 625 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 626 | trace(" = {"); |
| 627 | first = true; |
| 628 | for( j in setin) |
| 629 | { |
| 630 | if (first) |
| 631 | { |
| 632 | first = false; |
| 633 | } |
| 634 | else |
| 635 | { |
| 636 | trace(", "); |
| 637 | } |
| 638 | trace(j); |
| 639 | rslt.Expect(setout.contains(j), 'setout.contains($j)'); |
| 640 | } |
| 641 | trace("}"); |
| 642 | rslt.Expect(setin.size == setout.size, "setin.length == setout.length"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 643 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 644 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 645 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_BASETYPES); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 646 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 647 | trace("testEnum(ONE)"); |
| 648 | var ret = client.testEnum(Numberz.ONE); |
| 649 | trace(" = " + ret); |
| 650 | rslt.Expect(ret == Numberz.ONE, '$ret == Numberz.ONE'); |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 651 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 652 | trace("testEnum(TWO)"); |
| 653 | ret = client.testEnum(Numberz.TWO); |
| 654 | trace(" = " + ret); |
| 655 | rslt.Expect(ret == Numberz.TWO, '$ret == Numberz.TWO'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 656 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 657 | trace("testEnum(THREE)"); |
| 658 | ret = client.testEnum(Numberz.THREE); |
| 659 | trace(" = " + ret); |
| 660 | rslt.Expect(ret == Numberz.THREE, '$ret == Numberz.THREE'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 661 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 662 | trace("testEnum(FIVE)"); |
| 663 | ret = client.testEnum(Numberz.FIVE); |
| 664 | trace(" = " + ret); |
| 665 | rslt.Expect(ret == Numberz.FIVE, '$ret == Numberz.FIVE'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 666 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 667 | trace("testEnum(EIGHT)"); |
| 668 | ret = client.testEnum(Numberz.EIGHT); |
| 669 | trace(" = " + ret); |
| 670 | rslt.Expect(ret == Numberz.EIGHT, '$ret == Numberz.EIGHT'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 671 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 672 | trace("testTypedef(309858235082523)"); |
| 673 | var uid = client.testTypedef( Int64.make( 0x119D0, 0x7E08671B)); // 309858235082523 |
| 674 | trace(" = " + uid); |
| 675 | rslt.Expect( Int64.compare( uid, Int64.make( 0x119D0, 0x7E08671B)) == 0, |
| 676 | Int64.toStr(uid)+" == "+Int64.toStr(Int64.make( 0x119D0, 0x7E08671B))); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 677 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 678 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 679 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_CONTAINERS); |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 680 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 681 | trace("testMapMap(1)"); |
| 682 | var mm = client.testMapMap(1); |
| 683 | trace(" = {"); |
| 684 | for( key in mm.keys()) |
| 685 | { |
| 686 | trace(key + " => {"); |
| 687 | var m2 = mm.get(key); |
| 688 | for( k2 in m2.keys()) |
| 689 | { |
| 690 | trace(k2 + " => " + m2.get(k2) + ", "); |
| 691 | } |
| 692 | trace("}, "); |
| 693 | } |
| 694 | trace("}"); |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 695 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 696 | var pos = mm.get(4); |
| 697 | var neg = mm.get(-4); |
| 698 | rslt.Expect( (pos != null) && (neg != null), "(pos != null) && (neg != null)"); |
| 699 | for (i in 0 ... 5) { |
| 700 | rslt.Expect( pos.get(i) == i, 'pos.get($i) == $i'); |
| 701 | rslt.Expect( neg.get(-i) == -i, 'neg.get(-$i) == -$i'); |
| 702 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 703 | |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 704 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 705 | rslt.StartTestGroup( TestResults.EXITCODE_FAILBIT_STRUCTS); |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 706 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 707 | var insane = new Insanity(); |
| 708 | insane.userMap = new IntMap< Int64>(); |
| 709 | insane.userMap.set( Numberz.FIVE, Int64.make(0,5000)); |
| 710 | var truck = new Xtruct(); |
| 711 | truck.string_thing = "Truck"; |
| 712 | truck.byte_thing = 8; |
| 713 | truck.i32_thing = 8; |
| 714 | truck.i64_thing = Int64.make(0,8); |
| 715 | insane.xtructs = new List<Xtruct>(); |
| 716 | insane.xtructs.add(truck); |
| 717 | trace("testInsanity()"); |
| 718 | var whoa = client.testInsanity(insane); |
| 719 | trace(" = {"); |
| 720 | for( key in whoa.keys()) |
| 721 | { |
| 722 | var val = whoa.get(key); |
| 723 | trace(key + " => {"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 724 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 725 | for( k2 in val.keys()) |
| 726 | { |
| 727 | var v2 = val.get(k2); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 728 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 729 | trace(k2 + " => {"); |
| 730 | var userMap = v2.userMap; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 731 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 732 | trace("{"); |
| 733 | if (userMap != null) |
| 734 | { |
| 735 | for( k3 in userMap.keys()) |
| 736 | { |
| 737 | trace(k3 + " => " + userMap.get(k3) + ", "); |
| 738 | } |
| 739 | } |
| 740 | else |
| 741 | { |
| 742 | trace("null"); |
| 743 | } |
| 744 | trace("}, "); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 745 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 746 | var xtructs = v2.xtructs; |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 747 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 748 | trace("{"); |
| 749 | if (xtructs != null) |
| 750 | { |
| 751 | for( x in xtructs) |
| 752 | { |
| 753 | trace("{\"" + x.string_thing + "\", " |
| 754 | + x.byte_thing + ", " + x.i32_thing + ", " |
| 755 | + x.i32_thing + "}, "); |
| 756 | } |
| 757 | } |
| 758 | else |
| 759 | { |
| 760 | trace("null"); |
| 761 | } |
| 762 | trace("}"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 763 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 764 | trace("}, "); |
| 765 | } |
| 766 | trace("}, "); |
| 767 | } |
| 768 | trace("}"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 769 | |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 770 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 771 | var first_map = whoa.get(Int64.make(0,1)); |
| 772 | var second_map = whoa.get(Int64.make(0,2)); |
| 773 | rslt.Expect( (first_map != null) && (second_map != null), "(first_map != null) && (second_map != null)"); |
| 774 | if ((first_map != null) && (second_map != null)) |
| 775 | { |
| 776 | var crazy2 = first_map.get(Numberz.TWO); |
| 777 | var crazy3 = first_map.get(Numberz.THREE); |
| 778 | var looney = second_map.get(Numberz.SIX); |
| 779 | rslt.Expect( (crazy2 != null) && (crazy3 != null) && (looney != null), |
| 780 | "(crazy2 != null) && (crazy3 != null) && (looney != null)"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 781 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 782 | rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0, |
| 783 | "crazy2.UserMap.get(Numberz.EIGHT) == 8"); |
| 784 | rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.EIGHT), Int64.make(0,8)) == 0, |
| 785 | "crazy3.UserMap.get(Numberz.EIGHT) == 8"); |
| 786 | rslt.Expect( Int64.compare( crazy2.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0, |
| 787 | "crazy2.UserMap.get(Numberz.FIVE) == 5"); |
| 788 | rslt.Expect( Int64.compare( crazy3.userMap.get(Numberz.FIVE), Int64.make(0,5)) == 0, |
| 789 | "crazy3.UserMap.get(Numberz.FIVE) == 5"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 790 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 791 | var crz2iter = crazy2.xtructs.iterator(); |
| 792 | var crz3iter = crazy3.xtructs.iterator(); |
| 793 | rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()"); |
| 794 | var goodbye2 = crz2iter.next(); |
| 795 | var goodbye3 = crz3iter.next(); |
| 796 | rslt.Expect( crz2iter.hasNext() && crz3iter.hasNext(), "crz2iter.hasNext() && crz3iter.hasNext()"); |
| 797 | var hello2 = crz2iter.next(); |
| 798 | var hello3 = crz3iter.next(); |
| 799 | rslt.Expect( ! (crz2iter.hasNext() || crz3iter.hasNext()), "! (crz2iter.hasNext() || crz3iter.hasNext())"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 800 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 801 | rslt.Expect( hello2.string_thing == "Hello2", 'hello2.String_thing == "Hello2"'); |
| 802 | rslt.Expect( hello2.byte_thing == 2, 'hello2.Byte_thing == 2'); |
| 803 | rslt.Expect( hello2.i32_thing == 2, 'hello2.I32_thing == 2'); |
| 804 | rslt.Expect( Int64.compare( hello2.i64_thing, Int64.make(0,2)) == 0, 'hello2.I64_thing == 2'); |
| 805 | rslt.Expect( hello3.string_thing == "Hello2", 'hello3.String_thing == "Hello2"'); |
| 806 | rslt.Expect( hello3.byte_thing == 2, 'hello3.Byte_thing == 2'); |
| 807 | rslt.Expect( hello3.i32_thing == 2, 'hello3.I32_thing == 2'); |
| 808 | rslt.Expect( Int64.compare( hello3.i64_thing, Int64.make(0,2)) == 0, 'hello3.I64_thing == 2'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 809 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 810 | rslt.Expect( goodbye2.string_thing == "Goodbye4", 'goodbye2.String_thing == "Goodbye4"'); |
| 811 | rslt.Expect( goodbye2.byte_thing == 4, 'goodbye2.Byte_thing == 4'); |
| 812 | rslt.Expect( goodbye2.i32_thing == 4, 'goodbye2.I32_thing == 4'); |
| 813 | rslt.Expect( Int64.compare( goodbye2.i64_thing, Int64.make(0,4)) == 0, 'goodbye2.I64_thing == 4'); |
| 814 | rslt.Expect( goodbye3.string_thing == "Goodbye4", 'goodbye3.String_thing == "Goodbye4"'); |
| 815 | rslt.Expect( goodbye3.byte_thing == 4, 'goodbye3.Byte_thing == 4'); |
| 816 | rslt.Expect( goodbye3.i32_thing == 4, 'goodbye3.I32_thing == 4'); |
| 817 | rslt.Expect( Int64.compare( goodbye3.i64_thing, Int64.make(0,4)) == 0, 'goodbye3.I64_thing == 4'); |
| 818 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 819 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 820 | var arg0 = 1; |
| 821 | var arg1 = 2; |
| 822 | var arg2 = Int64.make( 0x7FFFFFFF,0xFFFFFFFF); |
| 823 | var multiDict = new IntMap< String>(); |
| 824 | multiDict.set(1, "one"); |
| 825 | var arg4 = Numberz.FIVE; |
| 826 | var arg5 = Int64.make(0,5000000); |
| 827 | trace("Test Multi(" + arg0 + "," + arg1 + "," + arg2 + "," + multiDict + "," + arg4 + "," + arg5 + ")"); |
| 828 | var multiResponse = client.testMulti(arg0, arg1, arg2, multiDict, arg4, arg5); |
| 829 | trace(" = Xtruct(byte_thing:" + multiResponse.byte_thing + ",string_thing:" + multiResponse.string_thing |
| 830 | + ",i32_thing:" + multiResponse.i32_thing |
| 831 | + ",i64_thing:" + Int64.toStr(multiResponse.i64_thing) + ")"); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 832 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 833 | rslt.Expect( multiResponse.string_thing == "Hello2", 'multiResponse.String_thing == "Hello2"'); |
| 834 | rslt.Expect( multiResponse.byte_thing == arg0, 'multiResponse.Byte_thing == arg0'); |
| 835 | rslt.Expect( multiResponse.i32_thing == arg1, 'multiResponse.I32_thing == arg1'); |
| 836 | rslt.Expect( Int64.compare( multiResponse.i64_thing, arg2) == 0, 'multiResponse.I64_thing == arg2'); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 837 | |
| 838 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 839 | rslt.StartTestGroup( 0); |
Jens Geyer | fea00ac | 2014-10-01 02:22:48 +0200 | [diff] [blame] | 840 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 841 | trace("Test Oneway(1)"); |
| 842 | client.testOneway(1); |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 843 | |
Jens Geyer | b502832 | 2014-11-09 02:38:11 +0100 | [diff] [blame] | 844 | if( ! args.skipSpeedTest) { |
| 845 | trace("Test Calltime()"); |
| 846 | var difft = Timer.stamp(); |
| 847 | for ( k in 0 ... 1000) { |
| 848 | client.testVoid(); |
| 849 | } |
| 850 | difft = Timer.stamp() - difft; |
| 851 | trace('$difft ms per testVoid() call'); |
| 852 | } |
| 853 | } |
Jens Geyer | bd52f1a | 2014-07-28 01:25:30 +0200 | [diff] [blame] | 854 | } |