sx sync: catch bindings take parens; Allocator.alloc -> alloc_bytes
This commit is contained in:
@@ -83,7 +83,7 @@ Manifest :: struct {
|
||||
// Copy `s` into `alloc`-owned, null-terminated storage so the manifest
|
||||
// survives the source bytes / parse scratch being dropped.
|
||||
dup_str :: (s: string, alloc: Allocator) -> string {
|
||||
raw : [*]u8 = xx alloc.alloc(s.len + 1);
|
||||
raw : [*]u8 = xx alloc.alloc_bytes(s.len + 1);
|
||||
if s.len > 0 { memcpy(raw, s.ptr, s.len); }
|
||||
raw[s.len] = 0;
|
||||
return string.{ ptr = raw, len = s.len };
|
||||
|
||||
@@ -237,7 +237,7 @@ save :: (self: *Repo, root_dir: string) -> !LoadErr {
|
||||
// Copy `s` into `alloc`-owned, null-terminated storage so it survives the
|
||||
// parse scratch / source buffer being freed.
|
||||
db_dup_str :: (s: string, alloc: Allocator) -> string {
|
||||
raw : [*]u8 = xx alloc.alloc(s.len + 1);
|
||||
raw : [*]u8 = xx alloc.alloc_bytes(s.len + 1);
|
||||
if s.len > 0 { memcpy(raw, s.ptr, s.len); }
|
||||
raw[s.len] = 0;
|
||||
return string.{ ptr = raw, len = s.len };
|
||||
|
||||
@@ -108,7 +108,7 @@ check_rejects_bad_slug :: () -> bool {
|
||||
a := valid_app();
|
||||
a.slug = "Bad_Slug"; // uppercase + underscore
|
||||
matched := false;
|
||||
validate_app(a) catch e { matched = (e == error.BadSlug); };
|
||||
validate_app(a) catch (e) { matched = (e == error.BadSlug); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ check_rejects_empty_version :: () -> bool {
|
||||
r := valid_release();
|
||||
r.version = "";
|
||||
matched := false;
|
||||
validate_release(r) catch e { matched = (e == error.EmptyVersion); };
|
||||
validate_release(r) catch (e) { matched = (e == error.EmptyVersion); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ check_rejects_bad_version :: () -> bool {
|
||||
r := valid_release();
|
||||
r.version = "1.2"; // missing PATCH component
|
||||
matched := false;
|
||||
validate_release(r) catch e { matched = (e == error.BadVersion); };
|
||||
validate_release(r) catch (e) { matched = (e == error.BadVersion); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ check_rejects_bad_channel :: () -> bool {
|
||||
c := valid_channel();
|
||||
c.name = "Bad Channel"; // space + uppercase
|
||||
matched := false;
|
||||
validate_channel(c) catch e { matched = (e == error.BadChannelName); };
|
||||
validate_channel(c) catch (e) { matched = (e == error.BadChannelName); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ check_rejects_empty_content_type :: () -> bool {
|
||||
a := valid_artifact();
|
||||
a.content_type = ""; // required string cleared
|
||||
matched := false;
|
||||
validate_artifact(a) catch e { matched = (e == error.MissingField); };
|
||||
validate_artifact(a) catch (e) { matched = (e == error.MissingField); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ check_rejects_bad_size :: () -> bool {
|
||||
a := valid_artifact();
|
||||
a.size_bytes = -1; // a content-addressed artifact has positive bytes
|
||||
matched := false;
|
||||
validate_artifact(a) catch e { matched = (e == error.BadSize); };
|
||||
validate_artifact(a) catch (e) { matched = (e == error.BadSize); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ check_rejects_bad_digest :: () -> bool {
|
||||
a := valid_artifact();
|
||||
a.sha256 = "not-a-sha"; // not 64 lowercase-hex chars
|
||||
matched := false;
|
||||
validate_artifact(a) catch e { matched = (e == error.BadDigest); };
|
||||
validate_artifact(a) catch (e) { matched = (e == error.BadDigest); };
|
||||
return matched;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ check_missing_artifact_path :: (alloc: Allocator) -> bool {
|
||||
if pe { return false; } // parse must not fail here
|
||||
raised := false;
|
||||
matched := false;
|
||||
validate_manifest(m, "examples") catch err { raised = true; matched = (err == error.MissingArtifact); };
|
||||
validate_manifest(m, "examples") catch (err) { raised = true; matched = (err == error.MissingArtifact); };
|
||||
return raised and matched;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ main :: () -> s32 {
|
||||
arts1.append(mk_artifact("art_01b", "rel_01", "not-a-sha")); // invalid digest
|
||||
failed := false;
|
||||
was_validation := false;
|
||||
repo.publish(mk_release("rel_01", "1.1.0"), @arts1, the_channel()) catch e {
|
||||
repo.publish(mk_release("rel_01", "1.1.0"), @arts1, the_channel()) catch (e) {
|
||||
failed = true;
|
||||
was_validation = (e == error.Validation);
|
||||
};
|
||||
@@ -123,7 +123,7 @@ main :: () -> s32 {
|
||||
arts2.append(mk_artifact("art_02", "WRONG", DIGEST_B)); // release_id mismatch
|
||||
ifailed := false;
|
||||
was_integrity := false;
|
||||
repo.publish(mk_release("rel_02", "1.2.0"), @arts2, the_channel()) catch e {
|
||||
repo.publish(mk_release("rel_02", "1.2.0"), @arts2, the_channel()) catch (e) {
|
||||
ifailed = true;
|
||||
was_integrity = (e == error.Integrity);
|
||||
};
|
||||
@@ -145,7 +145,7 @@ main :: () -> s32 {
|
||||
arts_xc.append(mk_artifact("art_xc", "rel_xc", DIGEST_B)); // self-consistent artifact
|
||||
xc_failed := false;
|
||||
xc_integrity := false;
|
||||
repo.publish(mk_release("rel_xc", "1.3.0"), @arts_xc, mk_channel_for("app_02")) catch e {
|
||||
repo.publish(mk_release("rel_xc", "1.3.0"), @arts_xc, mk_channel_for("app_02")) catch (e) {
|
||||
xc_failed = true;
|
||||
xc_integrity = (e == error.Integrity);
|
||||
};
|
||||
@@ -170,7 +170,7 @@ main :: () -> s32 {
|
||||
arts_xa.append(mk_artifact_for("art_xa", "app_02", "rel_xa", DIGEST_B));
|
||||
xa_failed := false;
|
||||
xa_integrity := false;
|
||||
repo.publish(mk_release("rel_xa", "1.4.0"), @arts_xa, the_channel()) catch e {
|
||||
repo.publish(mk_release("rel_xa", "1.4.0"), @arts_xa, the_channel()) catch (e) {
|
||||
xa_failed = true;
|
||||
xa_integrity = (e == error.Integrity);
|
||||
};
|
||||
@@ -196,7 +196,7 @@ main :: () -> s32 {
|
||||
arts_cn.append(mk_artifact("art_cn", "rel_cn", DIGEST_B)); // self-consistent artifact
|
||||
cn_failed := false;
|
||||
cn_integrity := false;
|
||||
repo.publish(mk_release("rel_cn", "1.5.0"), @arts_cn, mk_named_channel("app_01", "beta")) catch e {
|
||||
repo.publish(mk_release("rel_cn", "1.5.0"), @arts_cn, mk_named_channel("app_01", "beta")) catch (e) {
|
||||
cn_failed = true;
|
||||
cn_integrity = (e == error.Integrity);
|
||||
};
|
||||
@@ -222,7 +222,7 @@ main :: () -> s32 {
|
||||
arts_dup.append(mk_artifact("art_dup", "rel_00", DIGEST_B));
|
||||
dup_failed := false;
|
||||
dup_integrity := false;
|
||||
repo.publish(mk_release("rel_00", "9.9.9"), @arts_dup, the_channel()) catch e {
|
||||
repo.publish(mk_release("rel_00", "9.9.9"), @arts_dup, the_channel()) catch (e) {
|
||||
dup_failed = true;
|
||||
dup_integrity = (e == error.Integrity);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user