| ... | @@ -1,5 +1,5 @@ | ... | @@ -1,5 +1,5 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = std.builtin; |
| 3 | const expect = std.testing.expect; | 3 | const expect = std.testing.expect; |
| 4 | const expectEqual = std.testing.expectEqual; | 4 | const expectEqual = std.testing.expectEqual; |
| 5 | const expectEqualStrings = std.testing.expectEqualStrings; | 5 | const expectEqualStrings = std.testing.expectEqualStrings; |
| ... | @@ -1545,6 +1545,68 @@ test "nosuspend on function calls" { | ... | @@ -1545,6 +1545,68 @@ test "nosuspend on function calls" { |
| 1545 | expectEqual(@as(i32, 42), (try nosuspend S1.d()).b); | 1545 | expectEqual(@as(i32, 42), (try nosuspend S1.d()).b); |
| 1546 | } | 1546 | } |
| 1547 | | 1547 | |
| | 1548 | test "nosuspend on async function calls" { |
| | 1549 | const S0 = struct { |
| | 1550 | b: i32 = 42, |
| | 1551 | }; |
| | 1552 | const S1 = struct { |
| | 1553 | fn c() S0 { |
| | 1554 | return S0{}; |
| | 1555 | } |
| | 1556 | fn d() !S0 { |
| | 1557 | return S0{}; |
| | 1558 | } |
| | 1559 | }; |
| | 1560 | var frame_c = nosuspend async S1.c(); |
| | 1561 | expectEqual(@as(i32, 42), (await frame_c).b); |
| | 1562 | var frame_d = nosuspend async S1.d(); |
| | 1563 | expectEqual(@as(i32, 42), (try await frame_d).b); |
| | 1564 | } |
| | 1565 | |
| | 1566 | // test "resume nosuspend async function calls" { |
| | 1567 | // const S0 = struct { |
| | 1568 | // b: i32 = 42, |
| | 1569 | // }; |
| | 1570 | // const S1 = struct { |
| | 1571 | // fn c() S0 { |
| | 1572 | // suspend; |
| | 1573 | // return S0{}; |
| | 1574 | // } |
| | 1575 | // fn d() !S0 { |
| | 1576 | // suspend; |
| | 1577 | // return S0{}; |
| | 1578 | // } |
| | 1579 | // }; |
| | 1580 | // var frame_c = nosuspend async S1.c(); |
| | 1581 | // resume frame_c; |
| | 1582 | // expectEqual(@as(i32, 42), (await frame_c).b); |
| | 1583 | // var frame_d = nosuspend async S1.d(); |
| | 1584 | // resume frame_d; |
| | 1585 | // expectEqual(@as(i32, 42), (try await frame_d).b); |
| | 1586 | // } |
| | 1587 | |
| | 1588 | test "nosuspend resume async function calls" { |
| | 1589 | const S0 = struct { |
| | 1590 | b: i32 = 42, |
| | 1591 | }; |
| | 1592 | const S1 = struct { |
| | 1593 | fn c() S0 { |
| | 1594 | suspend; |
| | 1595 | return S0{}; |
| | 1596 | } |
| | 1597 | fn d() !S0 { |
| | 1598 | suspend; |
| | 1599 | return S0{}; |
| | 1600 | } |
| | 1601 | }; |
| | 1602 | var frame_c = async S1.c(); |
| | 1603 | nosuspend resume frame_c; |
| | 1604 | expectEqual(@as(i32, 42), (await frame_c).b); |
| | 1605 | var frame_d = async S1.d(); |
| | 1606 | nosuspend resume frame_d; |
| | 1607 | expectEqual(@as(i32, 42), (try await frame_d).b); |
| | 1608 | } |
| | 1609 | |
| 1548 | test "avoid forcing frame alignment resolution implicit cast to *c_void" { | 1610 | test "avoid forcing frame alignment resolution implicit cast to *c_void" { |
| 1549 | const S = struct { | 1611 | const S = struct { |
| 1550 | var x: ?*c_void = null; | 1612 | var x: ?*c_void = null; |