feat: lifetime elision, tooling CI, registry, and LSP locals
Ship the QUALITY_PLAN stretch from ownership through ecosystem: C.1 lifetime elision (bootstrap + selfhost), bux fmt/test/doc CI hooks, stdlib goldens, package registry (bux search/add), and LSP 0.4 position-sensitive locals with inferred let types. Full-tree format pass plus Map/Set remove double-free fix.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[Package]
|
||||
Name = "stdlib_collections"
|
||||
Version = "0.1.0"
|
||||
Type = "bin"
|
||||
|
||||
[Build]
|
||||
Output = "Bin"
|
||||
@@ -0,0 +1,3 @@
|
||||
stdlib_collections: ok
|
||||
PASS:
|
||||
stdlib_collections
|
||||
@@ -0,0 +1,67 @@
|
||||
// Stdlib golden: Map / Set / Result / Option helpers
|
||||
import Std::Io::{PrintLine};
|
||||
import Std::Map::{
|
||||
Map, Map_New, Map_Set, Map_Get, Map_Has, Map_Remove, Map_Clear,
|
||||
Map_Len, Map_IsEmpty, Map_Free
|
||||
};
|
||||
import Std::Set::{
|
||||
Set, Set_New, Set_Add, Set_Has, Set_Remove, Set_Len, Set_IsEmpty, Set_Free
|
||||
};
|
||||
import Std::Result::{
|
||||
Result, Result_NewOk, Result_NewErr, Result_IsOk, Result_IsErr,
|
||||
Result_UnwrapOr, Result_Or, Result_UnwrapErr
|
||||
};
|
||||
import Std::Option::{
|
||||
Option, Option_NewSome, Option_NewNone, Option_IsSome, Option_Or, Option_UnwrapOr
|
||||
};
|
||||
import Std::String::{String_Eq};
|
||||
import Std::Test::{
|
||||
Test_AssertTrue, Test_AssertFalse, Test_AssertEqInt, Test_Pass
|
||||
};
|
||||
|
||||
func Main() -> int {
|
||||
var m: Map<int, int> = Map_New<int, int>(16);
|
||||
Map_Set<int, int>(&m, 1, 100);
|
||||
Map_Set<int, int>(&m, 2, 200);
|
||||
Map_Set<int, int>(&m, 3, 300);
|
||||
Test_AssertEqInt(Map_Len<int, int>(&m) as int, 3);
|
||||
Test_AssertTrue(Map_Has<int, int>(&m, 2));
|
||||
Test_AssertTrue(Map_Remove<int, int>(&m, 2));
|
||||
Test_AssertFalse(Map_Has<int, int>(&m, 2));
|
||||
Test_AssertEqInt(Map_Get<int, int>(&m, 1), 100);
|
||||
Test_AssertFalse(Map_Remove<int, int>(&m, 99));
|
||||
Map_Clear<int, int>(&m);
|
||||
Test_AssertTrue(Map_IsEmpty<int, int>(&m));
|
||||
Map_Free<int, int>(&m);
|
||||
|
||||
var s: Set<int> = Set_New<int>(16);
|
||||
Set_Add<int>(&s, 10);
|
||||
Set_Add<int>(&s, 20);
|
||||
Set_Add<int>(&s, 30);
|
||||
Test_AssertTrue(Set_Remove<int>(&s, 20));
|
||||
Test_AssertFalse(Set_Has<int>(&s, 20));
|
||||
Test_AssertTrue(Set_Has<int>(&s, 10));
|
||||
Test_AssertEqInt(Set_Len<int>(&s) as int, 2);
|
||||
Test_AssertFalse(Set_IsEmpty<int>(&s));
|
||||
Set_Free<int>(&s);
|
||||
|
||||
let ok: Result = Result_NewOk(42);
|
||||
let err: Result = Result_NewErr("boom");
|
||||
Test_AssertTrue(Result_IsOk(ok));
|
||||
Test_AssertTrue(Result_IsErr(err));
|
||||
Test_AssertEqInt(Result_UnwrapOr(err, -1), -1);
|
||||
let recovered: Result = Result_Or(err, Result_NewOk(7));
|
||||
Test_AssertEqInt(Result_UnwrapOr(recovered, 0), 7);
|
||||
Test_AssertTrue(String_Eq(Result_UnwrapErr(err), "boom"));
|
||||
|
||||
let some: Option = Option_NewSome(5);
|
||||
let none: Option = Option_NewNone();
|
||||
Test_AssertTrue(Option_IsSome(some));
|
||||
Test_AssertEqInt(Option_UnwrapOr(none, 9), 9);
|
||||
let filled: Option = Option_Or(none, Option_NewSome(3));
|
||||
Test_AssertEqInt(Option_UnwrapOr(filled, 0), 3);
|
||||
|
||||
PrintLine("stdlib_collections: ok");
|
||||
Test_Pass("stdlib_collections");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user