Omr: Create compiler test for arrayset

Created on 9 Feb 2017  路  2Comments  路  Source: eclipse/omr

We should create array set compiler tests for the arrayset opcode.
This issue is created for pull request #732
Here is what the test should look like in java:

class Test1 {
    static int lsize = 20;

    static public void intLargeSize() {
        int valueInt = 1;
        int[]  arrayInt = new int[lsize];

        for (int i=0; i<20; i++)
            arrayInt[i] = valueInt;

        for (int i=0;i<lsize;i++)
            if (arrayInt[i] != valueInt) 
                System.out.println("Int" + i + " " + arrayInt[i]);
    }

    static public void intSmallSize() {
        int valueInt = 1;
        int[]  arrayInt = new int[2];

        for (int i=0; i<2; i++)
            arrayInt[i] = valueInt;

        for (int i=0;i<2;i++)
            if (arrayInt[i] != valueInt) 
                System.out.println("Int" + i + " " + arrayInt[i]);
    }

    static public void byteLargeSize() {
        byte valueByte = 1;
        byte[] arrayByte = new byte[lsize];

        for (int i=0; i<20; i++)
            arrayByte[i] = valueByte;

        for (int i=0;i<lsize;i++)
            if (arrayByte[i] != valueByte) 
                System.out.println("Byte" + i + " " + arrayByte[i]);
    }


    static public void byteSmallSize() {
        byte valueByte = 1;
        byte[] arrayByte = new byte[14];

        for (int i=0; i<14; i++)
            arrayByte[i] = valueByte;

        for (int i=0;i<14;i++)
            if (arrayByte[i] != valueByte) 
                System.out.println("Byte" + i + " " + arrayByte[i]);
    }

    static public void longLargeSize() {
        long valueLong = 1L;
        long[] arrayLong = new long[lsize];

        for (int i=0; i<20; i++)
            arrayLong[i] = valueLong;

        for (int i=0;i<lsize;i++)
            if (arrayLong[i] != valueLong) 
                System.out.println("Long" + i + " " + arrayLong[i]);
    }

    static public void longSmallSize() {
        long valueLong = 1L;
        long[] arrayLong = new long[3];

        for (int i=0; i<3; i++)
            arrayLong[i] = valueLong;

        for (int i=0;i<3;i++)
            if (arrayLong[i] != valueLong) 
                System.out.println("Long" + i + " " + arrayLong[i]);
    }

    static public void charLargeSize() {
        char valueChar = 1;
        char[] arrayChar = new char[lsize];

        for (int i=0; i<20; i++)
            arrayChar[i] = valueChar;

        for (int i=0;i<lsize;i++)
            if (arrayChar[i] != valueChar) 
                System.out.println("Char" + i + " " + arrayChar[i]);
    }

    static public void charSmallSize() {
        char valueChar = 1;
        char[] arrayChar = new char[5];

        for (int i=0; i<5; i++)
            arrayChar[i] = valueChar;

        for (int i=0;i<5;i++)
            if (arrayChar[i] != valueChar) 
                System.out.println("Char" + i + " " + arrayChar[i]);
    }

    static public void floatSmallSize() {
        float valueFloat = 1;
        float[] arrayFloat = new float[3];

        for (int i=0; i<3; i++)
            arrayFloat[i] = valueFloat;

        for (int i=0;i<3;i++)
            if (arrayFloat[i] != valueFloat) 
                System.out.println("Float" + i + " " + arrayFloat[i]);
    }

    static public void floatLargeSize() {
        float valueFloat = 1;
        float[] arrayFloat = new float[20];

        for (int i=0; i<20; i++)
            arrayFloat[i] = valueFloat;

        for (int i=0;i<20;i++)
            if (arrayFloat[i] != valueFloat) 
                System.out.println("Float" + i + " " + arrayFloat[i]);
    }

    static public void main(String[] argv) {
        Test1.byteSmallSize();
        Test1.byteLargeSize();

        Test1.charSmallSize();
        Test1.charLargeSize();

        Test1.intSmallSize();
        Test1.intLargeSize();

        Test1.longSmallSize();
        Test1.longLargeSize();

    Test1.floatSmallSize();
    Test1.floatLargeSize();
    }
}
backlog compiler test tril help wanted

All 2 comments

Seems like a reasonable candidate for someone to learn a bit about IlInjectors or IlBuilders.

This should be a Tril test.

Was this page helpful?
0 / 5 - 0 ratings