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