---
title: "Test Suites"
description: "The test suites that verify Slint SC, how their cases are written, and what they establish."
---
This chapter describes how Slint SC is tested.
The [Qualification Report](/qualification-report/) holds the evidence from running the suites.

## The Suites

Three suites run together, each verifying a different part of the toolchain.
`scripts/slint_sc_test_suite.sh` runs all of them and collects their reports.

### Compiler Syntax Tests

The syntax tests in `internal/compiler/tests/syntax/slint-sc/` run the compiler in SC mode and assert its diagnostics.
Each file pins the expected message to the exact source span that produces the message:

```slint
import { Button } from "std-widgets.slint";
//                     >                 <error{Imports are not supported in Slint SC}
```

These tests carry the weight of the subset.
Slint SC is defined as much by what it rejects as by what it accepts.
So each construct outside the subset has a file asserting that the compiler refuses the construct with a diagnostic the user can act on.

### Runtime Test Cases

The cases in `api/slint-sc/tests/cases/` are `.slint` files that get compiled and executed.
For each case, the driver in `api/slint-sc/tests/driver.rs`:

1. Compiles the case with `slint-compiler --slint-sc` into Rust.
2. Extracts the test body from the fenced `rust` blocks in the case's comments.
3. Compiles the generated code and that body with `rustc`.
4. Runs the resulting binary.
5. Compares the screenshots the case took, if the case took any, against the PNG references in `api/slint-sc/tests/references/`.
6. Measures the coverage of the case's `.slint` code.
   If the case states its expected coverage in caret lines, the driver compares the measurement with them.
   Every case that states its coverage tests that reporting.
   The cases under `coverage/` test nothing else, so the cases under `coverage/` have to state their coverage; see [Coverage Tool Verification](/safety-plan/slint-coverage/).

Step 3 is itself a test.
The runtime is the only `--extern` passed to `rustc`,
so generated code that reaches for any other crate fails to compile rather than shipping an undeclared dependency.

A block marked `compile_fail` inverts the check: the block must fail to compile, with every error named by a `//~ ERROR` line present in the compiler output.
That's how the API-level negative cases are written, such as a component that isn't exported staying unreachable:

```rust
let _ = Hidden::new();
//~ ERROR undeclared type `Hidden`
```

A case that verifies what the runtime draws calls the `screenshot!` macro.
The macro renders the component into a fixed 64x64 RGB buffer, and writes the buffer out for the driver to compare.
Other cases assert in Rust alone and take no screenshot.
The driver compares the screenshot byte for byte against the reference, with no tolerance threshold.
The runtime's determinism makes that possible: no dynamic allocation, no external dependencies, and a caller-provided frame buffer.
A single differing pixel fails the case.

### Runtime Unit Tests

The unit tests in the `slint-sc` crate cover its own API surface, such as color encoding and error formatting.
The unit tests are `no_std`, like the crate itself.

## Tagging Requirements

A test declares the requirements it verifies with `//#sls.…` comments naming their identifiers:

```slint
// A source file with a UTF-8 BOM is well-formed.
//#sls.source.encoding.bom
//#sls.source.encoding.utf8
```

`slint-doc-generator` scans cases, syntax tests, and the Rust sources of the runtime and the compiler for these comments.
Where a requirement is enforced by Rust code rather than by a `.slint` case, the comment sits at that code.
An identifier that matches no requirement paragraph fails the build, so a tag can't outlive the paragraph it names.

## What This Establishes

The evidence runs in two directions, and the build enforces both: every requirement paragraph is traced to a test, and the suites execute all of the runtime.
See [What Is Verified](/safety-plan/verification/#what-is-verified) and [Pass Criteria](/safety-plan/verification/#pass-criteria).
Together, the two directions show that the specified behavior is tested, and that the runtime has no behavior beyond what the tests reach.