vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 11 Feb 2013 12:46:43 +0100
branchemul
changeset 708 59d5596a9c6c
parent 680 7ffb635a5c4f
child 747 ae352b763959
permissions -rw-r--r--
Encapsulation. Moving shared code into TestVM instance.
jaroslav@114
     1
/**
jaroslav@114
     2
 * Back 2 Browser Bytecode Translator
jaroslav@114
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@114
     4
 *
jaroslav@114
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@114
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@114
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@114
     8
 *
jaroslav@114
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@114
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@114
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@114
    12
 * GNU General Public License for more details.
jaroslav@114
    13
 *
jaroslav@114
    14
 * You should have received a copy of the GNU General Public License
jaroslav@114
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@114
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@114
    17
 */
jaroslav@114
    18
package org.apidesign.vm4brwsr;
jaroslav@114
    19
jtulach@132
    20
import static org.testng.Assert.*;
jaroslav@114
    21
import org.testng.annotations.BeforeClass;
jaroslav@114
    22
import org.testng.annotations.Test;
jaroslav@114
    23
jaroslav@114
    24
/**
jaroslav@114
    25
 *
jaroslav@114
    26
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@114
    27
 */
jaroslav@114
    28
public class NumberTest {
jaroslav@114
    29
    @Test public void integerFromString() throws Exception {
jaroslav@248
    30
        assertExec("Can convert string to integer", Integer.class, "parseInt__ILjava_lang_String_2",
jaroslav@114
    31
            Double.valueOf(333), "333"
jaroslav@114
    32
        );
jaroslav@114
    33
    }
jaroslav@114
    34
jaroslav@114
    35
    @Test public void doubleFromString() throws Exception {
jaroslav@248
    36
        assertExec("Can convert string to double", Double.class, "parseDouble__DLjava_lang_String_2",
jaroslav@114
    37
            Double.valueOf(33.3), "33.3"
jaroslav@114
    38
        );
jaroslav@114
    39
    }
jaroslav@114
    40
jaroslav@114
    41
    @Test public void autoboxDouble() throws Exception {
jaroslav@248
    42
        assertExec("Autoboxing of doubles is OK", Numbers.class, "autoboxDblToString__Ljava_lang_String_2",
jaroslav@114
    43
            "3.3"
jaroslav@114
    44
        );
jaroslav@114
    45
    }
jtulach@132
    46
    
jtulach@132
    47
    @Test public void javalog1000() throws Exception {
jtulach@132
    48
        assertEquals(3.0, Math.log10(1000.0), 0.00003, "log_10(1000) == 3");
jtulach@132
    49
    }
jtulach@132
    50
jtulach@132
    51
    @Test public void jslog1000() throws Exception {
jaroslav@248
    52
        assertExec("log_10(1000) == 3", Math.class, "log10__DD", 
jtulach@132
    53
            Double.valueOf(3.0), 1000.0
jtulach@132
    54
        );
jtulach@132
    55
    }
jaroslav@178
    56
    
jaroslav@178
    57
    @Test public void javaRem() {
jaroslav@178
    58
        assertEquals(3, Numbers.rem(303, 10));
jaroslav@178
    59
    }
jaroslav@178
    60
    @Test public void jsRem() throws Exception {
jaroslav@248
    61
        assertExec("Should be three", Numbers.class, "rem__III", 
jaroslav@178
    62
            Double.valueOf(3.0), 303, 10
jaroslav@178
    63
        );
jaroslav@178
    64
    }
jaroslav@181
    65
    
jaroslav@181
    66
    @Test public void deserializeInt() throws Exception {
jaroslav@181
    67
        int exp = Numbers.deserInt();
jaroslav@248
    68
        assertExec("Should be the same", Numbers.class, "deserInt__I", 
jaroslav@181
    69
            Double.valueOf(exp)
jaroslav@181
    70
        );
jaroslav@181
    71
    }
jaroslav@185
    72
jaroslav@185
    73
    @Test public void deserializeSimpleLong() throws Exception {
jaroslav@248
    74
        assertExec("Should be 3454", Numbers.class, "deserLong__J_3B", 
jaroslav@185
    75
            Double.valueOf(3454), 
jaroslav@185
    76
            new byte[] { (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)13, (byte)126 }
jaroslav@185
    77
        );
jaroslav@185
    78
    }
jaroslav@185
    79
    /* XXX: JavaScript cannot represent as big longs as Java. 
jaroslav@185
    80
    @Test public void deserializeLargeLong() throws Exception {
jaroslav@185
    81
        final byte[] arr = new byte[] {
jaroslav@185
    82
            (byte)64, (byte)8, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0
jaroslav@185
    83
        };
jaroslav@185
    84
        long exp = Numbers.deserLong(arr);
jaroslav@248
    85
        assertExec("Should be " + exp, "org_apidesign_vm4brwsr_Numbers_deserLong__JAB", 
jaroslav@185
    86
            Double.valueOf(exp), arr);
jaroslav@185
    87
    }
jaroslav@185
    88
    */
jaroslav@181
    89
    
jaroslav@181
    90
    @Test public void deserializeFloatInJava() throws Exception {
jaroslav@181
    91
        float f = 54324.32423f;
jaroslav@181
    92
        float r = Numbers.deserFloat();
jaroslav@181
    93
        assertEquals(r, f, "Floats are the same");
jaroslav@181
    94
    }
jaroslav@181
    95
    
jaroslav@181
    96
    @Test public void deserializeFloatInJS() throws Exception {
jaroslav@181
    97
        float f = 54324.32423f;
jaroslav@248
    98
        assertExec("Should be the same", Numbers.class, "deserFloat__F", 
jaroslav@181
    99
            Double.valueOf(f)
jaroslav@181
   100
        );
jaroslav@181
   101
    }
jaroslav@114
   102
jaroslav@185
   103
    @Test public void deserializeDoubleInJava() throws Exception {
jaroslav@185
   104
        double f = 3.0;
jaroslav@185
   105
        double r = Numbers.deserDouble();
jaroslav@185
   106
        assertEquals(r, f, 0.001, "Doubles are the same");
jaroslav@185
   107
    }
jaroslav@114
   108
    
jaroslav@185
   109
    @Test public void deserializeDoubleInJS() throws Exception {
jaroslav@185
   110
        double f = 3.0;
jaroslav@248
   111
        assertExec("Should be the same", Numbers.class, "deserDouble__D", f);
jaroslav@185
   112
    }
jaroslav@185
   113
    /*
jaroslav@185
   114
    @Test public void serDouble() throws IOException {
jaroslav@185
   115
        double f = 3.0;
jaroslav@185
   116
        ByteArrayOutputStream os = new ByteArrayOutputStream();
jaroslav@185
   117
        DataOutputStream d = new DataOutputStream(os);
jaroslav@185
   118
        d.writeLong(3454);
jaroslav@185
   119
        d.close();
jaroslav@185
   120
        
jaroslav@185
   121
        StringBuilder sb = new StringBuilder();
jaroslav@185
   122
        byte[] arr = os.toByteArray();
jaroslav@185
   123
        for (int i = 0; i < arr.length; i++) {
jaroslav@185
   124
            sb.append("(byte)").append(arr[i]).append(", ");
jaroslav@185
   125
        }
jaroslav@185
   126
        fail("" + sb);
jaroslav@185
   127
    }
jaroslav@185
   128
*/    
jaroslav@186
   129
    @Test public void fiveInStringJS() throws Exception {
jaroslav@186
   130
        String s = Numbers.intToString();
jaroslav@186
   131
        assertExec("Should be the same: " + s, 
jaroslav@248
   132
            Numbers.class, "intToString__Ljava_lang_String_2", 
jaroslav@186
   133
            s
jaroslav@186
   134
        );
jaroslav@186
   135
    }
jaroslav@187
   136
jaroslav@187
   137
    @Test public void sevenInStringJS() throws Exception {
jaroslav@187
   138
        String s = Numbers.floatToString();
jaroslav@187
   139
        assertExec("Should be the same: " + s, 
jaroslav@248
   140
            Numbers.class, "floatToString__Ljava_lang_String_2", 
jaroslav@187
   141
            s
jaroslav@187
   142
        );
jaroslav@187
   143
    }
jaroslav@186
   144
    
Martin@615
   145
    @Test public void longConversion() throws Exception {
Martin@615
   146
        assertExec("Long from cPool",
Martin@615
   147
            Numbers.class, "conversionL__J", 
Martin@615
   148
            Double.valueOf(Long.MAX_VALUE)
Martin@615
   149
        );
Martin@615
   150
    }
Martin@615
   151
    
Martin@630
   152
    @Test public void longNegate1() throws Exception {
Martin@630
   153
        final long res = -0x00fa37d7763e0ca1l;
Martin@630
   154
        assertExec("Long negate",
Martin@630
   155
            Numbers.class, "negL__J_3B", 
Martin@630
   156
            Double.valueOf(res),
Martin@630
   157
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 }
Martin@630
   158
        );
Martin@630
   159
    }
Martin@630
   160
    
Martin@630
   161
    @Test public void longNegate2() throws Exception {
Martin@630
   162
        final long res = -0x80fa37d7763e0ca1l;
Martin@630
   163
        assertExec("Long negate",
Martin@630
   164
            Numbers.class, "negL__J_3B", 
Martin@630
   165
            Double.valueOf(res),
Martin@630
   166
                new byte[] { (byte)0x80, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 }
Martin@630
   167
        );
Martin@630
   168
    }
lubomir@676
   169
Martin@669
   170
    @Test public void longNegate3() throws Exception {
Martin@669
   171
        final long res = -0xfffffffffffffeddl;
Martin@669
   172
        assertExec("Long negate",
Martin@669
   173
            Numbers.class, "negL__J_3B",
Martin@669
   174
            Double.valueOf(res),
Martin@669
   175
                new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd }
Martin@669
   176
        );
Martin@669
   177
    }
Martin@669
   178
Martin@616
   179
    @Test public void longAddOverflow() throws Exception {
Martin@616
   180
        final long res = Long.MAX_VALUE + 1l;
Martin@616
   181
        assertExec("Addition 1+MAX",
Martin@616
   182
            Numbers.class, "addL__J_3B_3B", 
Martin@616
   183
            Double.valueOf(res),
Martin@616
   184
                new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
Martin@616
   185
                new byte[] { (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)1 }
Martin@616
   186
        );
Martin@616
   187
    }
Martin@616
   188
    
Martin@616
   189
    @Test public void longAddMaxAndMax() throws Exception {
Martin@616
   190
        final long res = Long.MAX_VALUE + Long.MAX_VALUE;
Martin@616
   191
        assertExec("Addition MAX+MAX",
Martin@616
   192
            Numbers.class, "addL__J_3B_3B", 
Martin@616
   193
            Double.valueOf(res),
Martin@616
   194
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
Martin@616
   195
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }
Martin@616
   196
        );
Martin@616
   197
    }
Martin@616
   198
    
Martin@620
   199
    @Test public void longSubUnderflow() throws Exception {
Martin@620
   200
        final long res = Long.MIN_VALUE - 1l;
Martin@620
   201
        assertExec("Subtraction MIN-1",
Martin@620
   202
            Numbers.class, "subL__J_3B_3B", 
Martin@620
   203
            Double.valueOf(res),
Martin@620
   204
                new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
Martin@620
   205
                new byte[] { (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)1 }
Martin@620
   206
        );
Martin@620
   207
    }
Martin@620
   208
    
Martin@620
   209
    @Test public void longSubMinAndMin() throws Exception {
Martin@620
   210
        final long res = Long.MIN_VALUE - Long.MIN_VALUE;
Martin@620
   211
        assertExec("Subtraction MIN-MIN",
Martin@620
   212
            Numbers.class, "subL__J_3B_3B", 
Martin@620
   213
            Double.valueOf(res),
Martin@620
   214
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
Martin@620
   215
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }
Martin@620
   216
        );
Martin@620
   217
    }
Martin@620
   218
    
Martin@620
   219
    @Test public void longSubMinAndMax() throws Exception {
Martin@620
   220
        final long res = Long.MIN_VALUE - Long.MAX_VALUE;
Martin@620
   221
        assertExec("Subtraction MIN-MAX",
Martin@620
   222
            Numbers.class, "subL__J_3B_3B", 
Martin@620
   223
            Double.valueOf(res),
Martin@620
   224
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
Martin@620
   225
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }
Martin@620
   226
        );
Martin@620
   227
    }
Martin@620
   228
    
Martin@657
   229
    @Test public void longMultiplyMax() throws Exception {
Martin@657
   230
        final long res = Long.MAX_VALUE * 2l;
Martin@657
   231
        assertExec("Multiplication MAX*2",
Martin@657
   232
            Numbers.class, "mulL__J_3B_3B",
Martin@657
   233
            Double.valueOf(res),
Martin@657
   234
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
Martin@657
   235
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02 }
Martin@657
   236
        );
Martin@657
   237
    }
Martin@657
   238
    
Martin@657
   239
    @Test public void longMultiplyMaxAndMax() throws Exception {
Martin@657
   240
        final long res = Long.MAX_VALUE * Long.MAX_VALUE;
Martin@657
   241
        assertExec("Multiplication MAX*MAX",
Martin@657
   242
            Numbers.class, "mulL__J_3B_3B",
Martin@657
   243
            Double.valueOf(res),
Martin@657
   244
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
Martin@657
   245
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }
Martin@657
   246
        );
Martin@657
   247
    }
Martin@657
   248
    
Martin@657
   249
    @Test public void longMultiplyMin() throws Exception {
Martin@657
   250
        final long res = Long.MIN_VALUE * 2l;
Martin@657
   251
        assertExec("Multiplication MIN*2",
Martin@657
   252
            Numbers.class, "mulL__J_3B_3B",
Martin@657
   253
            Double.valueOf(res),
Martin@657
   254
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
Martin@657
   255
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02 }
Martin@657
   256
        );
Martin@657
   257
    }
Martin@657
   258
    
Martin@657
   259
    @Test public void longMultiplyMinAndMin() throws Exception {
Martin@657
   260
        final long res = Long.MIN_VALUE * Long.MIN_VALUE;
Martin@657
   261
        assertExec("Multiplication MIN*2",
Martin@657
   262
            Numbers.class, "mulL__J_3B_3B",
Martin@657
   263
            Double.valueOf(res),
Martin@657
   264
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
Martin@657
   265
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }
Martin@657
   266
        );
Martin@657
   267
    }
Martin@657
   268
    
Martin@657
   269
    @Test public void longMultiplyPrecision() throws Exception {
Martin@657
   270
        final long res = 0x00fa37d7763e0ca1l * 0xa7b3432fff00123el;
Martin@657
   271
        assertExec("Multiplication",
Martin@657
   272
            Numbers.class, "mulL__J_3B_3B",
Martin@657
   273
            Double.valueOf(res),
Martin@657
   274
            new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@657
   275
            new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
Martin@657
   276
        );
Martin@657
   277
    }
lubomir@676
   278
lubomir@676
   279
    @Test public void longDivideSmallPositiveNumbers() throws Exception {
lubomir@676
   280
        final long res = 0xabcdef / 0x123;
lubomir@676
   281
        assertExec("Division Small Positive Numbers",
lubomir@676
   282
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   283
            Double.valueOf(res),
lubomir@676
   284
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef },
lubomir@676
   285
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x23 }
lubomir@676
   286
        );
lubomir@676
   287
    }
lubomir@676
   288
lubomir@676
   289
    @Test public void longDivideSmallNegativeNumbers() throws Exception {
lubomir@676
   290
        final long res = -0xabcdef / -0x123;
lubomir@676
   291
        assertExec("Division Small Negative Numbers",
lubomir@676
   292
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   293
            Double.valueOf(res),
lubomir@676
   294
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x11 },
lubomir@676
   295
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd }
lubomir@676
   296
        );
lubomir@676
   297
    }
lubomir@676
   298
lubomir@676
   299
    @Test public void longDivideSmallMixedNumbers() throws Exception {
lubomir@676
   300
        final long res = 0xabcdef / -0x123;
lubomir@676
   301
        assertExec("Division Small Mixed Numbers",
lubomir@676
   302
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   303
            Double.valueOf(res),
lubomir@676
   304
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef },
lubomir@676
   305
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd }
lubomir@676
   306
        );
lubomir@676
   307
    }
lubomir@676
   308
lubomir@676
   309
    @Test public void longDividePositiveNumbersOneDigitDenom()
lubomir@676
   310
            throws Exception {
lubomir@676
   311
        final long res = 0xabcdef0102ffffL / 0x654;
lubomir@676
   312
        assertExec("Division Positive Numbers One Digit Denom",
lubomir@676
   313
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   314
            Double.valueOf(res),
lubomir@676
   315
            new byte[] { (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef, (byte)0x01, (byte)0x02, (byte)0xff, (byte)0xff },
lubomir@676
   316
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 }
lubomir@676
   317
        );
lubomir@676
   318
    }
lubomir@676
   319
lubomir@676
   320
    @Test public void longDivideNegativeNumbersOneDigitDenom()
lubomir@676
   321
            throws Exception {
lubomir@676
   322
        final long res = -0xabcdef0102ffffL / -0x654;
lubomir@676
   323
        assertExec("Division Negative Numbers One Digit Denom",
lubomir@676
   324
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   325
            Double.valueOf(res),
lubomir@676
   326
            new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 },
lubomir@676
   327
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xf9, (byte)0xac }
lubomir@676
   328
        );
lubomir@676
   329
    }
lubomir@676
   330
lubomir@676
   331
    @Test public void longDivideMixedNumbersOneDigitDenom()
lubomir@676
   332
            throws Exception {
lubomir@676
   333
        final long res = -0xabcdef0102ffffL / 0x654;
lubomir@676
   334
        assertExec("Division Mixed Numbers One Digit Denom",
lubomir@676
   335
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   336
            Double.valueOf(res),
lubomir@676
   337
            new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 },
lubomir@676
   338
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 }
lubomir@676
   339
        );
lubomir@676
   340
    }
lubomir@676
   341
lubomir@676
   342
    @Test public void longDividePositiveNumbersMultiDigitDenom()
lubomir@676
   343
            throws Exception {
lubomir@676
   344
        final long res = 0x7ffefc003322aabbL / 0x89ab1000L;
lubomir@676
   345
        assertExec("Division Positive Numbers Multi Digit Denom",
lubomir@676
   346
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   347
            Double.valueOf(res),
lubomir@676
   348
            new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb },
lubomir@676
   349
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x89, (byte)0xab, (byte)0x10, (byte)0x00 }
lubomir@676
   350
        );
lubomir@676
   351
    }
lubomir@676
   352
lubomir@676
   353
    @Test public void longDivideNegativeNumbersMultiDigitDenom()
lubomir@676
   354
            throws Exception {
lubomir@676
   355
        final long res = -0x7ffefc003322aabbL / -0x123489ab1001L;
lubomir@676
   356
        assertExec("Division Negative Numbers Multi Digit Denom",
lubomir@676
   357
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   358
            Double.valueOf(res),
lubomir@676
   359
            new byte[] { (byte)0x80, (byte)0x01, (byte)0x03, (byte)0xff, (byte)0xcc, (byte)0xdd, (byte)0x55, (byte)0x45 },
lubomir@676
   360
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xed, (byte)0xcb, (byte)0x76, (byte)0x54, (byte)0xef, (byte)0xff }
lubomir@676
   361
        );
lubomir@676
   362
    }
lubomir@676
   363
lubomir@676
   364
    @Test public void longDivideMixedNumbersMultiDigitDenom()
lubomir@676
   365
            throws Exception {
lubomir@676
   366
        final long res = 0x7ffefc003322aabbL / -0x38f49b0b7574e36L;
lubomir@676
   367
        assertExec("Division Mixed Numbers Multi Digit Denom",
lubomir@676
   368
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   369
            Double.valueOf(res),
lubomir@676
   370
            new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb },
lubomir@676
   371
            new byte[] { (byte)0xfc, (byte)0x70, (byte)0xb6, (byte)0x4f, (byte)0x48, (byte)0xa8, (byte)0xb1, (byte)0xca }
lubomir@676
   372
        );
lubomir@676
   373
    }
lubomir@676
   374
lubomir@676
   375
    @Test public void longDivideWithOverflow() throws Exception {
lubomir@676
   376
        final long res = 0x8000fffe0000L / 0x8000ffffL;
lubomir@676
   377
        assertExec("Division With Overflow",
lubomir@676
   378
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   379
            Double.valueOf(res),
lubomir@676
   380
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xfe, (byte)0x00, (byte)0x00 },
lubomir@676
   381
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xff }
lubomir@676
   382
        );
lubomir@676
   383
    }
lubomir@676
   384
lubomir@676
   385
    @Test public void longDivideWithCorrection() throws Exception {
lubomir@676
   386
        final long res = 0x7fff800000000000L / 0x800000000001L;
lubomir@676
   387
        assertExec("Division With Correction",
lubomir@676
   388
            Numbers.class, "divL__J_3B_3B",
lubomir@676
   389
            Double.valueOf(res),
lubomir@676
   390
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@676
   391
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 }
lubomir@676
   392
        );
lubomir@676
   393
    }
lubomir@676
   394
lubomir@676
   395
    @Test public void longModuloSmallPositiveNumbers() throws Exception {
lubomir@676
   396
        final long res = 0xabcdef % 0x123;
lubomir@676
   397
        assertExec("Modulo Small Positive Numbers",
lubomir@676
   398
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   399
            Double.valueOf(res),
lubomir@676
   400
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef },
lubomir@676
   401
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x23 }
lubomir@676
   402
        );
lubomir@676
   403
    }
lubomir@676
   404
lubomir@676
   405
    @Test public void longModuloSmallNegativeNumbers() throws Exception {
lubomir@676
   406
        final long res = -0xabcdef % -0x123;
lubomir@676
   407
        assertExec("Modulo Small Negative Numbers",
lubomir@676
   408
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   409
            Double.valueOf(res),
lubomir@676
   410
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x11 },
lubomir@676
   411
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd }
lubomir@676
   412
        );
lubomir@676
   413
    }
lubomir@676
   414
lubomir@676
   415
    @Test public void longModuloSmallMixedNumbers() throws Exception {
lubomir@676
   416
        final long res = 0xabcdef % -0x123;
lubomir@676
   417
        assertExec("Modulo Small Mixed Numbers",
lubomir@676
   418
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   419
            Double.valueOf(res),
lubomir@676
   420
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef },
lubomir@676
   421
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd }
lubomir@676
   422
        );
lubomir@676
   423
    }
lubomir@676
   424
lubomir@676
   425
    @Test public void longModuloPositiveNumbersOneDigitDenom()
lubomir@676
   426
            throws Exception {
lubomir@676
   427
        final long res = 0xabcdef0102ffffL % 0x654;
lubomir@676
   428
        assertExec("Modulo Positive Numbers One Digit Denom",
lubomir@676
   429
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   430
            Double.valueOf(res),
lubomir@676
   431
            new byte[] { (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef, (byte)0x01, (byte)0x02, (byte)0xff, (byte)0xff },
lubomir@676
   432
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 }
lubomir@676
   433
        );
lubomir@676
   434
    }
lubomir@676
   435
lubomir@676
   436
    @Test public void longModuloNegativeNumbersOneDigitDenom()
lubomir@676
   437
            throws Exception {
lubomir@676
   438
        final long res = -0xabcdef0102ffffL % -0x654;
lubomir@676
   439
        assertExec("Modulo Negative Numbers One Digit Denom",
lubomir@676
   440
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   441
            Double.valueOf(res),
lubomir@676
   442
            new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 },
lubomir@676
   443
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xf9, (byte)0xac }
lubomir@676
   444
        );
lubomir@676
   445
    }
lubomir@676
   446
lubomir@676
   447
    @Test public void longModuloMixedNumbersOneDigitDenom()
lubomir@676
   448
            throws Exception {
lubomir@676
   449
        final long res = -0xabcdef0102ffffL % 0x654;
lubomir@676
   450
        assertExec("Modulo Mixed Numbers One Digit Denom",
lubomir@676
   451
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   452
            Double.valueOf(res),
lubomir@676
   453
            new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 },
lubomir@676
   454
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 }
lubomir@676
   455
        );
lubomir@676
   456
    }
lubomir@676
   457
lubomir@676
   458
    @Test public void longModuloPositiveNumbersMultiDigitDenom()
lubomir@676
   459
            throws Exception {
lubomir@676
   460
        final long res = 0x7ffefc003322aabbL % 0x89ab1000L;
lubomir@676
   461
        assertExec("Modulo Positive Numbers Multi Digit Denom",
lubomir@676
   462
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   463
            Double.valueOf(res),
lubomir@676
   464
            new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb },
lubomir@676
   465
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x89, (byte)0xab, (byte)0x10, (byte)0x00 }
lubomir@676
   466
        );
lubomir@676
   467
    }
lubomir@676
   468
lubomir@676
   469
    @Test public void longModuloNegativeNumbersMultiDigitDenom()
lubomir@676
   470
            throws Exception {
lubomir@676
   471
        final long res = -0x7ffefc003322aabbL % -0x123489ab1001L;
lubomir@676
   472
        assertExec("Modulo Negative Numbers Multi Digit Denom",
lubomir@676
   473
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   474
            Double.valueOf(res),
lubomir@676
   475
            new byte[] { (byte)0x80, (byte)0x01, (byte)0x03, (byte)0xff, (byte)0xcc, (byte)0xdd, (byte)0x55, (byte)0x45 },
lubomir@676
   476
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xed, (byte)0xcb, (byte)0x76, (byte)0x54, (byte)0xef, (byte)0xff }
lubomir@676
   477
        );
lubomir@676
   478
    }
lubomir@676
   479
lubomir@676
   480
    @Test public void longModuloMixedNumbersMultiDigitDenom()
lubomir@676
   481
            throws Exception {
lubomir@676
   482
        final long res = 0x7ffefc003322aabbL % -0x38f49b0b7574e36L;
lubomir@676
   483
        assertExec("Modulo Mixed Numbers Multi Digit Denom",
lubomir@676
   484
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   485
            Double.valueOf(res),
lubomir@676
   486
            new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb },
lubomir@676
   487
            new byte[] { (byte)0xfc, (byte)0x70, (byte)0xb6, (byte)0x4f, (byte)0x48, (byte)0xa8, (byte)0xb1, (byte)0xca }
lubomir@676
   488
        );
lubomir@676
   489
    }
lubomir@676
   490
lubomir@676
   491
    @Test public void longModuloWithOverflow() throws Exception {
lubomir@676
   492
        final long res = 0x8000fffe0000L % 0x8000ffffL;
lubomir@676
   493
        assertExec("Modulo With Overflow",
lubomir@676
   494
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   495
            Double.valueOf(res),
lubomir@676
   496
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xfe, (byte)0x00, (byte)0x00 },
lubomir@676
   497
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xff }
lubomir@676
   498
        );
lubomir@676
   499
    }
lubomir@676
   500
lubomir@676
   501
    @Test public void longModuloWithCorrection() throws Exception {
lubomir@676
   502
        final long res = 0x7fff800000000000L % 0x800000000001L;
lubomir@676
   503
        assertExec("Modulo With Correction",
lubomir@676
   504
            Numbers.class, "modL__J_3B_3B",
lubomir@676
   505
            Double.valueOf(res),
lubomir@676
   506
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@676
   507
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 }
lubomir@676
   508
        );
lubomir@676
   509
    }
lubomir@676
   510
Martin@617
   511
    @Test public void longShiftL1() throws Exception {
Martin@617
   512
        final long res = 0x00fa37d7763e0ca1l << 5;
Martin@618
   513
        assertExec("Long << 5",
Martin@617
   514
            Numbers.class, "shlL__J_3BI", 
Martin@617
   515
            Double.valueOf(res),
Martin@617
   516
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@618
   517
                5);
Martin@617
   518
    }
Martin@617
   519
    
Martin@617
   520
    @Test public void longShiftL2() throws Exception {
Martin@617
   521
        final long res = 0x00fa37d7763e0ca1l << 32;
Martin@618
   522
        assertExec("Long << 32",
Martin@617
   523
            Numbers.class, "shlL__J_3BI", 
Martin@617
   524
            Double.valueOf(res),
Martin@617
   525
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@618
   526
                32);
Martin@617
   527
    }
Martin@617
   528
    
Martin@617
   529
    @Test public void longShiftL3() throws Exception {
Martin@617
   530
        final long res = 0x00fa37d7763e0ca1l << 45;
Martin@618
   531
        assertExec("Long << 45",
Martin@617
   532
            Numbers.class, "shlL__J_3BI", 
Martin@617
   533
            Double.valueOf(res),
Martin@617
   534
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@618
   535
                45);
Martin@618
   536
    }
Martin@618
   537
    
Martin@618
   538
    @Test public void longShiftR1() throws Exception {
Martin@618
   539
        final long res = 0x00fa37d7763e0ca1l >> 5;
Martin@618
   540
        assertExec("Long >> 5",
Martin@618
   541
            Numbers.class, "shrL__J_3BI", 
Martin@618
   542
            Double.valueOf(res),
Martin@618
   543
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@618
   544
                5);
Martin@618
   545
    }
Martin@618
   546
    
Martin@618
   547
    @Test public void longShiftR2() throws Exception {
Martin@618
   548
        final long res = 0x00fa37d7763e0ca1l >> 32;
Martin@618
   549
        assertExec("Long >> 32",
Martin@618
   550
            Numbers.class, "shrL__J_3BI", 
Martin@618
   551
            Double.valueOf(res),
Martin@618
   552
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@618
   553
                32);
Martin@618
   554
    }
Martin@618
   555
    
Martin@618
   556
    @Test public void longShiftR3() throws Exception {
Martin@618
   557
        final long res = 0x00fa37d7763e0ca1l >> 45;
Martin@618
   558
        assertExec("Long >> 45",
Martin@618
   559
            Numbers.class, "shrL__J_3BI", 
Martin@618
   560
            Double.valueOf(res),
Martin@618
   561
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@618
   562
                45);
Martin@617
   563
    }
Martin@617
   564
    
Martin@629
   565
    @Test public void longUShiftR1() throws Exception {
Martin@629
   566
        final long res = 0x00fa37d7763e0ca1l >>> 5;
Martin@629
   567
        assertExec("Long >>> 5",
Martin@629
   568
            Numbers.class, "ushrL__J_3BI", 
Martin@629
   569
            Double.valueOf(res),
Martin@629
   570
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@629
   571
                5);
Martin@629
   572
    }
Martin@629
   573
    
Martin@629
   574
    @Test public void longUShiftR2() throws Exception {
Martin@629
   575
        final long res = 0x00fa37d7763e0ca1l >>> 45;
Martin@629
   576
        assertExec("Long >>> 45",
Martin@629
   577
            Numbers.class, "ushrL__J_3BI", 
Martin@629
   578
            Double.valueOf(res),
Martin@629
   579
                new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@629
   580
                45);
Martin@629
   581
    }
Martin@629
   582
    
Martin@629
   583
    @Test public void longUShiftR3() throws Exception {
Martin@629
   584
        final long res = 0xf0fa37d7763e0ca1l >>> 5;
Martin@629
   585
        assertExec("Long >>> 5",
Martin@629
   586
            Numbers.class, "ushrL__J_3BI", 
Martin@629
   587
            Double.valueOf(res),
Martin@629
   588
                new byte[] { (byte)0xf0, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@629
   589
                5);
Martin@629
   590
    }
Martin@629
   591
    
Martin@629
   592
    @Test public void longUShiftR4() throws Exception {
Martin@629
   593
        final long res = 0xf0fa37d7763e0ca1l >>> 45;
Martin@629
   594
        assertExec("Long >>> 45",
Martin@629
   595
            Numbers.class, "ushrL__J_3BI", 
Martin@629
   596
            Double.valueOf(res),
Martin@629
   597
                new byte[] { (byte)0xf0, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@629
   598
                45);
Martin@629
   599
    }
Martin@629
   600
    
Martin@627
   601
    @Test public void longAnd() throws Exception {
Martin@627
   602
        final long res = 0x00fa37d7763e0ca1l & 0xa7b3432fff00123el;
Martin@627
   603
        assertExec("LOng binary AND",
Martin@627
   604
            Numbers.class, "andL__J_3B_3B", 
Martin@627
   605
            Double.valueOf(res),
Martin@627
   606
            new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@627
   607
            new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
Martin@627
   608
        );
Martin@627
   609
    }
Martin@627
   610
    
Martin@627
   611
    @Test public void longOr() throws Exception {
Martin@627
   612
        final long res = 0x00fa37d7763e0ca1l | 0xa7b3432fff00123el;
Martin@627
   613
        assertExec("Long binary OR",
Martin@627
   614
            Numbers.class, "orL__J_3B_3B", 
Martin@627
   615
            Double.valueOf(res),
Martin@627
   616
            new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@627
   617
            new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
Martin@627
   618
        );
Martin@627
   619
    }
Martin@627
   620
    
Martin@628
   621
    @Test public void longXor1() throws Exception {
Martin@628
   622
        final long res = 0x00fa37d7763e0ca1l ^ 0xa7b3432fff00123el;
Martin@628
   623
        assertExec("Long binary XOR",
Martin@628
   624
            Numbers.class, "xorL__J_3B_3B", 
Martin@628
   625
            Double.valueOf(res),
Martin@628
   626
            new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@628
   627
            new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
Martin@628
   628
        );
Martin@628
   629
    }
Martin@628
   630
    
Martin@628
   631
    @Test public void longXor2() throws Exception {
Martin@628
   632
        final long res = 0x00fa37d7763e0ca1l ^ 0x00000000ff00123el;
Martin@628
   633
        assertExec("Long binary XOR",
Martin@628
   634
            Numbers.class, "xorL__J_3B_3B", 
Martin@628
   635
            Double.valueOf(res),
Martin@628
   636
            new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@628
   637
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
Martin@628
   638
        );
Martin@628
   639
    }
Martin@628
   640
    
Martin@628
   641
    @Test public void longXor3() throws Exception {
Martin@628
   642
        final long res = 0x00000000763e0ca1l ^ 0x00000000ff00123el;
Martin@628
   643
        assertExec("Long binary XOR",
Martin@628
   644
            Numbers.class, "xorL__J_3B_3B", 
Martin@628
   645
            Double.valueOf(res),
Martin@628
   646
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
Martin@628
   647
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
Martin@628
   648
        );
Martin@628
   649
    }
lubomir@680
   650
lubomir@680
   651
    @Test public void longCompareSameNumbers() throws Exception {
lubomir@680
   652
        assertExec("Long compare same numbers",
lubomir@680
   653
            Numbers.class, "compareL__I_3B_3BI",
lubomir@680
   654
            0.0,
lubomir@680
   655
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@680
   656
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@680
   657
            0
lubomir@680
   658
        );
lubomir@680
   659
    }
lubomir@680
   660
lubomir@680
   661
    @Test public void longComparePositiveNumbers() throws Exception {
lubomir@680
   662
        assertExec("Long compare positive numbers",
lubomir@680
   663
            Numbers.class, "compareL__I_3B_3BI",
lubomir@680
   664
            -1.0,
lubomir@680
   665
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x20, (byte)0x00, (byte)0x00 },
lubomir@680
   666
            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@680
   667
            0
lubomir@680
   668
        );
lubomir@680
   669
    }
lubomir@680
   670
lubomir@680
   671
    @Test public void longCompareNegativeNumbers() throws Exception {
lubomir@680
   672
        assertExec("Long compare negative numbers",
lubomir@680
   673
            Numbers.class, "compareL__I_3B_3BI",
lubomir@680
   674
            1.0,
lubomir@680
   675
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
lubomir@680
   676
            new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@680
   677
            0
lubomir@680
   678
        );
lubomir@680
   679
    }
lubomir@680
   680
lubomir@680
   681
    @Test public void longCompareMixedNumbers() throws Exception {
lubomir@680
   682
        assertExec("Long compare mixed numbers",
lubomir@680
   683
            Numbers.class, "compareL__I_3B_3BI",
lubomir@680
   684
            -1.0,
lubomir@680
   685
            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
lubomir@680
   686
            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
lubomir@680
   687
            0
lubomir@680
   688
        );
lubomir@680
   689
    }
lubomir@680
   690
jaroslav@708
   691
    private static TestVM code;
jaroslav@114
   692
jaroslav@114
   693
    @BeforeClass
jaroslav@114
   694
    public void compileTheCode() throws Exception {
jaroslav@708
   695
        code = TestVM.compileClass("org/apidesign/vm4brwsr/Numbers");
jaroslav@114
   696
    }
jaroslav@114
   697
jaroslav@114
   698
    private static void assertExec(
Martin@582
   699
        String msg, Class<?> clazz, String method, Object expRes, Object... args) throws Exception
Martin@582
   700
    {
jaroslav@708
   701
        Object ret = code.execCode(msg, clazz, method, expRes, args);
Martin@582
   702
        if (ret == null) {
jaroslav@114
   703
            return;
jaroslav@114
   704
        }
jtulach@132
   705
        if (expRes instanceof Double && ret instanceof Double) {
jtulach@132
   706
            double expD = ((Double)expRes).doubleValue();
jtulach@132
   707
            double retD = ((Double)ret).doubleValue();
Martin@616
   708
            assertEquals(retD, expD, 0.000004, msg + " "
jaroslav@708
   709
                    + code.toString());
jtulach@132
   710
            return;
jtulach@132
   711
        }
jaroslav@708
   712
        assertEquals(ret, expRes, msg + " " + code.toString());
jaroslav@114
   713
    }
jaroslav@114
   714
    
jaroslav@114
   715
}