Skip to content

Commit 9e0d038

Browse files
committed
test: add glyph-selection golden references; document --glyph-selection
New goldens for ascii hybrid/brightness, braille brightness, sculpted brightness. Existing 47 goldens unchanged (mechanism default-off proof). README gains a hybrid-glyph usage example.
1 parent f45489c commit 9e0d038

7 files changed

Lines changed: 176 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ tslime --preset zen --palette ocean --fps 24 # slow and quiet
5050
tslime --seed 42 --population 80000 # reproducible run, denser network
5151
tslime --braille --palette mono # high-resolution monochrome
5252
tslime --palette-cycles 3 --palette-cycle-mode mirror # banded contour coloring
53+
tslime --ascii --glyph-selection hybrid # edge-aware directional glyphs on filaments
5354
tslime --export-gif demo.gif --export-frames 120 --export-fps 30
5455
tslime -p > frame.txt # print a single frame and exit
5556
```

src/config_manager.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,4 +1959,53 @@ init_mode = "Random"
19591959
"palette_cycle must equal default"
19601960
);
19611961
}
1962+
1963+
#[test]
1964+
fn missing_glyph_loads_identity() {
1965+
use crate::render::charset::GlyphConfig;
1966+
1967+
// Old TOML without glyph fields must deserialize and produce GlyphConfig::default().
1968+
let toml = r#"name = "old_no_glyph"
1969+
population = 1000
1970+
sensor_angle = 22.5
1971+
sensor_distance = 9.0
1972+
rotation_angle = 45.0
1973+
step_size = 1.0
1974+
decay_factor = 0.9
1975+
deposit_amount = 5.0
1976+
max_brightness = 100.0
1977+
diffusion_kernel = "Mean3x3"
1978+
diffusion_sigma = 1.0
1979+
palette = "Organic"
1980+
charset = "HalfBlock"
1981+
reverse_palette = false
1982+
invert_palette = false
1983+
warmup_frames = 0
1984+
food_persist = false
1985+
auto_reset = false
1986+
grid = false
1987+
init_mode = "Random"
1988+
"#;
1989+
let cfg: SavedConfig =
1990+
toml::from_str(toml).expect("old config without glyph fields must load");
1991+
assert!(
1992+
cfg.glyph_selection.is_none(),
1993+
"missing glyph_selection must deserialize as None"
1994+
);
1995+
assert!(cfg.glyph_edge_threshold.is_none());
1996+
1997+
// apply_to_runtime_state must produce GlyphConfig::default() (selection = None).
1998+
let mut state = create_test_runtime_state();
1999+
cfg.apply_to_runtime_state(&mut state)
2000+
.expect("legacy config must still apply");
2001+
assert_eq!(
2002+
state.glyph,
2003+
GlyphConfig::default(),
2004+
"missing glyph keys must default to GlyphConfig::default()"
2005+
);
2006+
assert!(
2007+
state.glyph.selection.is_none(),
2008+
"missing glyph_selection must default to None"
2009+
);
2010+
}
19622011
}

tests/golden/ascii_brightness.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[?2026h                                                                                           .                                     .          ..       ..   .......  .... .  .   .....   ...              .. .  ....  ..  ..   ......  .  ...   ..  ..  ..                   .  ....   ...... ...:...  .      ..  ....                     ..  .......    ... ......  ..         ..  .. ..                      ..  .... .....   .. ....... ..   ....  ..  ....                     .  .    ....        ..       ..  .  ...   .         .                    .   .....       ..       ...  .. .....  ..   ..                                                                                                                                       [?2026l

0 commit comments

Comments
 (0)