fix(domain): js_number rounds exact decimal ties to even as ECMAScript (zmij digits); V8 oracle of 44,322 values, Zod oracle bytes checked against the core's printing
This commit is contained in:
1 parent
64d4595e73
commit
aed6b1e300
8 files changed
+225
-10
No files matched your search
@@ -39,9 +39,19 @@ pub fn oracle_file(name: &str) -> (String, Value) {
|
||||
|
||||
/// A Zod oracle (`crates/core/tests/oracles/<name>`): its source file and the Zod output in
|
||||
/// the JavaScript pretty form.
|
||||
///
|
||||
/// The expected text is printed here by `to_js_pretty`, the function under test; so the
|
||||
/// oracle's own bytes, written by `JSON.stringify` in Node, are first checked against the
|
||||
/// same value printed compactly: a number this side prints differently from V8 fails here
|
||||
/// (R5.1b, F1), not silently on both sides of the comparison.
|
||||
pub fn zod_oracle(name: &str) -> (String, String) {
|
||||
let oracle: Value =
|
||||
serde_json::from_str(&repo_file(&format!("crates/core/tests/oracles/{name}"))).unwrap();
|
||||
let raw = repo_file(&format!("crates/core/tests/oracles/{name}"));
|
||||
let oracle: Value = serde_json::from_str(&raw).unwrap();
|
||||
let reprinted = faunosteo_core::json::to_js_compact(&oracle).unwrap();
|
||||
assert!(
|
||||
raw == format!("{reprinted}\n"),
|
||||
"{name}: the core does not print the oracle's numbers as V8 wrote them"
|
||||
);
|
||||
let source = oracle["source"].as_str().unwrap().to_owned();
|
||||
let output = faunosteo_core::json::to_js_pretty(&oracle["output"]).unwrap();
|
||||
(repo_file(&source), output)
|
||||
|
||||
Reference in new issue
Block a user