зеркало из https://github.com/mozilla/pluotsorbet.git
test WeakReference
This commit is contained in:
Родитель
63dac16403
Коммит
38571c133d
|
@ -40,7 +40,7 @@ function setNative(javaObj, nativeObj) {
|
|||
}
|
||||
|
||||
function deleteNative(javaObj) {
|
||||
NativeMap.delete(javaObj);
|
||||
NativeMap.delete(javaObj._address);
|
||||
}
|
||||
|
||||
Native["java/lang/System.arraycopy.(Ljava/lang/Object;ILjava/lang/Object;II)V"] = function(src, srcOffset, dst, dstOffset, length) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package java.lang.ref;
|
||||
|
||||
import gnu.testlet.Testlet;
|
||||
import gnu.testlet.TestHarness;
|
||||
|
||||
public class TestWeakReference implements Testlet {
|
||||
public int getExpectedPass() { return 2; }
|
||||
public int getExpectedFail() { return 0; }
|
||||
public int getExpectedKnownFail() { return 0; }
|
||||
|
||||
public void test(TestHarness th) {
|
||||
Object obj = new Object();
|
||||
WeakReference weakRef = new WeakReference(obj);
|
||||
th.check(weakRef.get(), obj, "weakly held referent is object");
|
||||
weakRef.clear();
|
||||
th.check(weakRef.get(), null, "cleared weakly held referent is null");
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче