// Design §15.1. `sakura run` uses the host clock, so expected.stdout is a regex; the test// pins the clock.fngreet(name:String)->Unit!{Clock,Console}{letnow=Clock.now()Console.print("hello, {name}; it is {Instant.format_iso(now)}")}pubfnmain()->Unit!{Clock,Console}{greet("Sakura Lang")}test"greets with the time from the clock"{withClock.fixed(Instant.from_unix_millis(1_767_225_600_000)){greet("Sakura Lang")}expect_output(["hello, Sakura Lang; it is 2026-01-01T00:00:00Z"])}
// Design §15.1. `sakura run` uses the host clock, so expected.stdout is a regex; the test
// pins the clock.
fn greet(name: String) -> Unit ! {Clock, Console} {
let now = Clock.now()
Console.print("hello, {name}; it is {Instant.format_iso(now)}")
}
pub fn main() -> Unit ! {Clock, Console} { greet("Sakura Lang") }
test "greets with the time from the clock" {
with Clock.fixed(Instant.from_unix_millis(1_767_225_600_000)) { greet("Sakura Lang") }
expect_output(["hello, Sakura Lang; it is 2026-01-01T00:00:00Z"])
}
Tab inserts two spaces; press Escape, then Tab, to leave the editor. Control or Command and Enter runs the program.
Press Run to compile and run main.
Runs in your browser: the compiler is WebAssembly, the program a sandboxed worker with a 5 s limit. Console prints here; Clock is virtual from 2026-01-01; Random is seeded; Fs is an empty in-memory directory. Http, Serve, Sql, Llm, WebSocket and Worker are not available, and sakura verify needs Z3, which does not run here; contracts are still checked at run time.