From 879cb177d0bdded3875469baf17977943c9576ef Mon Sep 17 00:00:00 2001 From: Pilow Date: Sun, 1 Oct 2023 10:44:41 +0200 Subject: [PATCH] fix minus on int|real --- src/main/java/leekscript/runner/AI.java | 5 +++++ src/test/java/test/TestInterval.java | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/leekscript/runner/AI.java b/src/main/java/leekscript/runner/AI.java index 85c72e19..58bffc93 100644 --- a/src/main/java/leekscript/runner/AI.java +++ b/src/main/java/leekscript/runner/AI.java @@ -1001,6 +1001,11 @@ public Object minus(Object value) throws LeekRunException { return -longint(value); } + public Number minus(Number value) throws LeekRunException { + if (value instanceof Double) return -((Double) value); + return -longint(value); + } + public long bnot(Object value) throws LeekRunException { return LeekValueManager.bnot(this, value); } diff --git a/src/test/java/test/TestInterval.java b/src/test/java/test/TestInterval.java index 9c5322c6..2f305baf 100644 --- a/src/test/java/test/TestInterval.java +++ b/src/test/java/test/TestInterval.java @@ -40,6 +40,7 @@ public void run() throws Exception { code("return intervalMin([1..0])").equals("1"); code("return intervalMin(]..[)").equals("-∞"); code("intervalMin([1..2])").ops(3); + code_v3_("Interval inter = [1..10] integer min = -intervalMin(inter) return min").equals("-1"); section("Interval.intervalMax"); code("return intervalMax([1..2])").equals("2");