Prerequisite
링크Use a Topaz distribution that provides language mode 5.21 and the default SELF compiler.
1. Write a function
링크Save the source in the check example below as first-program.tpz. The function returns a greeting. The final call sends it to std.io.writeLine. This example uses an explicit output operation; it does not depend on automatic printing of a top-level value.
2. Check the program
링크Check the first program
링크import std.iofunction greet(name: string) -> string {return "Hello, {name}!"}io.writeLine(greet("Topaz"))
first-program.tpz: types-ok (2 modules)
first-program.tpz: resolve-ok (2 modules)
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.
관측한 단언 · 통과 · 5.21.3
종료 코드 0.
first-program.tpz: types-ok (2 modules)first-program.tpz: resolve-ok (2 modules)
표준 오류 출력 없음.
- 통과 · expected 0; observed 0
관측한 단언 · 통과 · 5.21.3
종료 코드 0.
first-program.tpz: types-ok (2 modules)first-program.tpz: resolve-ok (2 modules)
표준 오류 출력 없음.
- 통과 · expected 0; observed 0
Expected result: checking succeeds. This step checks the program without running its output operation. If checking fails, follow the reported diagnostic code to Diagnostics. The check reference defines input, options, and output channels.
3. Run the program
링크Run the first program
링크import std.iofunction greet(name: string) -> string {return "Hello, {name}!"}io.writeLine(greet("Topaz"))
Hello, Topaz!
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
Hello, Topaz!
관측한 단언 · 통과 · 5.21.3
종료 코드 0.
Hello, Topaz!
표준 오류 출력 없음.
- 통과 · expected 0; observed 0
- 통과 · stdout matches the authored expectation
- 통과 · stderr matches the authored expectation
관측한 단언 · 통과 · 5.21.3
종료 코드 0.
Hello, Topaz!
표준 오류 출력 없음.
- 통과 · expected 0; observed 0
- 통과 · stdout matches the authored expectation
- 통과 · stderr matches the authored expectation
The run command checks the selected unit before execution. The expected program output is shown above; an observation is displayed after the exact source is executed.
Verification
링크Public Topaz 5.21.3 checked and ran this program successfully in Docs run 42224592687, attempt 2. Both commands exited with code 0, and run printed the expected greeting. The new receipts preserve the observed output from the unchanged fixture and invocation. The earlier receipts remain available.