Skip to content

Commit 8846fd2

Browse files
committed
cleaning up public API
1 parent 23ec9d2 commit 8846fd2

37 files changed

+451
-1220
lines changed

src/embed_tests/TestConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public void CovertTypeError()
9494
[Test]
9595
public void ConvertOverflow()
9696
{
97-
using (var num = new PyLong(ulong.MaxValue))
97+
using (var num = new PyInt(ulong.MaxValue))
9898
{
9999
IntPtr largeNum = PyRuntime.PyNumber_Add(num.Handle, num.Handle);
100100
try

src/embed_tests/TestFinalizer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void CollectBasicObject()
5050
};
5151

5252
Assert.IsFalse(called, "The event handler was called before it was installed");
53-
Finalizer.Instance.CollectOnce += handler;
53+
Finalizer.Instance.BeforeCollect += handler;
5454

5555
IntPtr pyObj = MakeAGarbage(out var shortWeak, out var longWeak);
5656
FullGCCollect();
@@ -81,7 +81,7 @@ public void CollectBasicObject()
8181
}
8282
finally
8383
{
84-
Finalizer.Instance.CollectOnce -= handler;
84+
Finalizer.Instance.BeforeCollect -= handler;
8585
}
8686
Assert.IsTrue(called, "The event handler was not called during finalization");
8787
Assert.GreaterOrEqual(objectCount, 1);
@@ -121,7 +121,7 @@ private static IntPtr MakeAGarbage(out WeakReference shortWeak, out WeakReferenc
121121
IntPtr handle = IntPtr.Zero;
122122
WeakReference @short = null, @long = null;
123123
// must create Python object in the thread where we have GIL
124-
IntPtr val = PyLong.FromLong(1024);
124+
IntPtr val = Runtime.Runtime.PyLong_FromLongLong(1024).DangerousMoveToPointerOrNull();
125125
// must create temp object in a different thread to ensure it is not present
126126
// when conservatively scanning stack for GC roots.
127127
// see https://xamarin.github.io/bugzilla-archives/17/17593/bug.html
@@ -234,7 +234,7 @@ private static IntPtr CreateStringGarbage()
234234
{
235235
PyString s1 = new PyString("test_string");
236236
// s2 steal a reference from s1
237-
PyString s2 = new PyString(s1.Handle);
237+
PyString s2 = new PyString(StolenReference.DangerousFromPointer(s1.Handle));
238238
return s1.Handle;
239239
}
240240
}

src/embed_tests/TestPyAnsiString.cs

Lines changed: 0 additions & 97 deletions
This file was deleted.

src/embed_tests/TestPyFloat.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ public void Dispose()
2121
PythonEngine.Shutdown();
2222
}
2323

24-
[Test]
25-
public void IntPtrCtor()
26-
{
27-
var i = new PyFloat(1);
28-
Runtime.Runtime.XIncref(i.Handle);
29-
var ii = new PyFloat(i.Handle);
30-
Assert.AreEqual(i.Handle, ii.Handle);
31-
}
32-
3324
[Test]
3425
public void FloatCtor()
3526
{

src/embed_tests/TestPyInt.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ public void TestCtorSByte()
8282
Assert.AreEqual(i, a.ToInt32());
8383
}
8484

85-
[Test]
86-
public void TestCtorPtr()
87-
{
88-
var i = new PyInt(5);
89-
Runtime.Runtime.XIncref(i.Handle);
90-
var a = new PyInt(i.Handle);
91-
Assert.AreEqual(5, a.ToInt32());
92-
}
93-
9485
[Test]
9586
public void TestCtorPyObject()
9687
{
@@ -184,9 +175,10 @@ public void TestConvertToInt16()
184175
[Test]
185176
public void TestConvertToInt64()
186177
{
187-
var a = new PyInt(5);
178+
long val = 5 + (long)int.MaxValue;
179+
var a = new PyInt(val);
188180
Assert.IsInstanceOf(typeof(long), a.ToInt64());
189-
Assert.AreEqual(5, a.ToInt64());
181+
Assert.AreEqual(val, a.ToInt64());
190182
}
191183
}
192184
}

src/embed_tests/TestPyLong.cs

Lines changed: 0 additions & 208 deletions
This file was deleted.

0 commit comments

Comments
 (0)