From 361d712b010efea743b61428a1427dc1dbfee86f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 2 Jun 1999 20:23:58 +0000 Subject: [PATCH] Initial revision git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@831 379699f6-c40d-0410-875b-85095c16579e --- jode/test/OptimizerTest.java | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 jode/test/OptimizerTest.java diff --git a/jode/test/OptimizerTest.java b/jode/test/OptimizerTest.java new file mode 100644 index 0000000..b2509de --- /dev/null +++ b/jode/test/OptimizerTest.java @@ -0,0 +1,59 @@ +/** + * This class should be optimized through the obfuscator: + * + *
+ *  java jode.Obfuscator --dest tmp.zip --preserve 'jode.test.OptimizerTest.test.(*)*' jode
+ * 
+ */ +package jode.test; + +public class OptimizerTest { + String blah, blub; + Object o; + + private static String manipulateString(String input) { + char[] chars = input.toCharArray(); + char[] dests = new char[chars.length]; + dests[0] = chars[0]; + for (int i=1; i< chars.length; i++) { + if (chars[i] > chars[i-1]) { + dests[i] = (char) (chars[i] - chars[i-1]); + } else if (chars[i] == chars[i-1]) { + dests[i] = 0; + } else if (chars[i] < chars[i-1]) { + dests[i] = (char) (Character.MAX_VALUE + - (chars[i-1] - chars[i] - 1)); + } else + dests[i] = 'X'; + } + return new String(dests); + } + + public static String doubleCompare(double d1, double d2) { + return d1 + ((d1 > d2) ? " > " + : (d1 < d2) ? " < " + : (d1 == d2) ? " == " : " ?? ") + d2; + } + + public void test() { + System.err.println(manipulateString("ABCDEFGGFEDCBA")); + blah = manipulateString("hello world"); + o = new Object(); + blub = "Hallo"+manipulateString("ABCDEFGGFDECBA"); + System.err.println(blub); + + System.err.println(doubleCompare(0.0, 0.0)); + System.err.println(doubleCompare(0.0, 1.0)); + System.err.println(doubleCompare(0.0, -1.0)); + System.err.println(doubleCompare(0.0, Double.NaN)); + System.err.println(doubleCompare(Double.NaN, 0.0)); + System.err.println(doubleCompare(Double.NaN, Double.NaN)); + System.err.println(doubleCompare(Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY)); + + System.err.println(doubleCompare(Math.exp(1), 2.718281828459045)); + + System.err.println((int)Math.round(Math.exp(Math.log(5)*5))/ 625); + } +} +