From 9af356503d590142590bcfb2c8c2d90015582036 Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Tue, 23 Aug 2016 18:10:09 +0300 Subject: [PATCH] translator: add test on side effects in while argument --- .../tests/input/while_argument_side_effects_1.txt | 1 + .../tests/kotlin/while_argument_side_effects_1.kt | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 translator/src/test/kotlin/tests/input/while_argument_side_effects_1.txt create mode 100644 translator/src/test/kotlin/tests/kotlin/while_argument_side_effects_1.kt diff --git a/translator/src/test/kotlin/tests/input/while_argument_side_effects_1.txt b/translator/src/test/kotlin/tests/input/while_argument_side_effects_1.txt new file mode 100644 index 00000000000..aab348e4066 --- /dev/null +++ b/translator/src/test/kotlin/tests/input/while_argument_side_effects_1.txt @@ -0,0 +1 @@ +while_argument_side_effects_1() == 10099 diff --git a/translator/src/test/kotlin/tests/kotlin/while_argument_side_effects_1.kt b/translator/src/test/kotlin/tests/kotlin/while_argument_side_effects_1.kt new file mode 100644 index 00000000000..85599858a3c --- /dev/null +++ b/translator/src/test/kotlin/tests/kotlin/while_argument_side_effects_1.kt @@ -0,0 +1,15 @@ +object while_argument_side_effects_1_Counter{ + var cnt = 0 + fun isEnd():Boolean{ + cnt += 1 + return cnt < 10 + } +} + +fun while_argument_side_effects_1():Int{ + var iter = 0 + while(while_argument_side_effects_1_Counter.isEnd()){ + iter += 1 + } + return iter+ 1009*while_argument_side_effects_1_Counter.cnt +} \ No newline at end of file