| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -94,7 +94,7 @@ public void CovertTypeError() | |||
| 94 | 94 | [Test] | |
| 95 | 95 | public void ConvertOverflow() | |
| 96 | 96 | { | |
| 97 | - using (var num = new PyLong(ulong.MaxValue)) | ||
| 97 | + using (var num = new PyInt(ulong.MaxValue)) | ||
| 98 | 98 | { | |
| 99 | 99 | IntPtr largeNum = PyRuntime.PyNumber_Add(num.Handle, num.Handle); | |
| 100 | 100 | try | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,7 @@ public void CollectBasicObject() | |||
| 50 | 50 | }; | |
| 51 | 51 | ||
| 52 | 52 | Assert.IsFalse(called, "The event handler was called before it was installed"); | |
| 53 | - Finalizer.Instance.CollectOnce += handler; | ||
| 53 | + Finalizer.Instance.BeforeCollect += handler; | ||
| 54 | 54 | ||
| 55 | 55 | IntPtr pyObj = MakeAGarbage(out var shortWeak, out var longWeak); | |
| 56 | 56 | FullGCCollect(); | |
@@ -81,7 +81,7 @@ public void CollectBasicObject() | |||
| 81 | 81 | } | |
| 82 | 82 | finally | |
| 83 | 83 | { | |
| 84 | - Finalizer.Instance.CollectOnce -= handler; | ||
| 84 | + Finalizer.Instance.BeforeCollect -= handler; | ||
| 85 | 85 | } | |
| 86 | 86 | Assert.IsTrue(called, "The event handler was not called during finalization"); | |
| 87 | 87 | Assert.GreaterOrEqual(objectCount, 1); | |
@@ -121,7 +121,7 @@ private static IntPtr MakeAGarbage(out WeakReference shortWeak, out WeakReferenc | |||
| 121 | 121 | IntPtr handle = IntPtr.Zero; | |
| 122 | 122 | WeakReference @short = null, @long = null; | |
| 123 | 123 | // 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(); | ||
| 125 | 125 | // must create temp object in a different thread to ensure it is not present | |
| 126 | 126 | // when conservatively scanning stack for GC roots. | |
| 127 | 127 | // see https://xamarin.github.io/bugzilla-archives/17/17593/bug.html | |
@@ -234,7 +234,7 @@ private static IntPtr CreateStringGarbage() | |||
| 234 | 234 | { | |
| 235 | 235 | PyString s1 = new PyString("test_string"); | |
| 236 | 236 | // s2 steal a reference from s1 | |
| 237 | - PyString s2 = new PyString(s1.Handle); | ||
| 237 | + PyString s2 = new PyString(StolenReference.DangerousFromPointer(s1.Handle)); | ||
| 238 | 238 | return s1.Handle; | |
| 239 | 239 | } | |
| 240 | 240 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,15 +21,6 @@ public void Dispose() | |||
| 21 | 21 | PythonEngine.Shutdown(); | |
| 22 | 22 | } | |
| 23 | 23 | ||
| 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 | - | ||
| 33 | 24 | [Test] | |
| 34 | 25 | public void FloatCtor() | |
| 35 | 26 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,15 +82,6 @@ public void TestCtorSByte() | |||
| 82 | 82 | Assert.AreEqual(i, a.ToInt32()); | |
| 83 | 83 | } | |
| 84 | 84 | ||
| 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 | - | ||
| 94 | 85 | [Test] | |
| 95 | 86 | public void TestCtorPyObject() | |
| 96 | 87 | { | |
@@ -184,9 +175,10 @@ public void TestConvertToInt16() | |||
| 184 | 175 | [Test] | |
| 185 | 176 | public void TestConvertToInt64() | |
| 186 | 177 | { | |
| 187 | - var a = new PyInt(5); | ||
| 178 | + long val = 5 + (long)int.MaxValue; | ||
| 179 | + var a = new PyInt(val); | ||
| 188 | 180 | Assert.IsInstanceOf(typeof(long), a.ToInt64()); | |
| 189 | - Assert.AreEqual(5, a.ToInt64()); | ||
| 181 | + Assert.AreEqual(val, a.ToInt64()); | ||
| 190 | 182 | } | |
| 191 | 183 | } | |
| 192 | 184 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments