0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/test/cases
History 2026-10-21 10:04:01 -07:00
..
compile_errors Sema: check slice load for uninstantiable element type 2026-10-21 10:04:01 -07:00
safety Sema: check slice load for uninstantiable element type 2026-10-21 10:04:01 -07:00
address_of_extern_var_as_const.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
address_space_pointer_access_chaining_pointer_to_optional_array.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
address_spaces_pointer_access_chaining_array_pointer.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
address_spaces_pointer_access_chaining_complex.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
address_spaces_pointer_access_chaining_struct_pointer.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
ambiguous_reference.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
array_in_anon_struct.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
array_sentinel_cursor.zig AstGen: add missing cursor restores 2026-10-09 10:09:42 +02:00
blocks.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
callconv_spirv.zig Added missing local workgroup sizes to spirv_mesh's SpirvMeshOptions and 2026-08-24 17:49:49 +01:00
compile_error.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
comptime_aggregate_print.zig compiler: improve "... contains reference to comptime var" errors 2025-01-11 08:54:47 +00:00
custom_logfn_freestanding.zig test: move issue_7030 from test-standalone simple cases to test-cases 2026-10-10 08:36:08 +02:00
decl_qualifier_cursor.zig AstGen: properly advance cursor for decl qualifiers 2026-10-09 10:09:42 +02:00
decl_value_arena.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
default_value_references_comptime_var.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
dereferencing_though_multiple_pointers_with_address_spaces.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
disable_stack_tracing.zig Removes dead code, updates some tests, fixes typos in comments, formats 2026-04-12 04:01:30 -07:00
empty_global_error_set.zig test: move empty_global_error_set from test-standalone to test-cases 2026-10-10 08:36:07 +02:00
error_union_variant_is_runtime_known.zig sema: remove special case check in is_non_err 2025-12-08 14:59:55 +01:00
exit.zig disable plan9 test 2024-09-26 21:02:14 -07:00
export_from_body_of_coerced_fn.zig frontend: fix reference tracking through coerced function bodies 2025-09-15 11:29:31 +01:00
export_override_libc.zig llvm,Elf: fix strong exports overriding weak exports 2026-10-16 23:46:22 +02:00
f32_passed_to_variadic_fn.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
f_segment_address_space_reading_and_writing.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
float_mode_optimized_reduce.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
fn_typeinfo_passed_to_comptime_fn.zig all: update to use new std.lang.Type definitions 2026-05-27 10:03:51 +01:00
for_loop.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
function_redeclaration.zig compiler: allow files with AstGen errors to undergo semantic analysis 2024-12-05 19:58:38 +00:00
global_variable_redeclaration.zig cases: update for new error wording, add coverage for field/decl name conflict 2024-08-29 23:43:52 +01:00
image_sampling_spirv.zig spirv: don't put dummy OpVariable for non-Function pointers 2026-06-25 15:47:10 +02:00
inherit_want_safety.zig test: Set emit_bin=false for some safety tests. 2024-11-24 22:11:17 +01:00
inner_func_accessing_outer_var.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
large_add_function.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
large_slices.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
main_return_error_u8.zig test: move some test-standalone simple tests to test-cases 2026-10-10 08:36:08 +02:00
main_return_error_u8_non_zero.zig test: move some test-standalone simple tests to test-cases 2026-10-10 08:36:08 +02:00
maximum_sized_integer_literal.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
nested_blocks.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
no_compile_panic_for_unchecked_arith.zig test: Set emit_bin=false for some safety tests. 2024-11-24 22:11:17 +01:00
non_leaf_functions.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
noreturn_call_as_arg.zig test: move some test-standalone simple tests to test-cases 2026-10-10 08:36:08 +02:00
noreturn_call_inline.zig test: move some test-standalone simple tests to test-cases 2026-10-10 08:36:08 +02:00
optionals.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
passing_u0_to_function.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
pointer_keeps_address_space.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
pointer_keeps_address_space_when_taking_address_of_dereference.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
pointer_to_explicit_generic_address_space_coerces_to_implicit_pointer.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
README.md delete all the translate-c tests 2025-09-24 20:01:17 -07:00
recursive_fibonacci.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
rem.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
returning_undefined_sentinel_terminated_const_u8_slice.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
returns_in_try.zig stage2: change how defers are stored in Zir 2022-09-12 01:52:44 -04:00
runtime_bitwise_and.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
runtime_bitwise_or.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
save_function_return_values_in_callee_preserved_register.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
sentinel_references_comptime_var.zig all: replace all @Type usages 2025-11-22 22:42:38 +00:00
setting_an_address_space_on_a_local_variable.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
simple_addition_and_subtraction.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
simple_if_statement.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
spirv_mergable_pointers.zig spirv: require mesh_shading_ext for spirv_task and spirv_mesh 2026-06-25 15:47:10 +02:00
std_debug_no_panic.zig Fix simple_panic 2026-10-03 19:36:46 +02:00
std_debug_simple_panic.zig Fix simple_panic 2026-10-03 19:36:46 +02:00
storage_buffer_opengl.zig hardcode opengl float type alignment 2026-07-08 16:43:51 +02:00
tail_call_noreturn.zig Reverts renaming of builtin.StackTrace -> ErrorReturnTrace 2026-04-12 04:01:30 -07:00
taking_pointer_of_global_tagged_union.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
try_in_comptime_in_struct_in_test.zig tests: translate-c and run-translated-c to the test harness 2023-10-17 11:55:17 +03:00
tuple_assign_cursor.zig AstGen: add missing cursor restores 2026-10-09 10:09:42 +02:00
type_names.zig test: Restore and fix deleted tests that relied on intern pool types (#24422) 2025-07-17 22:07:50 +00:00
union_unresolved_layout.zig test: rename backend=stage2 to backend=selfhosted, and add backend=auto 2025-09-16 23:39:26 +02:00
unused_vars.zig compiler: allow files with AstGen errors to undergo semantic analysis 2024-12-05 19:58:38 +00:00
while_loops.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00

Test Case Quick Reference

Use comments at the end of the file to indicate metadata about the test case. Here are examples of different kinds of tests:

Compile Error Test

If you want it to be run with zig test and match expected error messages:

// error
// is_test=true
//
// :4:13: error: 'try' outside function scope

Execution

This will do zig run on the code and expect exit code 0.

// run

Incremental Compilation

Make multiple files that have ".", and then an integer, before the ".zig" extension, like this:

hello.0.zig
hello.1.zig
hello.2.zig

Each file can be a different kind of test, such as expecting compile errors, or expecting to be run and exit(0). The test harness will use these to simulate incremental compilation.

At the time of writing there is no way to specify multiple files being changed as part of an update.

Subdirectories

Subdirectories do not have any semantic meaning but they can be used for organization since the test harness will recurse into them. The full directory path will be prepended as a prefix on the test case name.

Limiting which Backends and Targets are Tested

// run
// backend=selfhosted,llvm
// target=x86_64-linux,x86_64-macos

Possible backends are:

  • auto: the default; compiler picks the backend based on robustness.
  • selfhosted: equivalent to passing -fno-llvm -fno-lld.
  • llvm: equivalent to -fllvm.