Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Introduce SemanticVersion data structure #6566

Merged
merged 1 commit into from
Nov 6, 2020

Conversation

jayschwa
Copy link
Contributor

@jayschwa jayschwa commented Oct 5, 2020

This will parse, format, and compare version strings following the
SemVer 2 specification. See: https://semver.org

Updates #6466

@jayschwa jayschwa added the standard library This issue involves writing Zig code for the standard library. label Oct 5, 2020
@jayschwa jayschwa added this to the 0.7.0 milestone Oct 5, 2020
@jayschwa jayschwa changed the title std: Introduce SemanticVersion data structure std: Introduce SemanticVersion data structure Oct 5, 2020
lib/std/semver.zig Outdated Show resolved Hide resolved
This will parse, format, and compare version strings following the
SemVer 2 specification. See: https://semver.org

Updates ziglang#6466
@jayschwa
Copy link
Contributor Author

jayschwa commented Oct 7, 2020

Okay, I think this is in decent shape and ready for review.

One question I have for reviewers is what to do about testFmt. I just copy-pasted it from fmt.zig, which feels icky. Should I just make the original public? Is there some other mechanism of format testing that I missed?

@jayschwa jayschwa marked this pull request as ready for review October 7, 2020 03:34
Comment on lines +284 to +295
fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void {
var buf: [100]u8 = undefined;
const result = try std.fmt.bufPrint(buf[0..], template, args);
if (std.mem.eql(u8, result, expected)) return;

std.debug.warn("\n====== expected this output: =========\n", .{});
std.debug.warn("{}", .{expected});
std.debug.warn("\n======== instead found this: =========\n", .{});
std.debug.warn("{}", .{result});
std.debug.warn("\n======================================\n", .{});
return error.TestFailed;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we move it into std.testing and make it public? Would that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense to me. I suppose I should do that in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR created: #6831

jayschwa added a commit to jayschwa/zig that referenced this pull request Oct 27, 2020
This will enable easier testing for custom formatting implementations.

Motivated by copy-pasted code in PR ziglang#6566.
@andrewrk andrewrk merged commit 030f003 into ziglang:master Nov 6, 2020
@jayschwa jayschwa deleted the semver-struct branch November 6, 2020 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants