zig/test/cases
2024-10-04 22:21:27 +00:00
..
compile_errors remove @fence (#21585) 2024-10-04 22:21:27 +00:00
llvm Revert "Merge pull request #20380 from tau-dev/master" 2024-07-21 02:44:58 -07:00
run_translated_c translate-c: Use mangled name for local extern in condition/loop 2024-07-28 02:58:49 +03:00
safety revert safety test cases to rely on deprecated old API 2024-09-28 12:16:41 -07:00
translate_c translate-c: support GCC/Clang pointer subtraction extension 2024-08-27 06:43:40 +01:00
x86_64-linux
adding_numbers_at_runtime_and_comptime.0.zig
adding_numbers_at_runtime_and_comptime.1.zig
adding_numbers_at_runtime_and_comptime.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
address_of_extern_var_as_const.zig
ambiguous_reference.zig
arithmetic_operations.0.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
arithmetic_operations.1.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
arithmetic_operations.2.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
arithmetic_operations.3.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
arithmetic_operations.4.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
arithmetic_operations.5.zig
arithmetic_operations.6.zig
array_in_anon_struct.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
assert_function.0.zig
assert_function.1.zig
assert_function.2.zig
assert_function.3.zig
assert_function.4.zig
assert_function.5.zig
assert_function.6.zig
assert_function.7.zig
assert_function.8.zig
assert_function.9.zig
assert_function.10.zig
assert_function.11.zig
assert_function.12.zig
assert_function.13.zig
assert_function.14.zig
assert_function.15.zig
assert_function.16.zig
assert_function.17.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
assert_function.18.zig
bad_inferred_variable_type.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.0.zig
binary_operands.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.3.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.4.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.5.zig
binary_operands.6.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.7.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.8.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.9.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.10.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.11.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.12.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.13.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.14.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
binary_operands.15.zig
binary_operands.16.zig
binary_operands.17.zig
binary_operands.18.zig
binary_operands.19.zig
binary_operands.20.zig
binary_operands.21.zig
binary_operands.22.zig
binary_operands.23.zig
binary_operands.24.zig
binary_operands.25.zig
break_continue.0.zig
break_continue.1.zig
break_continue.2.zig
break_continue.3.zig
catch_at_comptime.0.zig
catch_at_comptime.1.zig
catch_at_comptime.2.zig
catch_at_comptime.3.zig
catch_at_comptime.4.zig
comparison_of_non-tagged_union_and_enum_literal.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
compile_error.zig
compile_log.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
compile_log.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
comptime_aggregate_print.zig compiler: rework comptime pointer representation and access 2024-04-17 13:41:25 +01:00
comptime_var.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
comptime_var.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
comptime_var.2.zig
comptime_var.3.zig
comptime_var.4.zig
comptime_var.5.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
comptime_var.6.zig
conditional_branches.0.zig
conditional_branches.1.zig
conditions.0.zig
conditions.1.zig
conditions.2.zig
conditions.3.zig
conditions.4.zig
conditions.5.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
decl_value_arena.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
double_ampersand.0.zig
double_ampersand.1.zig
double_ampersand.2.zig
enum_values.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
enum_values.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
errdefer_discard.zig fix: disallow discard as errdefer capture 2024-09-24 13:21:06 -07:00
error_in_nested_declaration.zig Compilation: introduce work stages for better work distribution 2024-07-13 04:47:38 -04:00
error_unions.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
error_unions.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
error_unions.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
error_unions.3.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
error_unions.4.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
error_unions.5.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
errors.0.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
errors.1.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
errors.2.zig
errors.3.zig
exit.zig disable plan9 test 2024-09-26 21:02:14 -07:00
extern_variable_has_no_type.0.zig
extern_variable_has_no_type.1.zig
f32_passed_to_variadic_fn.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
float_mode_optimized_reduce.zig LLVM: Add test for calling reduce with float mode set to optimized 2024-03-17 16:34:36 +01:00
fn_typeinfo_passed_to_comptime_fn.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
function_calls.0.zig
function_calls.1.zig
function_calls.2.zig
function_calls.3.zig
function_pointers.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
function_redeclaration.zig cases: update for new error wording, add coverage for field/decl name conflict 2024-08-29 23:43:52 +01: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
hello_world_with_updates.0.zig
hello_world_with_updates.1.zig
hello_world_with_updates.2.zig
hello_world_with_updates.3.zig
hello_world_with_updates.4.zig
hello_world_with_updates.5.zig
hello_world_with_updates.6.zig
inherit_want_safety.zig riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07: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
int_to_ptr.0.zig
int_to_ptr.1.zig
large_add_function.zig
locals.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
locals.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
lower_unnamed_consts_structs.0.zig
lower_unnamed_consts_structs.1.zig
lower_unnamed_consts_structs.2.zig
maximum_sized_integer_literal.zig
merge_error_sets.0.zig
merge_error_sets.1.zig
multiplying_numbers_at_runtime_and_comptime.0.zig
multiplying_numbers_at_runtime_and_comptime.1.zig
multiplying_numbers_at_runtime_and_comptime.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
no_compile_panic_for_unchecked_arith.zig Sema: Added logic to avoid unchecked operations calling preparePanicId (#18416) 2024-01-03 02:34:24 -05:00
non_leaf_functions.zig
only_1_function_and_it_gets_updated.0.zig
only_1_function_and_it_gets_updated.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
optional_payload.0.zig
optional_payload.1.zig
optional_payload.2.zig
optional_payload.3.zig
optionals.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
optionals.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
optionals.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
optionals.3.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
optionals.4.zig
orelse_at_comptime.0.zig
orelse_at_comptime.1.zig
parameters_and_return_values.0.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
parameters_and_return_values.1.zig
passing_u0_to_function.zig
pointers.0.zig
pointers.1.zig
print_u32s.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
README.md
recursive_fibonacci.zig
redundant_comptime.0.zig
redundant_comptime.1.zig
returning_undefined_sentinel_terminated_const_u8_slice.zig
returns_in_try.zig
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
setting_an_address_space_on_a_local_variable.zig
spilling_registers.0.zig
spilling_registers.1.zig
structs.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
structs.1.zig
structs.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
structs.3.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
structs.4.zig
switch.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
switch.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
switch.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
switch.3.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
tail_call_noreturn.zig
taking_pointer_of_global_tagged_union.zig
try_in_comptime_in_struct_in_test.zig
type_of.0.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
type_of.1.zig
type_of.2.zig
union_unresolved_layout.zig LLVM lowerDebugType: Lower union types without a layout into an empty namespace 2024-03-17 13:25:09 +02:00
unused_labels.0.zig
unused_labels.1.zig
unused_labels.2.zig
unused_labels.3.zig
unused_vars.zig
variable_shadowing.0.zig
variable_shadowing.1.zig
variable_shadowing.2.zig
variable_shadowing.3.zig
variable_shadowing.4.zig
variable_shadowing.5.zig
variable_shadowing.6.zig
variable_shadowing.7.zig
variable_shadowing.8.zig
variable_shadowing.9.zig
variable_shadowing.10.zig
while_loops.0.zig
while_loops.1.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
while_loops.2.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00: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

Translate-c

If you want to test translating C code to Zig use translate-c:

// translate-c
// c_frontend=aro,clang
// target=x86_64-linux
//
// pub const foo = 1;
// pub const immediately_after_foo = 2;
//
// pub const somewhere_else_in_the_file = 3:

Run Translated C

If you want to test translating C code to Zig and then executing it use run-translated-c:

// run-translated-c
// c_frontend=aro,clang
// target=x86_64-linux
//
// Hello world!

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=stage2,llvm
// target=x86_64-linux,x86_64-macos

Possible backends are:

  • stage1: equivalent to -fstage1.
  • stage2: equivalent to passing -fno-stage1 -fno-LLVM.
  • llvm: equivalent to -fLLVM -fno-stage1.