code wiki / (root) / nx_doc_dashboard_test.nx

nx_doc_dashboard_test.nx source

↩ module page · 57 lines · 2306 B

1// nx_doc_dashboard_test.nx -- KAT + visual smoke for D23. 2 3import "nx_syscalls.nx" 4import "nx_string_ops.nx" 5import "nx_doc_decision.nx" 6import "nx_doc_incumbent.nx" 7import "nx_doc_dashboard.nx" 8 9func main() -> i64 { 10 // ----- T1 Header: empty title rejected ----- 11 if nx_doc_dashboard_emit_header("", 0, 20260521, 22) != -1 { return 1 } 12 13 // ----- T2 Header: valid emits 0 ----- 14 if nx_doc_dashboard_emit_header("Substrate dashboard 2026-05-21", 30, 20260521, 22) != 0 { return 2 } 15 16 // ----- T3 Section: empty label rejected ----- 17 if nx_doc_dashboard_emit_section("", 0) != -1 { return 3 } 18 if nx_doc_dashboard_emit_section("Hello", 5) != 0 { return 4 } 19 20 // ----- T4 Substrate-state summary ----- 21 nx_doc_dashboard_emit_substrate_state(7, 5, 44, 44, 0, 0) 22 23 // ----- T5 Footer always emits ----- 24 nx_doc_dashboard_emit_footer() 25 26 // ----- T6 Compose dashboard with one ADR + one incumbent table ----- 27 let decisions_buf: *u8 = sys_mmap(256) 28 let dr: *NxDecisionRecord = decisions_buf as *NxDecisionRecord 29 nx_decision_record_init(dr, 1, 20260521) 30 dr.title_ptr = "Use Boyer-Moore for nx_grep"; dr.title_len = 28 31 dr.status = NX_DECISION_ACCEPTED 32 dr.problem_ptr = "Substring search needs skip-on-mismatch."; dr.problem_len = 40 33 dr.chosen_ptr = "Boyer-Moore baseline; SIMD variant queued."; dr.chosen_len = 42 34 35 let table_buf: *u8 = sys_mmap(128) 36 let t: *NxIncumbentTable = table_buf as *NxIncumbentTable 37 nx_incumbent_table_init(t, NX_PCLASS_PATTERN_MATCHING, 38 "substring 1 GiB", 15, "ops/sec Q14", 11, 39 16384, NX_PROVENANCE_PERSONALLY_MEASURED) 40 let rows_buf: *u8 = sys_mmap(2 * 48 + 16) 41 let rows: *NxIncumbentRow = rows_buf as *NxIncumbentRow 42 nx_incumbent_row_init(rows, "ripgrep", 7, "14.1.0", 6, 24576, NX_PROVENANCE_INDUSTRY_STATED) 43 let r1: *NxIncumbentRow = ((rows_buf as *u8) + 48) as *NxIncumbentRow 44 nx_incumbent_row_init(r1, "GNU grep", 8, "3.11", 4, 8192, NX_PROVENANCE_CROSS_VALIDATED) 45 nx_incumbent_table_set_rows(t, rows, 2) 46 47 let rc: i64 = nx_doc_dashboard_compose( 48 "Substrate dashboard 2026-05-21", 30, 49 20260521, 22, 50 7, 5, 44, 44, 0, 0, 51 dr, 1, 52 t, 1 53 ) 54 if rc != 0 { return 6 } 55 56 return 0 57}