Module:Grow-out priority/testcases
From Landrace.wiki
More actions
Documentation for this module may be created at Module:Grow-out priority/testcases/doc
-- Module:Grow-out priority/testcases
-- The method's own cases, run against Module:Grow-out priority. Every case states the figure
-- the method gives; a module output that differs is a failure. Cases come from the method
-- paper, version 0.1: section 8.1 (five invented lots), Table 3 (holdings), Table 4
-- (germination counts) and Table 5 (default actions), with the count table from the method's
-- notes, which gives the same figures as Table 4. Version 0.2 adds the cases of three rulings
-- (17 October 2026): a reproduction with no parent recorded, lots held in a genebank that does not
-- give seed to the community, and the reader wording for a lot with nothing reported. Version 0.3
-- adds the cases of the 9 November 2026 rulings: effective parents, the share of variation expected
-- to remain since collection, plants removed before pollination, and plants that did not finish.
local M = require('Module:Grow-out priority')
local tc = {}
local ASOF = M.parseDate('2026-10-15')
local CTX = { today = ASOF }
local S = M.STEP
local results = {}
local function check(group, case, expected, got)
local e, g = tostring(expected), tostring(got)
results[#results + 1] = { group = group, case = case, expected = e, got = g, ok = (e == g) }
end
local function codes(r)
local out = {}
for _, a in ipairs(r.actions or {}) do out[#out + 1] = a.code end
return out
end
local function has(t, v) for _, x in ipairs(t) do if x == v then return true end end return false end
local function checkHas(group, case, list, v, want)
if want == nil then want = true end
check(group, case, (want and 'includes ' or 'excludes ') .. v,
(has(list, v) and 'includes ' or 'excludes ') .. v)
end
-- Builders --------------------------------------------------------------------------------
local function D() return { lots = {}, accessions = {}, populations = {} } end
local function pop(d, id, t) t.id = id; t.introgression = t.introgression or {}; t.trait_changes = t.trait_changes or {}; d.populations[id] = t end
local function acc(d, id, t) t.id = id; t.parents = t.parents or {}; d.accessions[id] = t end
local function lot(d, id, t) t.id = id; t.inventory = t.inventory or {}; t.tests = t.tests or {}; d.lots[id] = t end
local FROZEN = 'freezer (-18 to -20 °C)'
-- A backup of 600 seeds expected to germinate (667 at 90%), in another town.
local function goodBackup(d, id, of, accession)
lot(d, id, { accession = accession, lot_role = 'safety duplicate', duplicate_of = of,
storage_site = 'B-1', storage_country = 'India', backup_distance = 'other town', distance_measured_from = of,
handed_out = { 'no' }, received_date = '2024-10-01',
inventory = { { date = '2026-10-01', quantity = 667, storage = FROZEN } },
tests = { { date = '2024-10-15', seeds_tested = 100, seedlings = 90 } } })
end
-- Section 8.1: five invented lots ----------------------------------------------------------
local function lotOneData(band, count)
local d = D()
pop(d, 'P1', { band = band, reachability = 'reachable' })
acc(d, 'A1', { population = 'P1', parent_total = 45, collection_date = '2020-09-01' })
lot(d, 'L1', { accession = 'A1', lot_role = 'main', storage_site = 'H-1', storage_country = 'India',
received_date = '2020-10-01', handed_out = { 'no' },
inventory = { { date = '2026-10-01', quantity = count, storage = FROZEN } },
tests = { { date = '2020-11-01', seeds_tested = 100, seedlings = 90 },
{ date = '2024-10-15', seeds_tested = 100, seedlings = 88 } } })
goodBackup(d, 'L1-backup', 'L1', 'A1')
return d
end
local function section81()
local g = 'Section 8.1'
-- Lot 1
local r1 = M.evaluateLot('L1', lotOneData('Moderate', 3500), CTX)
check(g, 'Lot 1: reading', S.secure, r1.step)
check(g, 'Lot 1: germination (88 of 100; the floor needs 78, the relative line 84)', 'pass', r1.factors['germination'].state)
check(g, 'Lot 1: actions', 0, #r1.actions)
check(g, 'Lot 1: next test due (in three years)', '2029-10-15', r1.nextTest)
-- Lot 1 with its population Very High: no warning to raise.
local r1v = M.evaluateLot('L1', lotOneData('Very High', 3500), CTX)
check(g, 'Lot 1, population Very High: reading', S.secure, r1v.step)
check(g, 'Lot 1, population Very High: irreplaceable', 'true', tostring(r1v.irreplaceable ~= nil))
-- Lot 2
local r2 = M.evaluateLot('L1', lotOneData('Very High', 2400), CTX)
check(g, 'Lot 2: three sowings at 88%', 512, r2.threeSowings)
check(g, 'Lot 2: seeds left before raising', 'warning', r2.factors['seeds left'].state)
check(g, 'Lot 2: reading', S.urgent, r2.step)
check(g, 'Lot 2: reasons', 'seeds left', table.concat(r2.reasons, ', '))
check(g, 'Lot 2: queued for sowing', 'true', tostring(r2.queued))
checkHas(g, 'Lot 2: actions', codes(r2), 'sow')
-- Lot 3
local d3 = D()
pop(d3, 'P3', { band = 'Moderate', reachability = 'reachable' })
acc(d3, 'A3', { population = 'P3', parent_total = 22 })
lot(d3, 'L3', { accession = 'A3', lot_role = 'main', storage_site = 'H-1', storage_country = 'India',
received_date = '2025-12-01', handed_out = { 'no' },
inventory = { { date = '2026-10-01', quantity = 480, storage = FROZEN } },
tests = { { date = '2026-01-10', seeds_tested = 100, seedlings = 88 } } })
goodBackup(d3, 'L3-backup', 'L3', 'A3')
local r3 = M.evaluateLot('L3', d3, CTX)
check(g, 'Lot 3: three sowings at 88%', 512, r3.threeSowings)
check(g, 'Lot 3: reading', S.urgent, r3.step)
check(g, 'Lot 3: reasons', 'seeds left, mother plants', table.concat(r3.reasons, ', '))
check(g, 'Lot 3: queued for sowing', 'true', tostring(r3.queued))
check(g, 'Lot 3: one full sowing at 88%', 171, r3.sowing)
check(g, 'Lot 3: seeds kept in store', 309, r3.rest)
checkHas(g, 'Lot 3: actions', codes(r3), 'sow')
checkHas(g, 'Lot 3: actions', codes(r3), 'pool or re-collect')
checkHas(g, 'Lot 3: no further test', codes(r3), 'first test', false)
checkHas(g, 'Lot 3: no further test', codes(r3), 'retest sooner', false)
-- Lot 4
local function lotFour(count, otherLot)
local d = D()
pop(d, 'P4', { band = 'Moderate', reachability = 'reachable' })
acc(d, 'A4-0', { population = 'P4', parent_total = 40 })
acc(d, 'A4-1', { population = 'P4', parents = { 'A4-0' }, generation = 1, parent_total = 40 })
lot(d, 'L4', { accession = 'A4-1', lot_role = 'main', storage_site = 'H-1', storage_country = 'India',
handed_out = { 'no' }, received_date = '2026-01-01',
inventory = count and { { date = '2026-10-01', quantity = count, storage = FROZEN } } or {} })
if otherLot then
acc(d, 'A4-2', { population = 'P4', parent_total = 40 })
lot(d, 'L4-other', { accession = 'A4-2', inventory = { { date = '2026-10-01', quantity = 1000 } } })
end
return d
end
local d4 = lotFour(nil)
local r4 = M.evaluateLot('L4', d4, CTX)
check(g, 'Lot 4: reading', S.urgent, r4.step)
checkHas(g, 'Lot 4: reasons', r4.reasons, 'grow-out history')
check(g, 'Lot 4: verified copy', 'isolation not recorded', r4.verified)
check(g, 'Lot 4: queued for sowing', 'false', tostring(r4.queued))
check(g, 'Lot 4: flagged for a preservation grow-out', 'true', tostring(r4.preservation))
local p4 = M.evaluatePopulation('P4', d4, CTX)
check(g, 'Lot 4: holdings', S.urgent, p4.holdings.step)
check(g, 'Lot 4: live verified copy (collecting list)', 'false', tostring(p4.holdings.liveVerifiedCopy))
-- Section 8.1 adds that lot 4 is never queued; checked here with a low seed count too.
local r4low = M.evaluateLot('L4', lotFour(300), CTX)
check(g, 'Lot 4 with 300 seeds: queued for sowing', 'false', tostring(r4low.queued))
-- Lots 5a and 5b
local d5 = D()
pop(d5, 'P5', { band = 'Moderate', reachability = 'reachable' })
acc(d5, 'A5a', { population = 'P5', parent_total = 40 })
acc(d5, 'A5b', { population = 'P5' })
lot(d5, 'L5a', { accession = 'A5a', lot_role = 'main', storage_site = 'H5-1', storage_country = 'India',
backup_distance = 'other town', distance_measured_from = 'L5b', handed_out = { 'no' },
received_date = '2026-03-01', inventory = { { date = '2026-10-01', quantity = 400, storage = FROZEN } } })
lot(d5, 'L5b', { accession = 'A5b', lot_role = 'main', storage_site = 'H5-2', storage_country = 'India',
backup_distance = 'other town', distance_measured_from = 'L5a', handed_out = { 'no' },
received_date = '2025-10-15', inventory = { { date = '2025-10-15', quantity = 3500, storage = FROZEN } } })
local r5a = M.evaluateLot('L5a', d5, CTX)
local r5b = M.evaluateLot('L5b', d5, CTX)
check(g, 'Lot 5a: reading', S.urgent, r5a.step)
checkHas(g, 'Lot 5a: reasons', r5a.reasons, 'seeds left')
checkHas(g, 'Lot 5a: actions', codes(r5a), 'sow')
check(g, 'Lot 5b: reading', S.dd, r5b.step)
checkHas(g, 'Lot 5b: not known', r5b.missing, 'germination')
checkHas(g, 'Lot 5b: not known', r5b.missing, 'backup copy')
checkHas(g, 'Lot 5b: not known', r5b.missing, 'mother plants')
check(g, 'Lot 5b: storage (frozen, low risk)', 'pass', r5b.factors['storage'].state)
checkHas(g, 'Lot 5b: actions', codes(r5b), 'first test')
local p5 = M.evaluatePopulation('P5', d5, CTX)
check(g, 'Lots 5a and 5b: holdings', S.dd, p5.holdings.step)
check(g, 'Lots 5a and 5b: collections listed with every lot Urgent', 'A5a',
p5.holdings.listed[1] and p5.holdings.listed[1].id or 'none')
end
-- Table 3: holdings ------------------------------------------------------------------------
-- Two collections in two towns, each site recorded with country and distance class.
local function twoTowns(stepA, stepB, liveA, liveB)
return {
{ id = 'a', collection = 'C1', step = stepA, counting = true, evidencedLive = liveA,
site = 'S1', country = 'India', distance = 'other town', distanceFrom = 'b' },
{ id = 'b', collection = 'C2', step = stepB, counting = true, evidencedLive = liveB,
site = 'S2', country = 'India', distance = 'other town', distanceFrom = 'a' },
}
end
local function table3()
local g = 'Table 3'
local function row(case, expected, entries, listed)
local h = M.readHoldings(entries)
check(g, case, expected, h.step)
if listed then check(g, case .. ': collection listed', listed, h.listed[1] and h.listed[1].id or 'none') end
end
row('No verified copy that is not confirmed dead or used up', S.urgent,
{ { id = 'x', collection = 'C1', step = S.secure, counting = false } })
row('No lot at all', S.urgent, {})
row('Every verified copy is Urgent', S.urgent, twoTowns(S.urgent, S.urgent, true, true))
local one = twoTowns(S.secure, S.secure, true, true); one[2].collection = 'C1'
row('One collection only, whatever its lots (two Secure lots)', S.atrisk, one)
local oneDD = twoTowns(S.dd, S.dd, false, false); oneDD[2].collection = 'C1'
row('One collection only, whatever its lots (two Data deficient lots)', S.atrisk, oneDD)
local town = twoTowns(S.secure, S.secure, true, true); town[1].distance = 'same town'; town[2].distance = 'same town'
row('All verified copies in one town', S.atrisk, town)
row('Two collections in two towns: one Urgent, one At risk', S.atrisk, twoTowns(S.urgent, S.atrisk, true, true))
row('Two collections in two towns: one Urgent, one Data deficient', S.dd, twoTowns(S.urgent, S.dd, true, false), 'C1')
row('Two collections in two towns: both At risk', S.atrisk, twoTowns(S.atrisk, S.atrisk, true, true))
row('Two collections in two towns: one Urgent, one Secure', S.secure, twoTowns(S.urgent, S.secure, true, true), 'C1')
row('Two collections in two towns: one Secure, one Data deficient because its viability is unknown', S.dd,
twoTowns(S.secure, S.dd, true, false))
row('Two collections in two towns: one Secure, one Data deficient for another missing fact, with evidenced live seed',
S.secure, twoTowns(S.secure, S.dd, true, true))
row('Two collections in two towns: both Data deficient', S.dd, twoTowns(S.dd, S.dd, false, false))
-- Section 4: without the site records, or when the two records disagree, no place credit.
local unrec = twoTowns(S.secure, S.secure, true, true); unrec[1].site = nil; unrec[2].site = nil
row('Section 4: two Secure collections, sites not recorded', S.dd, unrec)
local disagree = twoTowns(S.secure, S.secure, true, true); disagree[2].distance = 'same town'
row('Section 4: two Secure collections, the two distance records disagree', S.dd, disagree)
end
-- Table 4 and the count table ------------------------------------------------------------
local COUNTS = {
-- seeds tested, then passes / clearly below at 70%, at 76.5%, at 80.75%
{ 25, 22, 13, 23, 15, 24, 16 },
{ 50, 41, 29, 44, 32, 46, 35 },
{ 100, 78, 61, 84, 68, 88, 73 },
{ 200, 152, 128, 164, 142, 171, 151 },
}
local function counts(g)
local lines = { { 0.70, '70% floor' }, { 0.85 * 0.90, '76.5% (85% of 90%)' }, { 0.85 * 0.95, '80.75% (85% of 95%)' } }
for _, row in ipairs(COUNTS) do
local n = row[1]
for i, l in ipairs(lines) do
check(g, string.format('%d seeds, %s: passes', n, l[2]), row[2 * i], M.passesAt(n, l[1]))
check(g, string.format('%d seeds, %s: clearly below', n, l[2]), row[2 * i + 1], M.clearlyBelowAt(n, l[1]))
end
end
end
-- Table 5: default action by evidence ------------------------------------------------------
local function table5()
local g = 'Table 5'
local function base(t, extra)
local d = D()
pop(d, 'P9', { band = 'Moderate', reachability = 'reachable' })
acc(d, 'A9', { population = 'P9', parent_total = 50 })
local l = { accession = 'A9', lot_role = 'main', storage_site = 'H-1', storage_country = 'India',
handed_out = { 'no' }, received_date = '2025-01-01',
inventory = { { date = '2026-10-01', quantity = 5000, storage = FROZEN } } }
for k, v in pairs(t or {}) do l[k] = v end
lot(d, 'L9', l)
if extra then extra(d) end
return M.evaluateLot('L9', d, CTX)
end
local function inv(q, storage, moisture)
return { { date = '2026-10-01', quantity = q, storage = storage or FROZEN, seed_moisture = moisture } }
end
local function test(n, s) return { { date = '2026-06-01', seeds_tested = n, seedlings = s } } end
local r = base({ tests = test(50, 25) })
check(g, 'Germination clearly below a line: queued', 'true', tostring(r.queued))
checkHas(g, 'Germination clearly below a line', codes(r), 'sow')
r = base({ tests = test(50, 35) })
checkHas(g, 'Germination test between the lines', codes(r), 'retest sooner')
check(g, 'Germination test between the lines: queued', 'false', tostring(r.queued))
r = base({ tests = { { date = '2026-06-01', percent = 60 } } })
checkHas(g, 'A percentage below a line, with no count', codes(r), 'retest with counts')
check(g, 'A percentage below a line: germination', 'warning', r.factors['germination'].state)
r = base({ tests = { { date = '2026-06-01', percent = 95 } } })
check(g, 'A percentage above the lines (section 5.1): germination', 'unknown', r.factors['germination'].state)
r = base({ inventory = inv(5000, 'room temperature') })
checkHas(g, 'Never tested, kept where a fall is predicted', codes(r), 'test at once')
checkHas(g, 'Never tested, kept where a fall is predicted', codes(r), 'cold storage')
check(g, 'Never tested, kept where a fall is predicted: queued', 'false', tostring(r.queued))
r = base({ received_date = '2026-06-01' })
checkHas(g, 'Never tested, kept elsewhere', codes(r), 'first test')
r = base({ inventory = inv(2000), tests = test(50, 45) })
checkHas(g, 'Seeds left below the warning line', codes(r), 'sow')
check(g, 'Seeds left below the warning line: one full sowing at 90%', 167, r.sowing)
check(g, 'Seeds left below the warning line: rest in store', 1833, r.rest)
r = base({ inventory = inv(400) })
check(g, 'Seeds left below the hard line, untested: queued', 'true', tostring(r.queued))
check(g, 'Seeds left below the hard line, untested: sowing at the 70% planning figure', 215, r.sowing)
check(g, 'Seeds left below the hard line, untested: rest in store', 185, r.rest)
checkHas(g, 'Seeds left below the hard line: not tested first', codes(r), 'first test', false)
r = base({ inventory = inv(100) })
check(g, 'Whole lot too small for one full sowing: small sowing', 'true', tostring(r.smallSowing))
checkHas(g, 'Whole lot too small for one full sowing', codes(r), 'sow')
r = base({ inventory = inv(5000, 'room temperature', 8), tests = test(50, 45) })
checkHas(g, 'Storage at the hard line', codes(r), 'cold storage')
r = base({ backup_status = 'confirmed none', tests = test(50, 45) })
checkHas(g, 'The holder confirms there is no backup', codes(r), 'assess spare seed for a backup')
check(g, 'The holder confirms there is no backup: backup copy', 'hard', r.factors['backup copy'].state)
r = base({ tests = test(50, 45) })
checkHas(g, 'Backup status not reported', codes(r), 'confirm whether a backup exists')
check(g, 'Backup status not reported: backup copy', 'unknown', r.factors['backup copy'].state)
r = base({ handed_out = { 'sold' }, inventory = inv(800), tests = test(50, 45) })
checkHas(g, 'Handed out with little left', codes(r), 'stop handing out')
r = base({ tests = test(50, 45) }, function(d) d.accessions.A9.parent_total = 20 end)
checkHas(g, 'Too few mother plants', codes(r), 'pool or re-collect')
r = base({ tests = test(50, 45) }, function(d)
for i = 0, 4 do
acc(d, 'G' .. i, { population = 'P9', parent_total = 50,
parents = i > 0 and { 'G' .. (i - 1) } or nil, generation = i,
regrow_isolation = i > 0 and 'pollen-proof enclosure' or nil })
end
d.lots.L9.accession = 'G4'
end)
checkHas(g, 'Too many grow-outs (4)', codes(r), 'pool or re-collect')
local function unisolated(d)
acc(d, 'A9-1', { population = 'P9', parents = { 'A9' }, generation = 1, parent_total = 50 })
d.lots.L9.accession = 'A9-1'
end
r = base({ inventory = inv(300) }, unisolated)
checkHas(g, 'Isolation not recorded', codes(r), 'do not queue')
check(g, 'Isolation not recorded: queued, even with 300 seeds', 'false', tostring(r.queued))
check(g, 'Isolation not recorded, only live seed: preservation review', 'true', tostring(r.preservation))
r = base({ inventory = inv(300) }, function(d)
unisolated(d)
lot(d, 'L9-other', { accession = 'A9', inventory = { { date = '2026-10-01', quantity = 1000 } } })
end)
check(g, 'Isolation not recorded, another lot held: preservation review', 'false', tostring(r.preservation))
end
-- Other rules (not from a table) -----------------------------------------------------------
local function other()
local g = 'Other rules'
local function seeds(n)
local d = D()
pop(d, 'P', { band = 'Moderate', reachability = 'reachable' })
acc(d, 'A', { population = 'P', parent_total = 50 })
lot(d, 'L', { accession = 'A', inventory = { { date = '2026-10-01', quantity = n, storage = FROZEN } } })
return M.evaluateLot('L', d, CTX).factors['seeds left'].state
end
check(g, 'Seeds left, germination unknown: 449', 'hard', seeds(449))
check(g, 'Seeds left, germination unknown: 450', 'warning', seeds(450))
check(g, 'Seeds left, germination unknown: 2,999', 'warning', seeds(2999))
check(g, 'Seeds left, germination unknown: 3,000', 'unknown', seeds(3000))
-- The field grade is worked out on the population page; a stored grade lapses here too.
check(g, 'Stored field grade with 2014 evidence has lapsed by 2026', 'Data deficient',
M.lapse({ band = 'High', evidenceYear = 2014 }, ASOF).band)
check(g, 'Stored field grade with 2022 evidence stands', 'High', M.lapse({ band = 'high', evidenceYear = 2022 }, ASOF).band)
local dv = lotOneData('very high', 2400)
check(g, 'Stored band read without regard to case (very high): irreplaceable', S.urgent, M.evaluateLot('L1', dv, CTX).step)
-- A population that has changed since the collection makes its lots irreplaceable.
local d = lotOneData('Moderate', 2400)
d.accessions.A1.introgression_at_collection = 'None seen or reported'
d.populations.P1.introgression = { { grade = 'Seen in the plants', date = '2025-08-01' } }
local rc = M.evaluateLot('L1', d, CTX)
check(g, 'Changed population: a seeds-left warning is raised', S.urgent, rc.step)
d.accessions.A1.introgression_at_collection = 'Pure landrace'
rc = M.evaluateLot('L1', d, CTX)
check(g, 'Old level scale at collection: change not known, so replaceability is not known', 'unknown',
rc.factors['replaceability'].state)
check(g, 'Warning with replaceability not known: At risk, may be Urgent', S.atrisk .. ' true', rc.step .. ' ' .. tostring(rc.mayBeUrgent))
end
-- Version 0.2 rulings (17 October 2026) -----------------------------------------------------
local function rulings()
-- A reproduction with no parent recorded: its grow-out history is not known.
local g = 'Ruling: reproductions'
local function repro(t)
local d = lotOneData('Moderate', 3500)
for k, v in pairs(t) do d.accessions.A1[k] = v end
return M.evaluateLot('L1', d, CTX), d
end
local r = repro({ accession_type = 'Reproduction' })
check(g, 'Typed Reproduction, no parent: grow-out history', 'unknown', r.factors['grow-out history'].state)
check(g, 'Typed Reproduction, no parent: reading (lot 1 otherwise Secure)', S.dd, r.step)
checkHas(g, 'Typed Reproduction, no parent: not known', r.missing, 'grow-out history')
check(g, 'Typed Reproduction, no parent: verified copy', 'lineage not traceable', r.verified)
check(g, 'Typed Reproduction, no parent: counts in holdings', 'false', tostring(r.counting))
r = repro({ sourcing_type = 'Multi-generation reproduction' })
check(g, 'Sourced Multi-generation reproduction, no parent: grow-out history', 'unknown', r.factors['grow-out history'].state)
r = repro({ sourcing_type = 'First generation reproduction' })
check(g, 'Sourced First generation reproduction, no parent: grow-out history', 'unknown', r.factors['grow-out history'].state)
r = repro({ accession_type = 'reproduction' })
check(g, 'Type read without regard to case: grow-out history', 'unknown', r.factors['grow-out history'].state)
r = repro({ accession_type = 'General population', sourcing_type = 'Point of Origin' })
check(g, 'Not a reproduction, no parent: still seed from the field', 'pass', r.factors['grow-out history'].state)
check(g, 'Not a reproduction, no parent: reading', S.secure, r.step)
-- With the parent recorded the walk goes on to the collection, as before.
local d = lotOneData('Moderate', 3500)
acc(d, 'A1-1', { population = 'P1', parents = { 'A1' }, generation = 1, parent_total = 45,
accession_type = 'Reproduction', regrow_isolation = 'pollen-proof enclosure' })
d.lots.L1.accession = 'A1-1'
r = M.evaluateLot('L1', d, CTX)
check(g, 'Reproduction with its parent recorded, isolated: grow-out history', 'pass', r.factors['grow-out history'].state)
check(g, 'Reproduction with its parent recorded, isolated: verified copy', 'documented isolation', r.verified)
-- A low seed count still reads Urgent.
local dl = lotOneData('Moderate', 300)
dl.accessions.A1.accession_type = 'Reproduction'
r = M.evaluateLot('L1', dl, CTX)
check(g, 'Typed Reproduction, no parent, 300 seeds: reading', S.urgent, r.step)
check(g, 'Typed Reproduction, no parent, 300 seeds: reasons', 'seeds left', table.concat(r.reasons, ', '))
-- Lots held by a genebank that does not give seed to the community take no reading.
g = 'Ruling: genebank lots'
local function gb(holder, count)
local d2 = lotOneData('Moderate', count or 300)
d2.lots.L1.holder = holder
return M.evaluateLot('L1', d2, CTX), d2
end
r = gb('INRA Maroc')
check(g, 'INRA Maroc lot with 300 seeds: status', S.genebank, r.step)
check(g, 'INRA Maroc lot: reader label', 'Held in a genebank, not distributed', M.stepLabel(r))
check(g, 'INRA Maroc lot: actions', 0, #r.actions)
check(g, 'INRA Maroc lot: queued for sowing', 'false', tostring(r.queued))
check(g, 'INRA Maroc lot: stored step', 'Held in a genebank', M.lotValues(r)['Has seed lot step'])
check(g, 'INRA Maroc lot: stored factors', 0, #M.lotValues(r)['Has seed lot factors'])
check(g, 'INRA Maroc lot: shown without a Next line', 'false', tostring(M.renderLot(r):find('Next:', 1, true) ~= nil))
r = gb('[[INRA Maroc]]')
check(g, 'Holder written as a link', S.genebank, r.step)
r = gb(' inra maroc ')
check(g, 'Holder read without regard to case or spaces', S.genebank, r.step)
r = gb('National Plant Germplasm System')
check(g, 'National Plant Germplasm System lot', S.genebank, r.step)
r = gb('Royal Botanic Gardens, Kew')
check(g, 'Royal Botanic Gardens, Kew lot (seed bank)', S.genebank, r.step)
r = gb('University of Mississippi')
check(g, 'University of Mississippi lot', S.genebank, r.step)
r = gb('Phylos Bioscience')
check(g, 'A company that keeps its seed is not a genebank: read as before (300 seeds)', S.urgent, r.step)
r = gb('Zomia Genetic Library')
check(g, 'A community holder: read as before (300 seeds)', S.urgent, r.step)
-- Holdings rest on the lots the community can reach.
local function popWith(gbHolder)
local d3 = D()
pop(d3, 'PG', { band = 'Moderate', reachability = 'reachable' })
acc(d3, 'AG1', { population = 'PG', parent_total = 40 })
acc(d3, 'AG2', { population = 'PG', parent_total = 40 })
lot(d3, 'LG1', { accession = 'AG1', holder = gbHolder, storage_site = 'G-1', storage_country = 'Morocco',
inventory = { { date = '2026-10-01', quantity = 5000, storage = FROZEN } },
tests = { { date = '2026-06-01', seeds_tested = 100, seedlings = 90 } } })
return d3
end
local pg = M.evaluatePopulation('PG', popWith('INRA Maroc'), CTX)
check(g, 'Population held only in a genebank: holdings', S.urgent, pg.holdings.step)
check(g, 'Population held only in a genebank: why', 'no verified copy the community can reach', pg.holdings.why)
check(g, 'Population held only in a genebank: live verified copy', 'false', tostring(pg.holdings.liveVerifiedCopy))
check(g, 'Population held only in a genebank: genebank lots listed', 1, pg.holdings.genebankLots)
local pc = M.evaluatePopulation('PG', popWith('Zomia Genetic Library'), CTX)
check(g, 'The same lot at a community holder: live verified copy', 'true', tostring(pc.holdings.liveVerifiedCopy))
local d4 = popWith('INRA Maroc')
lot(d4, 'LG2', { accession = 'AG2', holder = 'Zomia Genetic Library', storage_site = 'Z-1', storage_country = 'India',
inventory = { { date = '2026-10-01', quantity = 5000, storage = FROZEN } } })
local pm = M.evaluatePopulation('PG', d4, CTX)
check(g, 'Genebank lot and a community lot: counted lots', 1, #pm.holdings.counting)
check(g, 'Genebank lot and a community lot: holdings (one collection only)', S.atrisk, pm.holdings.step)
-- The only live seed the community can reach, though a genebank holds another lot.
local d5 = popWith('INRA Maroc')
acc(d5, 'AG2-1', { population = 'PG', parents = { 'AG2' }, generation = 1, parent_total = 40 })
lot(d5, 'LG3', { accession = 'AG2-1', holder = 'Zomia Genetic Library',
inventory = { { date = '2026-10-01', quantity = 300, storage = FROZEN } } })
r = M.evaluateLot('LG3', d5, CTX)
check(g, 'Isolation not recorded, other lot only in a genebank: preservation review', 'true', tostring(r.preservation))
-- A lot with nothing reported reads "no data yet"; the stored step stays Data deficient.
g = 'Ruling: no data yet'
local d6 = D()
pop(d6, 'PN', { band = 'Moderate', reachability = 'reachable' })
acc(d6, 'AN', { population = 'PN', parent_total = 40 })
lot(d6, 'LN', { accession = 'AN', holder = 'Coco Genes', lot_role = 'main' })
r = M.evaluateLot('LN', d6, CTX)
check(g, 'Nothing reported: stored step', S.dd, r.step)
check(g, 'Nothing reported: reader label', 'no data yet', M.stepLabel(r))
check(g, 'Nothing reported: stored step value', S.dd, M.lotValues(r)['Has seed lot step'])
check(g, 'Nothing reported: shown without a Next line', 'false', tostring(M.renderLot(r):find('Next:', 1, true) ~= nil))
checkHas(g, 'Nothing reported: stored factors still list what is not known', M.lotValues(r)['Has seed lot factors'], 'germination')
d6.lots.LN.handed_out = { 'sold' }
r = M.evaluateLot('LN', d6, CTX)
check(g, 'Handed out reported: full reading', S.atrisk, M.stepLabel(r))
d6.lots.LN.handed_out = nil
d6.lots.LN.received_date = '2026-09-01'
r = M.evaluateLot('LN', d6, CTX)
check(g, 'Received date reported, still Data deficient: full reading', S.dd, M.stepLabel(r))
check(g, 'Received date reported: Next line shown', 'true', tostring(M.renderLot(r):find('Next:', 1, true) ~= nil))
d6.lots.LN.received_date = nil
d6.lots.LN.inventory = { { quantity = 3500 } }
r = M.evaluateLot('LN', d6, CTX)
check(g, 'A seed count of 3,500 reported: full reading', S.dd, M.stepLabel(r))
-- A lot with nothing reported keeps a reading that is not Data deficient.
local d7 = D()
pop(d7, 'PN', { band = 'Moderate', reachability = 'reachable' })
acc(d7, 'AN0', { population = 'PN', parent_total = 40 })
acc(d7, 'AN1', { population = 'PN', parents = { 'AN0' }, generation = 1, parent_total = 40 })
lot(d7, 'LN1', { accession = 'AN1', holder = 'Coco Genes' })
r = M.evaluateLot('LN1', d7, CTX)
check(g, 'Nothing reported, regrown without isolation recorded: reading', S.urgent, M.stepLabel(r))
end
-- Rulings of 9 November 2026 (method v0.3) -------------------------------------------------
-- A lot one grow-out from its collection that reads Secure: isolated, 40 plants at each step,
-- three sowings and more, tested, frozen, backed up. `g1` adds fields to the grow-out step.
local function growOut(g1, collection, popExtra)
local d = D()
local pt = { band = 'Moderate', reachability = 'reachable' }
for k, v in pairs(popExtra or {}) do pt[k] = v end
pop(d, 'PV', pt)
local a0 = { population = 'PV', parent_total = 40, collection_date = '2020-09-01' }
for k, v in pairs(collection or {}) do a0[k] = v end
acc(d, 'AV0', a0)
local a1 = { population = 'PV', parents = { 'AV0' }, generation = 1, regrow_isolation = 'pollen-proof enclosure',
parent_total = 40 }
for k, v in pairs(g1 or {}) do a1[k] = v end
acc(d, 'AV1', a1)
lot(d, 'LV', { accession = 'AV1', lot_role = 'main', storage_site = 'H-1', storage_country = 'India',
received_date = '2024-10-01', handed_out = { 'no' },
inventory = { { date = '2026-10-01', quantity = 3500, storage = FROZEN } },
tests = { { date = '2024-10-15', seeds_tested = 100, seedlings = 90 } } })
goodBackup(d, 'LV-backup', 'LV', 'AV1')
return d
end
local function rulingsV03()
local g = 'Ruling P2: effective parents'
check(g, 'Seven mothers and one father', 3.5, M.effectiveParents(7, 1))
check(g, 'Twenty mothers and twenty fathers', 40, M.effectiveParents(20, 20))
local r = M.evaluateLot('LV', growOut(), CTX)
check(g, 'Base lot (40 plants at each step, totals only): reading', S.secure, r.step)
check(g, 'Base lot: mother plants', '40 plants at the smallest step', r.factors['mother plants'].text)
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 7, parent_males = 1 }), CTX)
check(g, '7 mothers, 1 father at grow-out 1: mother plants', 'hard', r.factors['mother plants'].state)
check(g, '7 mothers, 1 father at grow-out 1: text', 'seed from 3.5 effective parents (7 mothers, 1 father) (grow-out 1)',
r.factors['mother plants'].text)
check(g, '7 mothers, 1 father at grow-out 1: reading', S.urgent, r.step)
checkHas(g, '7 mothers, 1 father at grow-out 1: actions', codes(r), 'pool or re-collect')
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 20, parent_males = 20 }), CTX)
check(g, '20 mothers, 20 fathers: mother plants', 'pass', r.factors['mother plants'].state)
check(g, '20 mothers, 20 fathers: text (the collection, 40 plants, is not smaller)',
'40 effective parents (20 mothers, 20 fathers) at the smallest step', r.factors['mother plants'].text)
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 30, parent_males = 30 }), CTX)
check(g, '30 mothers, 30 fathers: text', '40 plants at the smallest step', r.factors['mother plants'].text)
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 20, parent_males = 20 }, { parent_total = 60 }), CTX)
check(g, '20 mothers, 20 fathers, collection 60: text',
'40 effective parents (20 mothers, 20 fathers) at the smallest step', r.factors['mother plants'].text)
-- 20 + 10 = 30 plants passed under v0.2; 4 x 20 x 10 / 30 = 26.7 effective parents does not.
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 20, parent_males = 10 }), CTX)
check(g, '20 mothers, 10 fathers (30 plants): mother plants', 'hard', r.factors['mother plants'].state)
check(g, '20 mothers, 10 fathers: text', 'seed from 26.7 effective parents (20 mothers, 10 fathers) (grow-out 1)',
r.factors['mother plants'].text)
-- Both counts given win over a total.
r = M.evaluateLot('LV', growOut({ parent_total = 40, parent_females = 7, parent_males = 1 }), CTX)
check(g, 'Total 40 with 7 mothers and 1 father: mother plants', 'hard', r.factors['mother plants'].state)
-- A total alone is read as before.
r = M.evaluateLot('LV', growOut({ parent_total = 25 }), CTX)
check(g, 'Total 25 alone: text as in v0.2', 'collected from 25 plants (grow-out 1)', r.factors['mother plants'].text)
-- No fathers counted: read as before (mothers plus fathers), not as nought.
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 30, parent_males = 0 }), CTX)
check(g, '30 mothers, 0 fathers: read as 30 plants', 'pass', r.factors['mother plants'].state)
-- The collection counted by sex too.
r = M.evaluateLot('LV', growOut(nil, { parent_total = '', parent_females = 12, parent_males = 4 }), CTX)
check(g, 'Collection of 12 mothers and 4 fathers: text', 'seed from 12 effective parents (12 mothers, 4 fathers) (the collection)',
r.factors['mother plants'].text)
g = 'Ruling P3: variation expected to remain'
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 5, parent_males = 5 }), CTX)
check(g, 'One grow-out of 5 mothers and 5 fathers (Ne 10, 1 - 1/20)', 95, r.variationRemaining)
check(g, 'Shown in the details', 'true',
tostring(M.renderLot(r):find('About 95% of the variation expected to remain since collection', 1, true) ~= nil))
check(g, 'Not stored', 'nil', tostring(M.lotValues(r)['Has variation remaining']))
r = M.evaluateLot('LV', growOut({ parent_total = '', parent_females = 20, parent_males = 20 }), CTX)
check(g, 'One grow-out of 20 and 20 (98.75%, nearest 5%)', 100, r.variationRemaining)
local d = growOut({ parent_total = '', parent_females = 20, parent_males = 20 })
acc(d, 'AV2', { population = 'PV', parents = { 'AV1' }, generation = 2, regrow_isolation = 'pollen-proof enclosure',
parent_females = 7, parent_males = 1 })
d.lots.LV.accession = 'AV2'
r = M.evaluateLot('LV', d, CTX)
check(g, 'Two grow-outs, 20 and 20 then 7 and 1 (0.9875 x 0.8571 = 84.6%)', 85, r.variationRemaining)
check(g, 'Two grow-outs: exact share', '0.846', string.format('%.3f', M.variationRemaining(M.walk('AV2', d))))
d.accessions.AV1.parent_females, d.accessions.AV1.parent_males, d.accessions.AV1.parent_total = nil, nil, 40
r = M.evaluateLot('LV', d, CTX)
check(g, 'One grow-out with a total only: not shown', 'nil', tostring(r.variationRemaining))
check(g, 'Not shown: no line in the details', 'false', tostring(M.renderLot(r):find('variation expected', 1, true) ~= nil))
r = M.evaluateLot('L1', lotOneData('Moderate', 3500), CTX)
check(g, 'Seed from the field (no grow-out): not shown', 'nil', tostring(r.variationRemaining))
d = growOut({ parent_total = '', parent_females = 5, parent_males = 5 })
d.accessions.AV0 = nil
r = M.evaluateLot('LV', d, CTX)
check(g, 'Lineage not traceable to the collection: not shown', 'nil', tostring(r.variationRemaining))
check(g, 'Rounding: 0.974 is 95%', 95, M.roundShare(0.974))
check(g, 'Rounding: 0.976 is 100%', 100, M.roundShare(0.976))
g = 'Ruling P4: plants removed before pollination'
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Tall' } }), CTX)
check(g, 'Tall plants removed: plants left out', 'hard', r.factors['plants left out'].state)
check(g, 'Tall plants removed: text', 'tall plants removed before pollination (grow-out 1)', r.factors['plants left out'].text)
check(g, 'Tall plants removed: reading', S.urgent, r.step)
check(g, 'Tall plants removed: reasons', 'plants left out', table.concat(r.reasons, ', '))
checkHas(g, 'Tall plants removed: actions', codes(r), 'pool or re-collect')
checkHas(g, 'Tall plants removed: stored factors', M.lotValues(r)['Has seed lot factors'], 'plants left out')
check(g, 'Tall plants removed: still a verified copy (isolated)', 'documented isolation', r.verified)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Late-flowering' } }), CTX)
check(g, 'Late-flowering plants removed: reading', S.urgent, r.step)
check(g, 'Late-flowering plants removed: text', 'late-flowering plants removed before pollination (grow-out 1)',
r.factors['plants left out'].text)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'tall' } }), CTX)
check(g, 'Value in lower case: plants left out', 'hard', r.factors['plants left out'].state)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Hermaphrodites' }, hermaphroditism = '20' }), CTX)
check(g, 'Hermaphrodites removed, 20% recorded on the accession: plants left out', 'warning', r.factors['plants left out'].state)
check(g, 'Hermaphrodites removed, recorded: text', 'hermaphrodites removed though the population has them (grow-out 1)',
r.factors['plants left out'].text)
check(g, 'Hermaphrodites removed, recorded: reading', S.atrisk, r.step)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Hermaphrodites' } }, { hermaphroditism = '20 %' }), CTX)
check(g, 'Hermaphrodites removed, "20 %" recorded on the collection: plants left out', 'warning', r.factors['plants left out'].state)
d = growOut({ regrow_removed = { 'Hermaphrodites' } })
acc(d, 'AV-other', { population = 'PV', hermaphroditism = '5' })
r = M.evaluateLot('LV', d, CTX)
check(g, 'Hermaphrodites removed, recorded on another accession of the population: plants left out', 'warning',
r.factors['plants left out'].state)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Hermaphrodites' }, hermaphroditism = '0' }), CTX)
check(g, 'Hermaphrodites removed, 0% recorded: plants left out', 'pass', r.factors['plants left out'].state)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Hermaphrodites' } }), CTX)
check(g, 'Hermaphrodites removed, hermaphroditism not recorded: plants left out', 'pass', r.factors['plants left out'].state)
check(g, 'Hermaphrodites removed, not recorded: reading', S.secure, r.step)
for _, v in ipairs({ 'None', 'Weak or sick', 'Other' }) do
r = M.evaluateLot('LV', growOut({ regrow_removed = { v } }), CTX)
check(g, v .. ': reading', S.secure, r.step)
end
r = M.evaluateLot('LV', growOut(nil, { regrow_removed = { 'Tall' } }), CTX)
check(g, 'Tall plants removed at the field collection: not a grow-out, no effect', 'pass', r.factors['plants left out'].state)
r = M.evaluateLot('LV', growOut({ regrow_removed = { 'Tall', 'Hermaphrodites' }, hermaphroditism = '20' }), CTX)
check(g, 'Tall plants and hermaphrodites removed: text',
'tall plants removed before pollination (grow-out 1); hermaphrodites removed though the population has them (grow-out 1)',
r.factors['plants left out'].text)
r = M.evaluateLot('LV', growOut(), CTX)
check(g, 'Nothing reported: plants left out', 'pass', r.factors['plants left out'].state)
g = 'Ruling P4/P6: every plant finished'
r = M.evaluateLot('LV', growOut({ regrow_finished = 'No' }), CTX)
check(g, 'Not every plant finished: plants left out', 'hard', r.factors['plants left out'].state)
check(g, 'Not every plant finished: text', 'not every plant finished flowering and set seed (grow-out 1)',
r.factors['plants left out'].text)
check(g, 'Not every plant finished: reading', S.urgent, r.step)
r = M.evaluateLot('LV', growOut({ regrow_finished = 'Yes', regrow_setting = 'Under lights' }), CTX)
check(g, 'Every plant finished, under lights: reading', S.secure, r.step)
r = M.evaluateLot('LV', growOut({ regrow_setting = 'Outdoors' }), CTX)
check(g, 'Where grown has no effect (outdoors): reading', S.secure, r.step)
d = growOut()
acc(d, 'AV2', { population = 'PV', parents = { 'AV1' }, generation = 2, regrow_isolation = 'pollen-proof enclosure',
parent_total = 40, regrow_finished = 'Yes' })
d.accessions.AV1.regrow_finished = 'No'
d.lots.LV.accession = 'AV2'
r = M.evaluateLot('LV', d, CTX)
check(g, 'An earlier grow-out did not finish: text', 'not every plant finished flowering and set seed (grow-out 1)',
r.factors['plants left out'].text)
end
-- Runner ----------------------------------------------------------------------------------
function tc.run()
results = {}
section81()
table3()
counts('Table 4')
counts('Count table, method notes')
table5()
other()
rulings()
rulingsV03()
return results
end
function tc.summary(res)
local pass, fail = 0, 0
for _, r in ipairs(res) do if r.ok then pass = pass + 1 else fail = fail + 1 end end
return pass, fail
end
-- Plain text, one line per case.
function tc.plain()
local res = tc.run()
local out = {}
for _, r in ipairs(res) do
out[#out + 1] = table.concat({ r.ok and 'PASS' or 'FAIL', r.group, r.case, r.expected, r.got }, '\t')
end
local pass, fail = tc.summary(res)
out[#out + 1] = string.format('TOTAL\t%d passed\t%d failed\tmethod %s', pass, fail, M.VERSION)
return table.concat(out, '\n')
end
-- {{#invoke:Grow-out priority/testcases|table}}
function tc.table()
local res = tc.run()
local pass, fail = tc.summary(res)
local out = { string.format("'''%d of %d cases reproduced%s''' (method %s).", pass, pass + fail,
fail > 0 and string.format(", '''%d failed'''", fail) or '', M.VERSION),
'{| class="wikitable sortable"', '! Source !! Case !! Paper !! Module !! Result' }
for _, r in ipairs(res) do
out[#out + 1] = '|-'
out[#out + 1] = table.concat({ '| ' .. r.group, r.case, r.expected, r.got,
r.ok and 'match' or "'''differs'''" }, ' || ')
end
out[#out + 1] = '|}'
return table.concat(out, '\n')
end
return tc