// SPDX-License-Identifier: Apache-2.0
; specs/widgets/basics-a-test-block.t27 -- the infographic of lesson 10 of the t27 basics course (specs/course/t27-basics.t27)
; Source of truth for public/widgets/basics-a-test-block/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles
; this file, checks its constants, evaluates the tests below and writes the page. tool.js is one import of
; ../infographic.js, which draws SAY_TABLE_* as a real <table> and SAY_FLOW_* as an SVG diagram with a
; <title>, black and white, and holds no words of its own. ASCII only (L3), English only (LANG-EN).
; The lesson spec it illustrates: public/t27/files/specs/basics/10_a_test_block.t27.
; phi^2 + 1/phi^2 = 3 | TRINITY

module widget_basics_a_test_block;

pub const KIND : str = "widget-tool";
pub const ID : str = "basics-a-test-block";
pub const TITLE : str = "t27 basics 10: a test block, passing and failing";
pub const DESCRIPTION : str = "A t27 test block and the report it gives when it passes and when an assert is false. Lesson 10 of the t27 basics course.";
pub const IMAGE_ALT : str = "A black and white diagram of a t27 test block: the keyword test, a name, asserts in braces; a table shows the same test passing with DAYS = 365 and failing with DAYS = 366, with the failure line the test runner printed.";
pub const HOOK : str = "A t27 test fails with the test name and the assert number. Here is the line.";
pub const CATEGORY : str = "compiler";
pub const DATA_SOURCES : [2]str = ["The lesson spec public/t27/files/specs/basics/10_a_test_block.t27, compiled clean on 7 backends by public/t27/t27_compiler.wasm, whose tests pass in the site test runner", "Compiler verdicts, error lines, code and counts quoted on this page are what the same wasm answered in node 22 when the course was authored; words without a run behind them are said to be read, not run"];
pub const READS_LOCAL_FILES : bool = false;
pub const SENDS_NOTHING : bool = true;

; --- The table -----------------------------------------------------------------------------
pub const SAY_TABLE_CAPTION : str = "test a_year_is_52_weeks_and_a_day";
pub const SAY_TABLE_HEAD : [2]str = ["DAYS", "Report"];
pub const SAY_TABLE_CELLS : [4]str = ["365", "1 test, 1 assert: pass", "366", "a_year_is_52_weeks_and_a_day: assert #1 is false"];
pub const K_TABLE_COLS : u8 = 2;
pub const K_TABLE_ROWS : u8 = 2;
pub const K_TABLE_CELLS : u16 = 4;

; --- The diagram and the note ----------------------------------------------------------------
pub const SAY_FLOW_TITLE : str = "The shape of a test";
pub const SAY_FLOW_STEPS : [3]str = ["test name {", "assert expression;", "}"];
pub const K_FLOW_STEPS : u8 = 3;
pub const SAY_NOTE : str = "The reports are what the site test runner printed for each value.";

test the_cells_fill_whole_rows {
    assert K_TABLE_ROWS * K_TABLE_COLS == K_TABLE_CELLS;
}

test the_table_has_a_body {
    assert K_TABLE_ROWS > 0;
    assert K_TABLE_COLS > 0;
}

test the_diagram_has_every_step {
    assert K_FLOW_STEPS == 3;
    assert K_FLOW_STEPS > 1;
}
