aboutsummaryrefslogtreecommitdiff
path: root/test/incremental/change_struct_same_fields
blob: 7af1161326279b743ef4e72d64319d94f33988fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#target=x86_64-linux-selfhosted
#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const S = extern struct { x: u8, y: u8 };
pub fn main() !void {
    const val: S = .{ .x = 100, .y = 200 };
    try foo(&val);
}
fn foo(val: *const S) !void {
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print(
        "{d} {d}\n",
        .{ val.x, val.y },
    );
}
const std = @import("std");
#expect_stdout="100 200\n"

#update=change struct layout
#file=main.zig
const S = extern struct { x: u32, y: u32 };
pub fn main() !void {
    const val: S = .{ .x = 100, .y = 200 };
    try foo(&val);
}
fn foo(val: *const S) !void {
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print(
        "{d} {d}\n",
        .{ val.x, val.y },
    );
}
const std = @import("std");
#expect_stdout="100 200\n"

#update=change values
#file=main.zig
const S = extern struct { x: u32, y: u32 };
pub fn main() !void {
    const val: S = .{ .x = 1234, .y = 5678 };
    try foo(&val);
}
fn foo(val: *const S) !void {
    var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
    try stdout_writer.interface.print(
        "{d} {d}\n",
        .{ val.x, val.y },
    );
}
const std = @import("std");
#expect_stdout="1234 5678\n"