cortex
aien-dev/cortex
Brought by drakestapleton
cortex / tests / json / t_json.om
| 1 | note tests/json/t_json.om - differential harness: per input document two records, |
| 2 | note A = from_slice::<Value> (canonical text or category + message), |
| 3 | note C = js_canon_buf over the same bytes (via jes) followed by js_canon of the A tree again (the tree |
| 4 | note must survive canon_buf), B = axum-style prefix parse + serde_path_to_error path. Needs t_io.om. |
| 5 | fn t_jem to void |
| 6 | for i ulong get jeml 0 |
| 7 | js_byte get jem i |
| 8 | end |
| 9 | end |
| 10 | fn t_res ok bool pfx bool to void |
| 11 | put jobl 0 0 |
| 12 | if ok |
| 13 | js_byte 79 |
| 14 | js_canon get jroot 0 |
| 15 | else |
| 16 | js_byte 69 |
| 17 | js_byte add 48 get jecat 0 |
| 18 | if pfx |
| 19 | if js_path |
| 20 | js_byte 58 |
| 21 | js_byte 32 |
| 22 | end |
| 23 | end |
| 24 | t_jem |
| 25 | end |
| 26 | t_emitjob |
| 27 | end |
| 28 | fn t_cpes n ulong to void |
| 29 | i = ulong 0 |
| 30 | for b ulong 4000 |
| 31 | for c ulong 4000 |
| 32 | if ge i n |
| 33 | ret |
| 34 | end |
| 35 | x = get jin i |
| 36 | put jes i x |
| 37 | i = add i 1 |
| 38 | end |
| 39 | end |
| 40 | end |
| 41 | fn t_canb a bool to void |
| 42 | n = get jinl 0 |
| 43 | t_cpes n |
| 44 | put jobl 0 0 |
| 45 | js_byte 79 |
| 46 | if js_canon_buf 0 n |
| 47 | if a |
| 48 | js_byte 124 |
| 49 | js_canon get jroot 0 |
| 50 | else |
| 51 | js_byte 63 |
| 52 | end |
| 53 | else |
| 54 | put jobl 0 0 |
| 55 | js_byte 70 |
| 56 | end |
| 57 | t_emitjob |
| 58 | end |
| 59 | fn main to int |
| 60 | num_init |
| 61 | for it ulong 100000000 |
| 62 | if not t_rec |
| 63 | t_flush |
| 64 | ret 0 |
| 65 | end |
| 66 | a = js_parse |
| 67 | t_res a false |
| 68 | t_canb a |
| 69 | t_res js_parsep true |
| 70 | end |
| 71 | ret 1 |
| 72 | end |