flan/test/programs/dev-break.flan
Joseph Ferano 96ab4c9cf0 Retire the per-type printers, since print says all of it
print-str, print-i64, print-f64, print-bytes, print-line and newline leave
the prelude. print and println are the whole printing surface now, and print
is the better call at every one of the sites that used them: it is the same
structural walk without the newline, so the no-newline case the family was
kept for is covered, and it takes the value as it is. The old print-i64
forced an explicit (i64 x) at every call site, because this language widens
nothing implicitly; that cast is gone from 127 places.

Dropping it moves one answer. hash-grid returns u64, and the cast through
the signed printer showed sand-headless's hash as -2851001042534928384.
print routes a u64 through flan_u64_to_bytes, so it now prints
15595743031174623232 — the same 64 bits, read as the unsigned number they
are. The pinned expectation follows the correction.

test-flan-dev.el and test_session.ml both reached for print-line as "a name
the prelude has"; they reach for rand-seed instead.
2026-09-12 05:32:25 +07:00

34 lines
1.0 KiB
Plaintext

;;;; A program that stops, for driving the break loop from an editor.
;;;;
;;;; It errors on its first frame, with nothing having handled the condition,
;;;; so [flan dev] meets a program that is already stopped — which is the state
;;;; an editor has to cope with, and the one that is hardest to arrange on
;;;; purpose later. Two restarts are on offer and they return different values,
;;;; so the transcript says which one was chosen.
;;;;
;;;; After resuming it keeps polling, because the claim worth testing is that
;;;; everything else still works on either side of a break.
(import agent "vendor:agent")
(defstruct Missing [id i32])
(defn fetch [n i32] i32
(restart-case
(do (error (Missing {:id n})) 0)
(use-placeholder [] -1)
(retry [] 7)))
(defvar ticks i64)
(defn step [] i64
(set ticks (+ ticks 1))
ticks)
(defn main [] i32
(agent/start "/tmp/flan-dev-break-fallback.sock")
(print (fetch 1)) (println "")
(dotimes [i 4000]
(agent/wait 5)
(set ticks (step)))
0)