본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    도구

    테스트 결과와 단언

    Read the result of a SELF test invocation and use equality assertions to check returned values.

    Rules

    링크
    규칙topaz.rule.test-result.completion

    Test completion and failure reporting

    topaz test checks the selected entry before execution. After a successful SELF execution, it writes {entry}: test-ok followed by a newline to standard output. A reported runtime failure writes its diagnostic and {entry}: test failed to standard error and exits unsuccessfully. A unit with compilation diagnostics does not execute.

    Success includes deferred cleanup. Deferred errors and process exit codes follow the test command.

    이유

    Checking before execution prevents invalid programs from producing effects. Separate success and failure channels let test runners distinguish completion from a failed test.

    규칙topaz.rule.test-result.assert-eq

    Equality assertions

    The operands of std.test.assertEq(actual, expected) use the ordinary equality domain.

    Equal values return () and execution continues. Unequal values raise TPZ4007 with the rendered actual and expected values.

    Known noncomparable operands produce TPZ5007 during checking.

    Argument evaluation and assertion failure follow Test comparisons.

    이유

    Using ordinary value equality keeps tests consistent with comparisons in program code. Reporting both operands makes a mismatch inspectable.

    Examples

    링크

    A successful test reports completion

    링크
    test-result.tpzA successful test reports completion플레이그라운드 열기 →
    1. let value = 1
    기대 출력종료 코드 0
    test-result.tpz: test-ok
    
    $ topaz test test-result.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. test-result.tpz: test-ok

    Equality returns unit and execution continues

    링크
    assert-eq.tpzEquality returns unit and execution continues플레이그라운드 열기 →
    1. import std.io
    2. import std.test
    3. let result: () = test.assertEq([1, 2], [1, 2])
    4. io.writeLine("{result}")
    기대 출력종료 코드 0
    ()
    
    $ topaz run assert-eq.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. ()

    Reject function equality before execution

    링크
    test-input-bad.tpzReject function equality before execution플레이그라운드 열기 →
    1. import std.test
    2. function value(x: int) -> int { x }
    3. test.assertEq(value, value)
    기대 출력0이 아닌 종료 코드
    표준 출력 없음.
    $ topaz check test-input-bad.tpz --compiler self · 대상 제품 5.21.3
    기대 결과

    기대 결과

    거절 단계 check. 종료 코드가 0이 아닙니다.

    • TPZ5007 →

      test-assert-eq-non-comparable at test-input-bad.tpz:3:1

    An unequal assertion fails the test

    링크
    test-failure.tpzAn unequal assertion fails the test플레이그라운드 열기 →
    1. import std.test
    2. test.assertEq(1, 2)
    대상 제품 5.21.3
    기대 결과

    기대 결과

    The independently intended result is a nonzero exit, TPZ4007, and the test-failed footer. The dedicated installed-CLI product test has not run in this sandbox.

    The intended runtime outcome is TPZ4007, an unsuccessful exit, and test-failure.tpz: test failed on standard error. A dedicated installed-CLI product test checks these observations for this exact fixture. Its execution awaits the public CLI integration run.

    Related

    링크

    Value is not comparable or keyable →

    Assertion failed →

    test →

    std.test.assertEq →

    메뉴

    다운로드 →