Reproducible relational test data construction for MoonBit.
| 组件 | 版本 |
|---|---|
| moon | 0.1.20261104 (940aa18 2026-11-04) |
| moonc | v0.10.20+65efd5b93 (2026-11-05) |
| moonrun | 0.1.20261104 (940aa18 2026-11-04) |
| CLI 依赖 | moonbitlang/async 0.22.7、moonbitlang/x 0.5.7 |
| 本地验证 | Windows / MSVC;Node.js v26.5.1;Python 3.12.13 |
moon add tlhuecdkoyg/MoonFixture@0.1.3import {
"tlhuecdkoyg/MoonFixture" @fixture,
} for "test"test "relational fixture" {
let model : @fixture.Model = {
name: "shop",
entities: [
{
name: "users", count: 5,
fields: [@fixture.Field::new("id", Sequence(1, 1), primary=true)],
},
{
name: "orders", count: 20,
fields: [
@fixture.Field::new("id", Sequence(100, 1), primary=true),
@fixture.Field::new("user_id", Reference("users", "id")),
@fixture.Field::new("quantity", IntegerRange(1, 5)),
@fixture.Field::new("unit_price", Constant(Integer(200))),
@fixture.Field::new("total", Multiply("quantity", "unit_price")),
],
},
],
}
let context = @fixture.Context::new(2026U)
let plan = @fixture.compile(model, context~).unwrap()
let data = plan.generate().unwrap()
assert_true(@fixture.validate_dataset(model, data).is_valid())
assert_eq(@fixture.replay(plan.replay_json()).unwrap(), data)
}moon update
moon run cmd/main --target native -- --help
moon run cmd/main --target native -- --version
moon run cmd/main --target native -- generate examples/shop.json --seed 2026 --output shop-data.json
moon run cmd/main --target native -- validate shop-data.json --model examples/shop.json
moon run cmd/main --target native -- manifest examples/shop.json --seed 2026 --output replay.json
moon run cmd/main --target native -- replay replay.json --output replayed-data.json
moon run cmd/main --target native -- generate examples/shop.json --format csv --table products
moon run cmd/main --target native -- generate examples/shop.json --format sqlite --output sqlite-batches.jsonmoon build --target native --deny-warn
python scripts/integration.pymoon check --target all --deny-warn
moon build --target all --deny-warn
moon test --target all --deny-warn
moon fmt --check
moon info
python scripts/verify.py
python scripts/count_lines.py --minimum 4000pub(all) struct BatchProgress {
rows_accepted : Int
batches_accepted : Int
completed : Bool
}pub(all) enum Expectation {
RowCount(String, Int, Int)
NonNull(String, String)
IntegerBounds(String, String, Int, Int)
TextLength(String, String, Int, Int)
LessEqual(String, String, String)
SumEquals(String, String, Int64)
RelatedCount(String, String, String, String, Int, Int)
}pub(all) struct FieldPlan {
name : String
evaluation_index : Int
unique : Bool
primary : Bool
finite_capacity : String?
local_dependencies : Array[String]
parent_entity : String?
}pub(all) struct FieldProfile {
name : String
present : Int
missing : Int
nulls : Int
booleans : Int
true_values : Int
integers : Int
texts : Int
distinct : Int
min_integer : Int?
max_integer : Int?
sum_integer : Int64
min_text_length : Int?
max_text_length : Int?
}pub(all) enum Generator {
Constant(Value)
Sequence(Int, Int)
IntegerRange(Int, Int)
BooleanChance(Int)
Choice(Array[Value])
WeightedChoice(Array[(Value, Int)])
Pattern(String, Int)
DateOffset(Int, Int)
Reference(String, String)
Copy(String)
Add(String, String)
Multiply(String, String)
Concat(Array[String], String)
Lookup(String, String, String, String)
} derive(Eq, Debug)pub(all) struct GroupSummary {
key : Value
count : Int
integer_count : Int
null_count : Int
sum : Int64
min : Int?
max : Int?
}pub(all) struct MutationResult {
dataset : Dataset
operations : Array[Mutation]
report : ValidationReport
}pub(all) struct PlanReport {
model : String
fingerprint : String
rows : Int64
cells : Int64
entities : Array[EntityPlan]
notes : Array[String]
}fn Table::visit_ndjson(self : Table, size : Int, consume : (String) -> Bool, offset? : Int) -> Result[BatchProgress, Issue]fn check_expectations(data : Dataset, expectations : Array[Expectation], max_issues? : Int) -> ValidationReportfn validate_dataset(model : Model, data : Dataset, max_issues? : Int, check_counts? : Bool) -> ValidationReport