Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.interop.java.test/src/com/oracle/truffle/api/interop/java/test/PrimitiveRawArrayInteropTest.java @ 22241:14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
- Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget
- Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing
- Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 22 Sep 2015 20:31:19 -0700 |
parents | dc83cc1f94f2 |
children | 0d36601f233e |
comparison
equal
deleted
inserted
replaced
22240:f78c72e2e0b6 | 22241:14e6dfb1ef05 |
---|---|
24 */ | 24 */ |
25 package com.oracle.truffle.api.interop.java.test; | 25 package com.oracle.truffle.api.interop.java.test; |
26 | 26 |
27 import com.oracle.truffle.api.interop.TruffleObject; | 27 import com.oracle.truffle.api.interop.TruffleObject; |
28 import com.oracle.truffle.api.interop.java.JavaInterop; | 28 import com.oracle.truffle.api.interop.java.JavaInterop; |
29 | |
29 import java.util.List; | 30 import java.util.List; |
31 | |
30 import static org.junit.Assert.assertEquals; | 32 import static org.junit.Assert.assertEquals; |
31 import static org.junit.Assert.assertNull; | 33 import static org.junit.Assert.assertNull; |
34 | |
35 import org.junit.After; | |
32 import org.junit.Before; | 36 import org.junit.Before; |
33 import org.junit.Test; | 37 import org.junit.Test; |
34 | 38 |
35 public class PrimitiveRawArrayInteropTest { | 39 public class PrimitiveRawArrayInteropTest { |
36 private Object[] objArr; | 40 private Object[] objArr; |
74 | 78 |
75 private TruffleObject obj; | 79 private TruffleObject obj; |
76 private RawInterop interop; | 80 private RawInterop interop; |
77 | 81 |
78 @Before | 82 @Before |
79 public void initObjects() { | 83 public void initObjects() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
80 obj = JavaInterop.asTruffleObject(this); | 84 obj = JavaInterop.asTruffleObject(this); |
81 interop = JavaInterop.asJavaObject(RawInterop.class, obj); | 85 interop = JavaInterop.asJavaObject(RawInterop.class, obj); |
86 InstrumentationTestMode.set(true); | |
87 } | |
88 | |
89 @After | |
90 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { | |
91 InstrumentationTestMode.set(false); | |
82 } | 92 } |
83 | 93 |
84 @Test | 94 @Test |
85 public void everyThingIsNull() { | 95 public void everyThingIsNull() { |
86 assertNull(interop.arr(0)); | 96 assertNull(interop.arr(0)); |