From ec10240c52fbb18da701ea851ae7972c66b62c9f Mon Sep 17 00:00:00 2001 From: Volker Date: Fri, 3 Aug 2018 19:42:20 +0200 Subject: [PATCH] add tests for compare of non int data values --- .../runtime/ControlFlowOperators.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java b/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java index f445b3a..66d6065 100644 --- a/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java +++ b/test/de/inetsoftware/jwebassembly/runtime/ControlFlowOperators.java @@ -43,6 +43,7 @@ public class ControlFlowOperators extends AbstractBaseTest { addParam( list, script, "ifne" ); addParam( list, script, "iflt" ); addParam( list, script, "ifMultiple" ); + addParam( list, script, "ifMultipleDouble" ); addParam( list, script, "ifCompare" ); addParam( list, script, "switchDirect" ); addParam( list, script, "endlessLoop" ); @@ -129,6 +130,54 @@ public class ControlFlowOperators extends AbstractBaseTest { return condition; } + @Export + static int ifMultipleDouble() { + double condition = 3; + if( condition <= 0 ) { + if( condition < 0 ) { + condition = 13; + } + } else { + if( condition > 0 ) { + condition++; + } else { + condition--; + } + } + if( condition > 2 ) { + condition *= 2; + } else { + condition = 0; + } + if( condition >= 2 ) { + condition *= 2; + } else { + condition = 0; + } + if( condition <= 123 ) { + condition *= 2; + } else { + condition = 0; + } + if( condition < 123 ) { + condition *= 2; + } else { + condition = 0; + } + if( condition != 123 ) { + condition *= 2; + } else { + condition = 0; + } + if( condition == 123 ) { + condition = 0; + } else { + condition *= 2; + } + int x = (int)(25 / condition); // prevent 0 as value + return (int)condition; + } + @Export static int ifCompare() { double condition = 3.0;