authorgravatar for 2179872-misanthrop@users.noreply.gitlab.comSashko <2179872-misanthrop@users.noreply.gitlab.com> 2024-03-12 09:46:21+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-01 16:36:39-07:00
loga717ac0340b6d177e4f02d96dff5418e6961391c
tree91f439cc2a723360be25ea198943641d04272fde
parent604a332e21f9aaff13c7b13331d9c6926c6c9d52

Add a standalone test to cover the duplicate module bug


5 files changed, 56 insertions(+), 0 deletions(-)

test/standalone/build.zig.zon+3
......@@ -86,6 +86,9 @@
8686 .dirname = .{
8787 .path = "dirname",
8888 },
89 .dep_duplicate_module = .{
90 .path = "dep_duplicate_module",
91 },
8992 .empty_env = .{
9093 .path = "empty_env",
9194 },
test/standalone/dep_duplicate_module/build.zig created+32
......@@ -0,0 +1,32 @@
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6
7 const mod = b.addModule("mod", .{
8 .root_source_file = .{ .path = "mod.zig" },
9 .target = target,
10 .optimize = optimize,
11 });
12
13 const lib = b.addStaticLibrary(.{
14 .name = "lib",
15 .root_source_file = .{ .path = "lib.zig" },
16 .target = target,
17 .optimize = optimize,
18 });
19 lib.root_module.addImport("mod", mod);
20
21 const exe = b.addExecutable(.{
22 .name = "app",
23 .root_source_file = .{ .path = "main.zig" },
24 .target = target,
25 .optimize = optimize,
26 });
27
28 exe.root_module.addImport("mod", mod);
29 exe.root_module.linkLibrary(lib);
30
31 b.installArtifact(exe);
32}
test/standalone/dep_duplicate_module/lib.zig created+6
......@@ -0,0 +1,6 @@
1const std = @import("std");
2const mod = @import("mod");
3
4export fn work(x: u32) u32 {
5 return mod.double(x);
6}
test/standalone/dep_duplicate_module/main.zig created+8
......@@ -0,0 +1,8 @@
1const std = @import("std");
2const mod = @import("mod");
3
4extern fn work(x: u32) u32;
5
6pub fn main() !void {
7 _ = work(mod.half(25));
8}
test/standalone/dep_duplicate_module/mod.zig created+7
......@@ -0,0 +1,7 @@
1pub fn double(v: u32) u32 {
2 return v * 2;
3}
4
5pub fn half(v: u32) u32 {
6 return v / 2;
7}