Skip to content

Commit 70166a7

Browse files
committed
Add tests
1 parent ac34756 commit 70166a7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_weakref.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -107,3 +107,19 @@ def do_hash(item):
107107
assert False, "could compute hash for r3 but should have failed"
108108

109109
assert r1_hash == do_hash(r1)
110+
111+
def test_weakref_reuse():
112+
from weakref import ref
113+
class A:
114+
pass
115+
a = A()
116+
assert ref(a) == ref(a)
117+
118+
def test_weakref_object_type_support():
119+
from weakref import ref
120+
try:
121+
ref(42)
122+
except TypeError as e:
123+
pass
124+
else:
125+
assert False, "should throw TypeError for unsupported objects"

0 commit comments

Comments
 (0)