From bbc121d9d2b7bc3bf6eb80f0fec55cca76894421 Mon Sep 17 00:00:00 2001 From: dsavvinov Date: Thu, 18 Aug 2016 11:19:05 +0300 Subject: [PATCH] Protobuf: fixed bug in PRNG in native tests --- .../test/kotlin/tests/kotlin/proto_repeated_varint.kt | 5 +++-- .../test/kotlin/tests/kotlin/proto_repeated_zigzag.kt | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/translator/src/test/kotlin/tests/kotlin/proto_repeated_varint.kt b/translator/src/test/kotlin/tests/kotlin/proto_repeated_varint.kt index 6c907abc3b9..2fab5f5435e 100644 --- a/translator/src/test/kotlin/tests/kotlin/proto_repeated_varint.kt +++ b/translator/src/test/kotlin/tests/kotlin/proto_repeated_varint.kt @@ -1134,14 +1134,15 @@ fun checkRepSerializationIdentity(msg: MessageRepeatedVarints): Int { } } + object Rng { var rngState = 0.6938893903907228 val point = 762939453125 fun rng(): Double { - val res = rngState - rngState.toInt().toDouble() rngState *= point.toDouble() - return res + rngState -= rngState.toLong().toDouble() + return rngState } } diff --git a/translator/src/test/kotlin/tests/kotlin/proto_repeated_zigzag.kt b/translator/src/test/kotlin/tests/kotlin/proto_repeated_zigzag.kt index dcea6007d0a..e2e4c72a44a 100644 --- a/translator/src/test/kotlin/tests/kotlin/proto_repeated_zigzag.kt +++ b/translator/src/test/kotlin/tests/kotlin/proto_repeated_zigzag.kt @@ -435,14 +435,15 @@ fun checkRepZZSerializationIdentity(msg: MessageRepeatedZigZag): Int { } } + object Rng { var rngState = 0.6938893903907228 val point = 762939453125 fun rng(): Double { - val res = rngState - rngState.toInt().toDouble() rngState *= point.toDouble() - return res + rngState -= rngState.toLong().toDouble() + return rngState } } @@ -544,3 +545,7 @@ fun testArraysOfDefaultValues(): Int { val msg = MessageRepeatedZigZag.BuilderMessageRepeatedZigZag(intArr, longArr).build() return checkRepZZSerializationIdentity(msg) } + +fun main(args: Array) { + println(testRepZigZag()) +} \ No newline at end of file