Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java @ 21689:ed234a3178af
Behavior of null-like values is now part of the TCK
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 10:17:19 +0200 |
parents | 31fc2fce38f3 |
children | c8418635b575 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java Tue Jun 02 21:15:59 2015 -0700 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleTCK.java Wed Jun 03 10:17:19 2015 +0200 @@ -27,6 +27,7 @@ import org.junit.*; import com.oracle.truffle.api.vm.*; +import static org.junit.Assert.*; /** * A collection of tests that can certify language implementaiton to be complient with most recent @@ -66,6 +67,18 @@ } /** + * Name of a function that returns <code>null</code>. Truffle languages are encouraged to have + * their own type representing <code>null</code>, but when such value is returned from + * {@link TruffleVM#eval}, it needs to be converted to real Java <code>null</code> by sending a + * foreign access <em>isNull</em> message. There is a test to verify it is really true. + * + * @return name of globally exported symbol + */ + protected String returnsNull() { // abstract + return null; + } + + /** * Name of function to add two integer values together. The symbol will be invoked with two * parameters of type {@link Integer} and expects result of type {@link Number} which's * {@link Number#intValue()} is equivalent of <code>param1 + param2</code>. @@ -104,6 +117,18 @@ } @Test + public void testNull() throws Exception { + if (getClass() == TruffleTCK.class) { + return; + } + TruffleVM.Symbol retNull = findGlobalSymbol(returnsNull()); + + Object res = retNull.invoke(null); + + assertNull("Should yield real Java null", res); + } + + @Test public void testPlusWithInts() throws Exception { if (getClass() == TruffleTCK.class) { return;