Mercurial > hg > truffle
changeset 5685:757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 22 Jun 2012 16:42:01 +0200 |
parents | 5a29310e1504 |
children | 6cb39a47da14 |
files | graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java |
diffstat | 1 files changed, 24 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java Fri Jun 22 15:20:19 2012 +0200 +++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java Fri Jun 22 16:42:01 2012 +0200 @@ -32,6 +32,7 @@ import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.tests.*; import com.oracle.graal.nodes.*; +import com.oracle.graal.snippets.Snippet.InliningPolicy; /** * Tests for the {@link Word} type. @@ -45,10 +46,12 @@ installer = new SnippetInstaller(runtime, target); } + private static final ThreadLocal<InliningPolicy> inliningPolicy = new ThreadLocal<>(); + @Override protected StructuredGraph parse(Method m) { ResolvedJavaMethod resolvedMethod = runtime.getResolvedJavaMethod(m); - return installer.makeGraph(resolvedMethod, null); + return installer.makeGraph(resolvedMethod, inliningPolicy.get()); } @Test @@ -83,6 +86,21 @@ } } + @Test + public void test_fromObject() { + inliningPolicy.set(new InliningPolicy() { + public boolean shouldInline(ResolvedJavaMethod method, ResolvedJavaMethod caller) { + return InliningPolicy.Default.shouldInline(method, caller) && !method.name().equals("hashCode"); + } + }); + test("fromToObject", "object1", "object2"); + test("fromToObject", "object1", "object1"); + test("fromToObject", "object", null); + test("fromToObject", null, "object"); + test("fromToObject", null, null); + inliningPolicy.set(null); + } + @Snippet public static long plus_int(long word, int addend) { return Word.fromLong(word).plus(addend).toLong(); @@ -113,4 +131,9 @@ return Word.fromLong(word1).below(Word.fromLong(word2)); } + @Snippet + public static int fromToObject(Object o1, Object o2) { + return Word.fromObject(o1).toObject().hashCode() + Word.fromObject(o2).toObject().hashCode(); + } } +