zig/test/cases
Ali Cheraghi dec1163fbb
all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
..
compile_errors all: replace all @Type usages 2025-11-22 22:42:38 +00:00
safety
address_of_extern_var_as_const.zig
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
array_in_anon_struct.zig
blocks.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
compile_error.zig
comptime_aggregate_print.zig
decl_value_arena.zig
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 std: allow disabling stack tracing 2025-09-30 13:44:55 +01:00
error_in_nested_declaration.zig sema: disallow slices of opaque types 2025-11-07 12:12:32 +00:00
exit.zig
export_from_body_of_coerced_fn.zig
f32_passed_to_variadic_fn.zig
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
fn_typeinfo_passed_to_comptime_fn.zig
for_loop.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
function_pointers.zig
function_redeclaration.zig
global_variable_redeclaration.zig
hello_world.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
inherit_want_safety.zig
inner_func_accessing_outer_var.zig
large_add_function.zig
large_slices.zig test: pull tests in test/cases/llvm/ up to test/cases/ 2025-09-16 23:39:29 +02:00
maximum_sized_integer_literal.zig
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
non_leaf_functions.zig
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
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
print_u32s.zig
README.md delete all the translate-c tests 2025-09-24 20:01:17 -07:00
recursive_fibonacci.zig
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
returns_in_try.zig
runtime_bitwise_and.zig
runtime_bitwise_or.zig
save_function_return_values_in_callee_preserved_register.zig
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
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
tail_call_noreturn.zig
taking_pointer_of_global_tagged_union.zig
try_in_comptime_in_struct_in_test.zig
type_names.zig
union_unresolved_layout.zig
unused_vars.zig
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.