Files
alkane-os/vendor/serde_json/tests/debug.rs
T
x ad31cfbafa Vendor flare-ui v0.2.9 and prove the schema-driven UI in an image
Spike, not the final UI: it answers whether flare-ui can drive Alkane OS's
on-box pages, and what it costs.

What works:

- schema/alkane-bb.json authors the sidebar as data (3 sections, 14 tabs);
- src/bin/ui-spike.rs renders it through flare_ui::nav + flare_ui::shell, so
  the unified sidebar, ordering and surface filtering come from the schema
  rather than from hand-written HTML;
- the render uses the shared bf- design tokens, the same ones the rest of the
  suite uses.

Size, measured rather than assumed (armv7, release, stripped):

  ui-baseline   323 KiB   (maud + serde_json, no flare-ui)
  ui-spike      771 KiB   (flare-ui + wschema + sha2)
  marginal      448 KiB

Vendoring: third-party/flare-ui is the full v0.2.9 tree pinned in
flare-ui/flare-ui.lock (a partial archive does not compile, since the crate
include_str!s assets from dash-editor/). vendor/ is re-generated as a cargo
directory source with the new registry dependencies (maud, sha2, typenum,
digest, generic-array, block-buffer, crypto-common, cfg-if, etc.) so the build
still works offline. third-party/README.md records how to re-pin.
2026-11-04 14:06:25 -06:00

84 lines
2.0 KiB
Rust

#![allow(clippy::uninlined_format_args)]
use indoc::indoc;
use serde_json::{json, Number, Value};
#[test]
fn number() {
assert_eq!(format!("{:?}", Number::from(1)), "Number(1)");
assert_eq!(format!("{:?}", Number::from(-1)), "Number(-1)");
assert_eq!(
format!("{:?}", Number::from_f64(1.0).unwrap()),
"Number(1.0)"
);
}
#[test]
fn value_null() {
assert_eq!(format!("{:?}", json!(null)), "Null");
}
#[test]
fn value_bool() {
assert_eq!(format!("{:?}", json!(true)), "Bool(true)");
assert_eq!(format!("{:?}", json!(false)), "Bool(false)");
}
#[test]
fn value_number() {
assert_eq!(format!("{:?}", json!(1)), "Number(1)");
assert_eq!(format!("{:?}", json!(-1)), "Number(-1)");
assert_eq!(format!("{:?}", json!(1.0)), "Number(1.0)");
assert_eq!(Number::from_f64(1.0).unwrap().to_string(), "1.0"); // not just "1"
assert_eq!(Number::from_f64(12e40).unwrap().to_string(), "1.2e+41");
}
#[test]
fn value_string() {
assert_eq!(format!("{:?}", json!("s")), "String(\"s\")");
}
#[test]
fn value_array() {
assert_eq!(format!("{:?}", json!([])), "Array []");
}
#[test]
fn value_object() {
assert_eq!(format!("{:?}", json!({})), "Object {}");
}
#[test]
fn error() {
let err = serde_json::from_str::<Value>("{0}").unwrap_err();
let expected = "Error(\"key must be a string\", line: 1, column: 2)";
assert_eq!(format!("{:?}", err), expected);
}
#[test]
fn indented() {
let j = json!({
"Array": [true],
"Bool": true,
"EmptyArray": [],
"EmptyObject": {},
"Null": null,
"Number": 1,
"String": "...",
});
let expected = indoc! {r#"
Object {
"Array": Array [
Bool(true),
],
"Bool": Bool(true),
"EmptyArray": Array [],
"EmptyObject": Object {},
"Null": Null,
"Number": Number(1),
"String": String("..."),
}"#
};
assert_eq!(format!("{:#?}", j), expected);
}