// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/tc-sort-three.t27 -- lesson 24 of the course "The ternary machine" (specs/course/ternary-computing.t27) ; Source of truth for public/widgets/tc-sort-three/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles this ; file, checks its constants, evaluates the tests below and writes the page; the page hands every constant to ; tool.js as window.T27_WIDGET. tool.js draws through ../ternary-kit.js and computes nothing: every number comes ; from public/widgets/tc-sort-three/logic.js, the fn bodies of the gHashTag/t27 spec in logic.t27, compiled to wasm. ; ASCII only (L3), English only (LANG-EN). ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_tc_sort_three; pub const KIND : str = "widget-tool"; pub const ID : str = "tc-sort-three"; pub const TITLE : str = "Sort three numbers with three-way compares"; pub const DESCRIPTION : str = "Three compares sort three numbers. Each one answers less, equal or greater in one go, so equal values never need a second test."; pub const IMAGE_ALT : str = "Sort three card: 7, -2 and 7 sorted by three compares, each answered with a trit; the two sevens compare equal in one step and stay put. Result: -2, 7, 7."; pub const HOOK : str = "A three-way compare tells equal apart for free. Sorting with ties needs no extra test."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [1]str = ["gHashTag/t27 specs/ternary/trits.t27 (t27#8979): every value on the page is its fn bodies, compiled to wasm (logic.js), with 18 tests and 4108 runtime asserts"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; pub const K_CARD_WIDTH : u16 = 1200; pub const K_CARD_HEIGHT : u16 = 630; pub const SAY_LOADING : str = "Loading"; pub const K_TRITS : u32 = 5; pub const SAY_STEP : str = "compare {0} with {1}: {2} ({3}), {4}"; pub const SAY_SIGNS : [3]str = ["less", "equal", "greater"]; pub const SAY_SWAP : str = "swap"; pub const SAY_KEEP : str = "keep"; pub const SAY_SORTED : str = "sorted: {0}"; pub const SAY_HOW : str = "Compare the first two, the last two, then the first two again: three trits, any order sorted."; pub const SAY_SOURCE : str = "Logic: t27 spec ternary/trits.t27, compiled"; test the_card_is_the_share_size { assert K_CARD_WIDTH == 1200; assert K_CARD_HEIGHT == 630; assert K_CARD_WIDTH * 21 == K_CARD_HEIGHT * 40; } test the_widget_starts_where_its_card_says { assert SENDS_NOTHING == true; assert READS_LOCAL_FILES == false; }