diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-26 19:17:05 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-26 19:17:05 -0400 |
| commit | 7b0542d08b7e8e5ccbe81f495d641305b3b8a264 (patch) | |
| tree | 67060c5620c5a36700abfa9c44d3ce31e35f9da4 /test | |
| parent | 09bc4d6ba366c1a642b3c92c7ec554e95a369053 (diff) | |
| download | zig-7b0542d08b7e8e5ccbe81f495d641305b3b8a264.tar.gz zig-7b0542d08b7e8e5ccbe81f495d641305b3b8a264.zip | |
build system: consolidate duplicate code and more
* add ability to add assembly files when building an exe, obj, or lib
* add implicit cast from `[N]T` to `?[]const T` (closes #343)
* remove link_exe and link_lib in favor of allowing build_exe and
build_lib support no root zig source file
Diffstat (limited to 'test')
| -rw-r--r-- | test/cases/cast.zig | 9 | ||||
| -rw-r--r-- | test/tests.zig | 10 |
2 files changed, 13 insertions, 6 deletions
diff --git a/test/cases/cast.zig b/test/cases/cast.zig index f6425ee464..a9c7b068a4 100644 --- a/test/cases/cast.zig +++ b/test/cases/cast.zig @@ -150,3 +150,12 @@ fn peerTypeEmptyArrayAndSlice(a: bool, slice: []const u8) -> []const u8 { return slice[0...1]; } + +test "implicitly cast from [N]T to ?[]const T" { + assert(mem.eql(u8, ??castToMaybeSlice(), "hi")); + comptime assert(mem.eql(u8, ??castToMaybeSlice(), "hi")); +} + +fn castToMaybeSlice() -> ?[]const u8 { + return "hi"; +} diff --git a/test/tests.zig b/test/tests.zig index d115ed037a..b89a47eff7 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -355,18 +355,16 @@ pub const CompareOutputContext = struct { return; } - const assembly = b.addAssemble("test", root_src); + const exe = b.addExecutable("test", null); + exe.addAssemblyFile(root_src); + exe.setOutputPath(exe_path); for (case.sources.toSliceConst()) |src_file| { const expanded_src_path = %%os.path.join(b.allocator, "test_artifacts", src_file.filename); const write_src = b.addWriteFile(expanded_src_path, src_file.source); - assembly.step.dependOn(&write_src.step); + exe.step.dependOn(&write_src.step); } - const exe = b.addLinkExecutable("test"); - exe.addAssembly(assembly); - exe.setOutputPath(exe_path); - const run_and_cmp_output = RunCompareOutputStep.create(self, exe_path, annotated_case_name, case.expected_output); run_and_cmp_output.step.dependOn(&exe.step); |
