Skip to content

Commit bcd5e1b

Browse files
committed
test: restore binary operator test case
1 parent 045719c commit bcd5e1b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

regression-tests/pure2-bugfix-for-discard-precedence.cpp2

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ quantity: type = {
44
number = x;
55
_ = _;
66
}
7+
operator+=: (inout this, that) -> forward quantity = {
8+
_ = number += that.number;
9+
return this;
10+
}
711
}
812

9-
main: () = { _ = :quantity = (std::in_place, 1729); }
13+
main: () = {
14+
x: quantity = (std::in_place, 1729);
15+
_ = x += x;
16+
}

regression-tests/test-results/pure2-bugfix-for-discard-precedence.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ class quantity {
1717
private: cpp2::i32 number;
1818
public: explicit quantity(cpp2::in<std::in_place_t> _, cpp2::in<cpp2::i32> x);
1919

20+
21+
#line 7 "pure2-bugfix-for-discard-precedence.cpp2"
22+
public: [[nodiscard]] auto operator+=(quantity const& that) -> quantity&;
23+
2024
public: quantity(quantity const&) = delete; /* No 'that' constructor, suppress copy */
2125
public: auto operator=(quantity const&) -> void = delete;
2226

2327

24-
#line 7 "pure2-bugfix-for-discard-precedence.cpp2"
28+
#line 11 "pure2-bugfix-for-discard-precedence.cpp2"
2529
};
2630

2731
auto main() -> int;
28-
32+
2933

3034
//=== Cpp2 function definitions =================================================
3135

@@ -38,7 +42,14 @@ auto main() -> int;
3842

3943
static_cast<void>(_);
4044
}
45+
[[nodiscard]] auto quantity::operator+=(quantity const& that) -> quantity&{
46+
static_cast<void>(number += that.number);
47+
return (*this);
48+
}
4149

42-
#line 9 "pure2-bugfix-for-discard-precedence.cpp2"
43-
auto main() -> int{static_cast<void>(quantity{std::in_place, 1729}); }
50+
#line 13 "pure2-bugfix-for-discard-precedence.cpp2"
51+
auto main() -> int{
52+
quantity x {std::in_place, 1729};
53+
static_cast<void>(x += std::move(x));
54+
}
4455

0 commit comments

Comments
 (0)