diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/haxe/test/HaxeTests.hxproj | 3 | ||||
-rw-r--r-- | lib/haxe/test/cpp.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/csharp.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/flash.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/java.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/javascript.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/make_all.bat | 1 | ||||
-rw-r--r-- | lib/haxe/test/neko.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/php.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/python.hxml | 5 | ||||
-rw-r--r-- | lib/haxe/test/src/ConstantsTest.hx | 74 | ||||
-rw-r--r-- | lib/haxe/test/src/Main.hx | 5 | ||||
-rw-r--r-- | lib/haxe/test/src/MultiplexTest.hx | 4 | ||||
-rw-r--r-- | lib/haxe/test/src/StreamTest.hx | 4 | ||||
-rw-r--r-- | lib/haxe/test/src/TestBase.hx | 1 |
15 files changed, 127 insertions, 5 deletions
diff --git a/lib/haxe/test/HaxeTests.hxproj b/lib/haxe/test/HaxeTests.hxproj index 7ad23920d..839917b47 100644 --- a/lib/haxe/test/HaxeTests.hxproj +++ b/lib/haxe/test/HaxeTests.hxproj @@ -26,7 +26,7 @@ <option noInlineOnDebug="False" /> <option mainClass="Main" /> <option enabledebug="False" /> - <option additional="--macro include('org.apache.thrift', true)
--macro include('thrift', true)" /> + <option additional="--macro include('org.apache.thrift', true)
--macro include('thrift', true)
--macro include('constantsDemo', true)" /> </build> <!-- haxelib libraries --> <haxelib> @@ -54,6 +54,7 @@ </hiddenPaths> <!-- Executed before build --> <preBuildCommand>thrift -r -gen haxe ../../../test/ThriftTest.thrift +thrift -r -gen haxe ../../../test/ConstantsDemo.thrift thrift -r -gen haxe ../../../contrib/async-test/aggr.thrift thrift -r -gen haxe ../../../lib/rb/benchmark/Benchmark.thrift</preBuildCommand> <!-- Executed after build --> diff --git a/lib/haxe/test/cpp.hxml b/lib/haxe/test/cpp.hxml index 73848a8bc..28e1a017e 100644 --- a/lib/haxe/test/cpp.hxml +++ b/lib/haxe/test/cpp.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #CPP target -cpp bin diff --git a/lib/haxe/test/csharp.hxml b/lib/haxe/test/csharp.hxml index 4c34b0d94..6ddfd0767 100644 --- a/lib/haxe/test/csharp.hxml +++ b/lib/haxe/test/csharp.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #CSHARP target -cs bin/Test.exe diff --git a/lib/haxe/test/flash.hxml b/lib/haxe/test/flash.hxml index 8b1763190..130ab78d4 100644 --- a/lib/haxe/test/flash.hxml +++ b/lib/haxe/test/flash.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #Flash target -swf bin/Test.swf diff --git a/lib/haxe/test/java.hxml b/lib/haxe/test/java.hxml index c9471597c..b72d99fb9 100644 --- a/lib/haxe/test/java.hxml +++ b/lib/haxe/test/java.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #Java target -java bin/Test.jar diff --git a/lib/haxe/test/javascript.hxml b/lib/haxe/test/javascript.hxml index 18d9964c2..496e780ba 100644 --- a/lib/haxe/test/javascript.hxml +++ b/lib/haxe/test/javascript.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #JavaScript target -js bin/Test.js diff --git a/lib/haxe/test/make_all.bat b/lib/haxe/test/make_all.bat index 0314e18a3..8a063dd7c 100644 --- a/lib/haxe/test/make_all.bat +++ b/lib/haxe/test/make_all.bat @@ -27,6 +27,7 @@ set path=%HAXEPATH%;%HAXEPATH%\..\neko;%path% rem # invoke Thrift comnpiler thrift -r -gen haxe ..\..\..\test\ThriftTest.thrift +thrift -r -gen haxe ..\..\..\test\ConstantsDemo.thrift thrift -r -gen haxe ..\..\..\contrib\async-test\aggr.thrift thrift -r -gen haxe ..\..\..\lib\rb\benchmark\Benchmark.thrift if errorlevel 1 goto STOP diff --git a/lib/haxe/test/neko.hxml b/lib/haxe/test/neko.hxml index 2db70c8e6..eed22bd70 100644 --- a/lib/haxe/test/neko.hxml +++ b/lib/haxe/test/neko.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #neko target -neko bin/Test.n diff --git a/lib/haxe/test/php.hxml b/lib/haxe/test/php.hxml index 9fc23b6b0..3af54dab5 100644 --- a/lib/haxe/test/php.hxml +++ b/lib/haxe/test/php.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #PHP target -php bin/php/ #--php-front Main-debug.php diff --git a/lib/haxe/test/python.hxml b/lib/haxe/test/python.hxml index 4d6a133d6..58eb3cb71 100644 --- a/lib/haxe/test/python.hxml +++ b/lib/haxe/test/python.hxml @@ -25,6 +25,11 @@ #this class wil be used as entry point for your app. -main Main +# forced compile of all source files +--macro include('org.apache.thrift', true) +--macro include('thrift', true) +--macro include('constantsDemo', true) + #Python target -python bin/Test.py diff --git a/lib/haxe/test/src/ConstantsTest.hx b/lib/haxe/test/src/ConstantsTest.hx new file mode 100644 index 000000000..d0041e49f --- /dev/null +++ b/lib/haxe/test/src/ConstantsTest.hx @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package; + +import haxe.Int64; + +import org.apache.thrift.*; +import org.apache.thrift.protocol.*; +import org.apache.thrift.transport.*; +import org.apache.thrift.server.*; +import org.apache.thrift.meta_data.*; + +import constantsDemo.*; // generated code + + +class ConstantsTest extends TestBase { + + public static function Run(server : Bool) : Void + { + TestBase.Expect( ConstantsDemoConstants.myInt == 3, "myInt = 3"); + TestBase.Expect( ConstantsDemoConstants.hex_const == 0x0001F, "hex_const = 31"); + TestBase.Expect( ConstantsDemoConstants.negative_hex_constant == -0x0001F, "negative_hex_constant = -31"); + TestBase.Expect( ConstantsDemoConstants.GEN_ME == -3523553, "GEN_ME = -3523553"); + TestBase.Expect( ConstantsDemoConstants.GEn_DUB == 325.532, "GEn_DUB = 325.532"); + TestBase.Expect( ConstantsDemoConstants.GEn_DU == 85.2355, "GEn_DU = 85.2355"); + TestBase.Expect( ConstantsDemoConstants.GEN_STRING == "asldkjasfd", "GEN_STRING = \"asldkjasfd\""); + TestBase.Expect( ConstantsDemoConstants.e10 == 1e+10, "e10 = 1e+10"); + TestBase.Expect( ConstantsDemoConstants.e11 == -1e+10, "e11 = -1e+10"); + TestBase.Expect( ConstantsDemoConstants.GEN_UUID == "00000000-4444-CCCC-ffff-0123456789ab", "GEN_UUID = \"00000000-4444-CCCC-ffff-0123456789ab\""); + + TestBase.Expect( ConstantsDemoConstants.GEN_MAP.get(35532) == 233, "GEN_MAP.get(35532) == 233"); + TestBase.Expect( ConstantsDemoConstants.GEN_MAP.get(43523) == 853, "GEN_MAP.get(43523) == 853"); + + TestBase.Expect( ConstantsDemoConstants.GEN_LIST.length == 3, "GEN_LIST.size() == 3"); + TestBase.Expect( ConstantsDemoConstants.GEN_LIST.join("/") == "235235/23598352/3253523", "GEN_LIST elements"); + + TestBase.Expect( ConstantsDemoConstants.GEN_MAPMAP.get(235).get(532) == 53255, "GEN_MAPMAP.get(235).get(532) == 53255"); + TestBase.Expect( ConstantsDemoConstants.GEN_MAPMAP.get(235).get(235) == 235, "GEN_MAPMAP.get(235).get(235) == 235"); + + TestBase.Expect( ConstantsDemoConstants.GEN_MAP2.get("hello") == 233, "GEN_MAP2.get(\"hello\") == 233"); + TestBase.Expect( ConstantsDemoConstants.GEN_MAP2.get("lkj98d") == 853, "GEN_MAP2.get(\"lkj98d\") == 853"); + TestBase.Expect( ConstantsDemoConstants.GEN_MAP2.get('lkjsdf') == 98325, "GEN_MAP2.get('lkjsdf') == 98325"); + + TestBase.Expect( ConstantsDemoConstants.GEN_THING.hello == 325, "GEN_THING.hello == 325"); + TestBase.Expect( ConstantsDemoConstants.GEN_THING.goodbye == 325352, "GEN_THING.goodbye == 325352"); + + TestBase.Expect( ConstantsDemoConstants.GEN_WHAT.get(35).hello == 325, "GEN_WHAT.get(35).hello == 325"); + TestBase.Expect( ConstantsDemoConstants.GEN_WHAT.get(35).goodbye == 325352, "GEN_WHAT.get(35).goodbye == 325352"); + + TestBase.Expect( ConstantsDemoConstants.GEN_SET.size == 2, "GEN_SET.size() == 2"); + TestBase.Expect( ConstantsDemoConstants.GEN_SET.contains(235), "GEN_SET.contains(235)"); // added twice, but this is a set + TestBase.Expect( ConstantsDemoConstants.GEN_SET.contains(53235), "GEN_SET.contains(53235)"); + } + +} + + diff --git a/lib/haxe/test/src/Main.hx b/lib/haxe/test/src/Main.hx index 6c262d78f..e04af78b0 100644 --- a/lib/haxe/test/src/Main.hx +++ b/lib/haxe/test/src/Main.hx @@ -31,6 +31,7 @@ import thrift.test.*; // generated code enum WhatTests { Normal; Multiplex; + Constants; } class Main @@ -56,6 +57,8 @@ class Main server = true; case "multiplex" : tests = Multiplex; + case "constants" : + tests = Constants; default: throw 'Invalid argument "$arg"\n'+CMDLINEHELP; } @@ -76,6 +79,8 @@ class Main StreamTest.Run(server); case Multiplex: MultiplexTest.Run(server); + case Constants: + ConstantsTest.Run(server); default: throw "Unhandled test mode $tests"; } diff --git a/lib/haxe/test/src/MultiplexTest.hx b/lib/haxe/test/src/MultiplexTest.hx index 3e2786db5..74fa357fe 100644 --- a/lib/haxe/test/src/MultiplexTest.hx +++ b/lib/haxe/test/src/MultiplexTest.hx @@ -48,7 +48,7 @@ class BenchmarkServiceHandler implements BenchmarkService_service public function new() { } - public function fibonacci(n : haxe.Int32) : haxe.Int32 { + public function fibonacci(n : haxe.Int32) : haxe.Int32 { trace('Benchmark.fibonacci($n)'); var next : Int; var prev = 0; @@ -60,7 +60,7 @@ class BenchmarkServiceHandler implements BenchmarkService_service result = next; --n; } - return result; + return result; } } diff --git a/lib/haxe/test/src/StreamTest.hx b/lib/haxe/test/src/StreamTest.hx index 9b8706a57..4744272a5 100644 --- a/lib/haxe/test/src/StreamTest.hx +++ b/lib/haxe/test/src/StreamTest.hx @@ -48,7 +48,7 @@ class StreamTest extends TestBase { public static function WriteData() : Xtruct { - var config : TConfiguration = new TConfiguration(); + var config : TConfiguration = new TConfiguration(); var stream : TStream = new TFileStream( tmpfile, CreateNew); var trans : TTransport = new TStreamTransport( null, stream, config); var prot = new TJSONProtocol( trans); @@ -62,7 +62,7 @@ class StreamTest extends TestBase { public static function ReadData() : Xtruct { - var config : TConfiguration = new TConfiguration(); + var config : TConfiguration = new TConfiguration(); var stream : TStream = new TFileStream( tmpfile, Read); var trans : TTransport = new TStreamTransport( stream, null, config); var prot = new TJSONProtocol( trans); diff --git a/lib/haxe/test/src/TestBase.hx b/lib/haxe/test/src/TestBase.hx index 12327737a..865a801a9 100644 --- a/lib/haxe/test/src/TestBase.hx +++ b/lib/haxe/test/src/TestBase.hx @@ -40,6 +40,7 @@ class TestBase { if( ! expr) { throw ('Test "$info" failed at '+pos.methodName+' in '+pos.fileName+':'+pos.lineNumber); } + trace('Test "$info" - OK'); } } |