Skip to content

Commit ac957e3

Browse files
committed
Update test expectations for swapped NoisyAlloc overloads
PR 5879 swapped the order of NoisyAlloc constructor overloads: - (int i, double) is now placement new (comes first) - (double d, double) is now factory pointer (comes second) This swap is necessary because pybind11 tries overloads in order until one matches. With int → float conversion now allowed: - create_and_destroy(4, 0.5): Without the swap, (double d, double) would match first (since int → double conversion is allowed), bypassing the more specific (int i, double) overload. With the swap, (int i, double) matches first (exact match), which is correct. - create_and_destroy(3.5, 4.5): (int i, double) fails (float → int is rejected), then (double d, double) matches, which is correct. The swap ensures exact int matches are preferred over double matches when an int is provided, which is the expected overload resolution behavior. Update the test expectations to match the new overload resolution order.
1 parent cc411c6 commit ac957e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/test_factory_constructors.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,10 @@ def test_reallocation_e(capture, msg):
433433
create_and_destroy(3.5, 4.5)
434434
assert msg(capture) == strip_comments(
435435
"""
436-
noisy new # preallocation needed before invoking placement-new overload
437-
noisy placement new # Placement new
438-
NoisyAlloc(double 3.5) # construction
436+
noisy new # preallocation needed before invoking factory pointer overload
437+
noisy delete # deallocation of preallocated storage
438+
noisy new # Factory pointer allocation
439+
NoisyAlloc(double 3.5) # factory pointer construction
439440
---
440441
~NoisyAlloc() # Destructor
441442
noisy delete # operator delete
@@ -450,9 +451,8 @@ def test_reallocation_f(capture, msg):
450451
assert msg(capture) == strip_comments(
451452
"""
452453
noisy new # preallocation needed before invoking placement-new overload
453-
noisy delete # deallocation of preallocated storage
454-
noisy new # Factory pointer allocation
455-
NoisyAlloc(int 4) # factory pointer construction
454+
noisy placement new # Placement new
455+
NoisyAlloc(int 4) # construction
456456
---
457457
~NoisyAlloc() # Destructor
458458
noisy delete # operator delete

0 commit comments

Comments
 (0)