Add a standalone test to cover the duplicate module bug

This commit is contained in:
Sashko 2024-03-12 09:46:21 +01:00 committed by Andrew Kelley
parent 604a332e21
commit a717ac0340
5 changed files with 56 additions and 0 deletions

View File

@ -86,6 +86,9 @@
.dirname = .{
.path = "dirname",
},
.dep_duplicate_module = .{
.path = "dep_duplicate_module",
},
.empty_env = .{
.path = "empty_env",
},

View File

@ -0,0 +1,32 @@
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("mod", .{
.root_source_file = .{ .path = "mod.zig" },
.target = target,
.optimize = optimize,
});
const lib = b.addStaticLibrary(.{
.name = "lib",
.root_source_file = .{ .path = "lib.zig" },
.target = target,
.optimize = optimize,
});
lib.root_module.addImport("mod", mod);
const exe = b.addExecutable(.{
.name = "app",
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("mod", mod);
exe.root_module.linkLibrary(lib);
b.installArtifact(exe);
}

View File

@ -0,0 +1,6 @@
const std = @import("std");
const mod = @import("mod");
export fn work(x: u32) u32 {
return mod.double(x);
}

View File

@ -0,0 +1,8 @@
const std = @import("std");
const mod = @import("mod");
extern fn work(x: u32) u32;
pub fn main() !void {
_ = work(mod.half(25));
}

View File

@ -0,0 +1,7 @@
pub fn double(v: u32) u32 {
return v * 2;
}
pub fn half(v: u32) u32 {
return v / 2;
}