# HG changeset patch # User Jaroslav Tulach # Date 1358246355 -3600 # Node ID 6506c5925775c038cc8d2b54f1344431bea478e7 # Parent aa48132c8a803382a3b546243e0e7de2dc217829 Are multi dimensional arrays properly initialized with 0? diff -r aa48132c8a80 -r 6506c5925775 vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java Mon Jan 14 14:23:27 2013 +0100 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/IntegerArithmeticTest.java Tue Jan 15 11:39:15 2013 +0100 @@ -91,6 +91,25 @@ return mod(1, 2); } + @Compare public int sumTwoDimensions() { + int[][] matrix = createMatrix(4, 3); + int sum = 0; + for (int i = 0; i < matrix.length; i++) { + for (int j = 0; j < matrix[i].length; j++) { + sum += matrix[i][j]; + } + } + return sum; + } + + static int[][] createMatrix(int x, int y) { + int[][] m = new int[x][y]; + for (int i = 0; i < Math.min(x, y); i++) { + m[i][i] = i; + } + return m; + } + @Factory public static Object[] create() { return VMTest.create(IntegerArithmeticTest.class);