Mercurial > hg > truffle
comparison graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestMetaAccessProvider.java @ 11682:976ebd1973d1
The runtime might not always be able to report an array length
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 17 Sep 2013 10:31:22 -0700 |
parents | 21b8cd853b2b |
children | 23ccaa863eda |
comparison
equal
deleted
inserted
replaced
11681:39f98ffd187f | 11682:976ebd1973d1 |
---|---|
105 } | 105 } |
106 | 106 |
107 @Test | 107 @Test |
108 public void lookupArrayLengthTest() { | 108 public void lookupArrayLengthTest() { |
109 for (Constant c : constants) { | 109 for (Constant c : constants) { |
110 Integer actual = runtime.lookupArrayLength(c); | |
110 if (c.getKind() != Kind.Object || c.isNull() || !c.asObject().getClass().isArray()) { | 111 if (c.getKind() != Kind.Object || c.isNull() || !c.asObject().getClass().isArray()) { |
111 try { | 112 assertNull(actual); |
112 int length = runtime.lookupArrayLength(c); | |
113 fail("Expected " + IllegalArgumentException.class.getName() + " for " + c + ", not " + length); | |
114 } catch (IllegalArgumentException e) { | |
115 // pass | |
116 } | |
117 } else { | 113 } else { |
118 assertEquals(Array.getLength(c.asObject()), runtime.lookupArrayLength(c)); | 114 assertNotNull(actual); |
115 int actualInt = actual; | |
116 assertEquals(Array.getLength(c.asObject()), actualInt); | |
119 } | 117 } |
120 } | 118 } |
121 } | 119 } |
122 } | 120 } |