mirror of
https://github.com/ziglang/zig.git
synced 2025-01-10 20:21:16 +00:00
Add a standalone test to cover the duplicate module bug
This commit is contained in:
parent
604a332e21
commit
a717ac0340
@ -86,6 +86,9 @@
|
||||
.dirname = .{
|
||||
.path = "dirname",
|
||||
},
|
||||
.dep_duplicate_module = .{
|
||||
.path = "dep_duplicate_module",
|
||||
},
|
||||
.empty_env = .{
|
||||
.path = "empty_env",
|
||||
},
|
||||
|
32
test/standalone/dep_duplicate_module/build.zig
Normal file
32
test/standalone/dep_duplicate_module/build.zig
Normal 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);
|
||||
}
|
6
test/standalone/dep_duplicate_module/lib.zig
Normal file
6
test/standalone/dep_duplicate_module/lib.zig
Normal file
@ -0,0 +1,6 @@
|
||||
const std = @import("std");
|
||||
const mod = @import("mod");
|
||||
|
||||
export fn work(x: u32) u32 {
|
||||
return mod.double(x);
|
||||
}
|
8
test/standalone/dep_duplicate_module/main.zig
Normal file
8
test/standalone/dep_duplicate_module/main.zig
Normal 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));
|
||||
}
|
7
test/standalone/dep_duplicate_module/mod.zig
Normal file
7
test/standalone/dep_duplicate_module/mod.zig
Normal file
@ -0,0 +1,7 @@
|
||||
pub fn double(v: u32) u32 {
|
||||
return v * 2;
|
||||
}
|
||||
|
||||
pub fn half(v: u32) u32 {
|
||||
return v / 2;
|
||||
}
|
Loading…
Reference in New Issue
Block a user