diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2023-07-06 12:41:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-06 12:41:33 +0200 |
commit | 0c94c8cf85824c2a8798a4c72d345738b1583388 (patch) | |
tree | fcf278acc366f05b3355fe786cb0d8dde9fcce8f /src/test/java | |
parent | b3b43eed2fe6677741ee52065016f319b6c9d723 (diff) | |
download | NotEnoughUpdates-0c94c8cf85824c2a8798a4c72d345738b1583388.tar.gz NotEnoughUpdates-0c94c8cf85824c2a8798a4c72d345738b1583388.tar.bz2 NotEnoughUpdates-0c94c8cf85824c2a8798a4c72d345738b1583388.zip |
Fix calculator preop operations (#758)
Fix calculator postop operations
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/io/github/moulberry/notenoughupdates/util/CalculatorTest.java | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/src/test/java/io/github/moulberry/notenoughupdates/util/CalculatorTest.java b/src/test/java/io/github/moulberry/notenoughupdates/util/CalculatorTest.java deleted file mode 100644 index eff4a8de..00000000 --- a/src/test/java/io/github/moulberry/notenoughupdates/util/CalculatorTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2022 NotEnoughUpdates contributors - * - * This file is part of NotEnoughUpdates. - * - * NotEnoughUpdates is free software: you can redistribute it - * and/or modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation, either - * version 3 of the License, or (at your option) any later version. - * - * NotEnoughUpdates is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. - */ - -package io.github.moulberry.notenoughupdates.util; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Optional; -import java.util.Scanner; - -public class CalculatorTest { - public static void main(String[] args) throws Calculator.CalculatorException { - Scanner s = new Scanner(System.in); - while (true) { - try { - List<Calculator.Token> lex = Calculator.lex(s.nextLine()); - List<Calculator.Token> shunted = Calculator.shuntingYard(lex); - for (Calculator.Token rawToken : shunted) { - System.out.printf( - "%s(%s)", - rawToken.type, - rawToken.operatorValue == null - ? rawToken.numericValue + " * 10 ^ " + rawToken.exponent - : rawToken.operatorValue - ); - } - System.out.println(); - BigDecimal evaluate = Calculator.evaluate(name -> Optional.of(BigDecimal.valueOf(16)), shunted); - System.out.println("Eval: " + evaluate); - } catch (Calculator.CalculatorException e) { - e.printStackTrace(); - } - } - } - -} |