// packages/data_formats/examples/demo.vk // Runnable verification suite for `data_formats` (YAML 1.2, XML 1.0, RSS 2.0, and Atom 1.0). use [ df = data_formats yaml = data_formats/yaml xml = data_formats/xml ] assert-eq = fn [actual any, expected any, label str] any [ if actual != expected [ return (err (str/join ['ASSERT FAILED [' label ']: got ' (mold actual) ', expected ' (mold expected)] '')) ] .ok ] assert-true = fn [cond bool, label str] any [ if not cond [ return (err (str/join ['ASSERT FAILED [' label ']'] '')) ] .ok ] main = fn [] any [ println '=== data_formats 1.0.0 Verification Suite ===' // 1. Kubernetes-style YAML 1.2 Deployment manifest + roundtrip encode/decode k8s_yaml = str/join [ '---\n' '# Veko Control Plane Kubernetes Deployment\n' 'apiVersion: apps/v1\n' 'kind: Deployment\n' 'metadata:\n' ' name: veko-gateway\n' ' namespace: production\n' ' labels:\n' ' "app.kubernetes.io/name": veko-gateway\n' ' "app.kubernetes.io/version": \'1.0.0\'\n' 'spec:\n' ' replicas: 3 # active replicas\n' ' paused: false\n' ' canaryWeight: 0.25\n' ' rollbackTo: ~\n' ' architectures: [amd64, arm64]\n' ' resources: { cpu: "500m", memory: "256Mi" }\n' ' notes: >-\n' ' Zero-dependency Veko edge gateway\n' ' running on shared-nothing workers.\n' ' startupScript: |\n' ' #!/bin/sh\n' ' exec /bin/veko-gateway --port=8080\n' ' containers:\n' ' - name: gateway\n' ' image: ghcr.io/veko-lang/gateway:1.0.0\n' ' readOnlyRoot: true\n' ' ports:\n' ' - containerPort: 8080\n' ' protocol: TCP\n' ' - containerPort: 8443\n' ' protocol: TCP\n' ' - name: metrics\n' ' image: ghcr.io/veko-lang/otel:1.0.0\n' ' readOnlyRoot: true\n' '...\n' ] '' doc = yaml/decode k8s_yaml if err? doc [ return doc ] r1 = assert-eq (map/get doc 'apiVersion') 'apps/v1' 'yaml apiVersion' if err? r1 [ return r1 ] meta = map/get doc 'metadata' labels = map/get meta 'labels' r2 = assert-eq (map/get labels 'app.kubernetes.io/version') '1.0.0' 'yaml quoted version string' if err? r2 [ return r2 ] spec = map/get doc 'spec' r3 = assert-eq (map/get spec 'replicas') 3 'yaml i64 replicas' if err? r3 [ return r3 ] r4 = assert-eq (map/get spec 'paused') false 'yaml bool paused' if err? r4 [ return r4 ] r5 = assert-eq (map/get spec 'canaryWeight') 0.25 'yaml f64 canaryWeight' if err? r5 [ return r5 ] r6 = assert-eq (map/get spec 'rollbackTo') .null 'yaml ~ -> .null' if err? r6 [ return r6 ] r7 = assert-eq (map/get spec 'architectures') ['amd64' 'arm64'] 'yaml inline flow sequence' if err? r7 [ return r7 ] res_m = map/get spec 'resources' r8 = assert-eq (map/get res_m 'cpu') '500m' 'yaml inline flow map' if err? r8 [ return r8 ] r9 = assert-eq (map/get spec 'notes') 'Zero-dependency Veko edge gateway running on shared-nothing workers.' 'yaml folded >- block scalar' if err? r9 [ return r9 ] r10 = assert-eq (map/get spec 'startupScript') '#!/bin/sh\nexec /bin/veko-gateway --port=8080\n' 'yaml literal | block scalar' if err? r10 [ return r10 ] containers = map/get spec 'containers' r11 = assert-eq (len containers) 2 'yaml containers sequence len' if err? r11 [ return r11 ] c0 = containers[0] r12 = assert-eq (map/get c0 'image') 'ghcr.io/veko-lang/gateway:1.0.0' 'yaml unquoted colon in image' if err? r12 [ return r12 ] ports0 = map/get c0 'ports' r13 = assert-eq (map/get ports0[1] 'containerPort') 8443 'yaml nested sequence map port' if err? r13 [ return r13 ] // Roundtrip YAML encode -> decode emitted_yaml = df/yaml-encode doc redecoded = df/yaml-decode emitted_yaml if err? redecoded [ return redecoded ] re_spec = map/get redecoded 'spec' re_conts = map/get re_spec 'containers' r14 = assert-eq (map/get re_conts[0] 'name') 'gateway' 'yaml roundtrip container name' if err? r14 [ return r14 ] r15 = assert-eq (map/get re_spec 'startupScript') (map/get spec 'startupScript') 'yaml roundtrip multiline script' if err? r15 [ return r15 ] r16 = assert-eq (map/get re_spec 'rollbackTo') .null 'yaml roundtrip .null' if err? r16 [ return r16 ] println ' [PASS] YAML 1.2 Kubernetes manifest decode & canonical roundtrip encode' // 2. XML 1.0 namespaces, prolog, comments, entities, numeric refs & CDATA xml_src = str/join [ '\n' '\n' '\n' ' Veko & Contributors AB\n' ' \n' ' Edge <Gateway> "v1"\n' ' \n' ' \n' ' \n' ' Replica 'Node'\n' ' \n' '\n' ] '' xroot = df/xml-parse xml_src if err? xroot [ return xroot ] r17 = assert-eq xroot.tag 'catalog' 'xml root tag' if err? r17 [ return r17 ] r18 = assert-eq (df/xml-attr xroot 'region' '') 'eu-west-1' 'xml root attribute' if err? r18 [ return r18 ] r19 = assert-eq (df/xml-child-text xroot 'dc:creator') 'Veko & Contributors AB' 'xml namespace child + hex/dec entities' if err? r19 [ return r19 ] svcs = df/xml-find-all xroot 'service' r20 = assert-eq (len svcs) 2 'xml find-all count' if err? r20 [ return r20 ] r21 = assert-eq (df/xml-child-text svcs[0] 'title') 'Edge "v1"' 'xml entity unescaping' if err? r21 [ return r21 ] r22 = assert-eq (df/xml-child-text svcs[0] 'filter') 'latency_ms < 50 && status == "ok"' 'xml CDATA raw preservation' if err? r22 [ return r22 ] // XML render -> parse roundtrip (also testing &lt; non-double-unescape!) tricky_node = xml/XmlNode { tag = 'note' attrs = { 'expr' = 'a < b & "c"' } children = [] text = 'Literal entity <stays> intact' } rendered_xml = df/xml-render/pretty/decl tricky_node true true reparsed_xml = df/xml-parse rendered_xml r23 = assert-eq reparsed_xml.text 'Literal entity <stays> intact' 'xml single-pass entity safety' if err? r23 [ return r23 ] r24 = assert-eq (df/xml-attr reparsed_xml 'expr' '') 'a < b & "c"' 'xml attribute escape roundtrip' if err? r24 [ return r24 ] println ' [PASS] XML 1.0 parser, namespaces, CDATA, numeric refs & serializer roundtrip' // 3. RSS 2.0 Feed build & parse roundtrip rss_in = xml/RssChannel { title = 'Veko Language Releases' link = 'https://veko-lang.org/releases' description = 'Official compiler & ecosystem updates' language = 'en-us' last_build_date = 'Sat, 05 Dec 2026 01:00:00 GMT' items = [ (xml/RssItem { title = 'Veko 1.0.0 Released' link = 'https://veko-lang.org/releases/1.0.0' description = '64-bit VKO VM, Wasm 3.0 & Native PE32+/ELF64/Mach-O.' guid = 'tag:veko-lang.org,2026:1.0.0' pub_date = 'Sat, 05 Dec 2026 00:00:00 GMT' author = 'team@veko-lang.org' categories = ['compiler' 'release'] }) (xml/RssItem { title = 'Official Ecosystem Packages' link = 'https://veko-lang.org/pkg' description = 'Pure-Veko cloud_s3, data_formats, openapi, smtp_mail & webauthn.' guid = 'tag:veko-lang.org,2026:ecosystem-1' pub_date = 'Sat, 05 Dec 2026 01:00:00 GMT' author = 'team@veko-lang.org' categories = ['packages'] }) ] } rss_xml = df/build-rss rss_in rss_out = df/parse-rss rss_xml if err? rss_out [ return rss_out ] r25 = assert-eq rss_out.title 'Veko Language Releases' 'rss channel title' if err? r25 [ return r25 ] r26 = assert-eq (len rss_out.items) 2 'rss items len' if err? r26 [ return r26 ] r27 = assert-eq rss_out.items[0].guid 'tag:veko-lang.org,2026:1.0.0' 'rss item guid' if err? r27 [ return r27 ] r28 = assert-eq rss_out.items[0].categories ['compiler' 'release'] 'rss item categories' if err? r28 [ return r28 ] println ' [PASS] RSS 2.0 feed codec build & parse roundtrip' // 4. Atom 1.0 Feed build & parse roundtrip atom_in = xml/AtomFeed { id = 'urn:uuid:veko-releases-feed' title = 'Veko Security & Release Advisories' updated = '2026-12-05T01:00:00Z' subtitle = 'Signed VKP1 package advisories' link = 'https://veko-lang.org/atom.xml' author_name = 'Veko Core Team' entries = [ (xml/AtomEntry { id = 'urn:veko:release:1.0.0' title = 'Veko 1.0.0 GA' updated = '2026-12-05T00:00:00Z' link = 'https://veko-lang.org/releases/1.0.0' summary = 'General availability across Windows, Linux, macOS, and Wasm.' content = '

Deterministic single-owner memory & gradual types.

' author_name = 'Veko Core Team' }) ] } atom_xml = df/build-atom atom_in atom_out = df/parse-atom atom_xml if err? atom_out [ return atom_out ] r29 = assert-eq atom_out.id 'urn:uuid:veko-releases-feed' 'atom feed id' if err? r29 [ return r29 ] r30 = assert-eq atom_out.author_name 'Veko Core Team' 'atom feed author' if err? r30 [ return r30 ] r31 = assert-eq (len atom_out.entries) 1 'atom entries len' if err? r31 [ return r31 ] r32 = assert-eq atom_out.entries[0].link 'https://veko-lang.org/releases/1.0.0' 'atom entry link href' if err? r32 [ return r32 ] r33 = assert-eq atom_out.entries[0].content '

Deterministic single-owner memory & gradual types.

' 'atom entry HTML content' if err? r33 [ return r33 ] println ' [PASS] Atom 1.0 (RFC 4287) feed codec build & parse roundtrip' println 'ALL data_formats TESTS PASSED' .ok ] res = main if err? res [ println (mold res) os/exit 1 ]