interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / crates / allen-design-tokens / tests / exports.rs

102 lines · 3593 bytes Raw Blame History
1//! The committed exports must match DESIGN.md, every gated contrast pair must pass, and the tokens lifted
2//! from the kernel must keep the kernel's values.
3
4use std::path::PathBuf;
5
6fn root() -> PathBuf {
7 PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../..")
8}
9
10fn tokens() -> allen_design_tokens::Tokens {
11 let text = std::fs::read_to_string(root().join("docs/design/DESIGN.md")).unwrap();
12 allen_design_tokens::parse(&text).unwrap()
13}
14
15#[test]
16fn exports_are_current() {
17 for (name, body) in allen_design_tokens::outputs(&tokens()).unwrap() {
18 let path = root().join("docs/design/tokens").join(name);
19 let on_disk = std::fs::read_to_string(&path).unwrap_or_default();
20 assert!(
21 on_disk == body,
22 "{} is stale: run `cargo run -p allen-design-tokens -- generate`",
23 path.display()
24 );
25 }
26}
27
28#[test]
29fn gated_contrast_passes() {
30 for r in allen_design_tokens::check_contrast(&tokens()).unwrap() {
31 assert!(
32 !r.gated || r.passes(),
33 "{} on {}: {:.2}:1 below {:.1}",
34 r.fg,
35 r.bg,
36 r.ratio,
37 r.floor
38 );
39 }
40}
41
42#[test]
43fn kernel_values_are_kept() {
44 // native/kernel/ui on feat/allen-boot-everywhere (iMac 0930240): night.h, chirp.h, allen_ui.c, mind.c
45 let t = tokens();
46 for (path, want) in [
47 ("colors.night", "#060812"),
48 ("colors.primary", "#ECF0FC"),
49 ("colors.hint", "#96A0C4"),
50 ("colors.faint", "#828CB0"),
51 ("colors.glow", "#96AAFF"),
52 ("colors.mist", "#C8D2FF"),
53 ("colors.warm", "#FFD496"),
54 ("colors.heart", "#FFD2AA"),
55 ("colors.heart-core", "#FFECD6"),
56 ("colors.halo", "#3C4AD2"),
57 ("colors.halo-violet", "#705CFF"),
58 ("colors.sky-glow", "#6E82FF"),
59 ("boot.holes-appear", "2600ms"),
60 ("boot.fade-end", "6800ms"),
61 ("boot.spiral", "6000ms"),
62 ("boot.merge", "12000ms"),
63 ("boot.ripple-run", "3600ms"),
64 ("boot.gone", "15200ms"),
65 ("boot.allen-born", "12300ms"),
66 ("boot.allen-formed", "15300ms"),
67 ("sound.chirp-rate", "48000Hz"),
68 ("sound.chirp-from", "200Hz"),
69 ("sound.chirp-to", "1000Hz"),
70 ("sound.chirp-in", "40ms"),
71 ("sound.chirp-rise", "600ms"),
72 ("sound.chirp-start", "11400ms"),
73 ("sound.chirp-end", "12300ms"),
74 ("motion.letter", "35ms"),
75 ("motion.mind-form", "3000ms"),
76 ("motion.caret-breath", "1100ms"),
77 ("heartbeat.breath-period", "5500ms"),
78 ("heartbeat.think-pulse-period", "900ms"),
79 ("native-type.voice-cap", "19px"),
80 ("native-type.body-cap", "15px"),
81 ("native-type.small-cap", "11px"),
82 ("native-type.line", "40px"),
83 ("native-type.wrap", "900px"),
84 ("spacing.bar-width", "720px"),
85 ("spacing.bar-height", "54px"),
86 ] {
87 assert_eq!(t.get(path), Some(want), "{path}");
88 }
89 let c = allen_design_tokens::emit_c(&t);
90 // the kernel's fixed-point forms: chirp peak 22937 (CK_CHIRP_PEAK), breath 1966/65536 (mind.c 173),
91 // heart levels 50, 70, 120, 80 out of 256 (mind.c 137)
92 for line in [
93 "#define ALLEN_SOUND_CHIRP_PEAK_Q15 22937",
94 "#define ALLEN_HEARTBEAT_BREATH_DEPTH_Q16 1966",
95 "#define ALLEN_HEARTBEAT_HEART_IDLE_Q8 50",
96 "#define ALLEN_HEARTBEAT_HEART_LISTEN_Q8 70",
97 "#define ALLEN_HEARTBEAT_HEART_THINK_Q8 120",
98 "#define ALLEN_HEARTBEAT_HEART_SPEAK_Q8 80",
99 ] {
100 assert!(c.contains(line), "missing `{line}`");
101 }
102}