zig/test/cases
mlugg bbbc95afd0 AstGen: add missing rvalue call to labeledBlockExpr
...and fix a minor x86_64 backend bug exposed by this fix.

Resolves: #21974
2024-11-12 14:51:10 +00:00
..
compile_errors AstGen: add missing rvalue call to labeledBlockExpr 2024-11-12 14:51:10 +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 test: update for CallingConvention changes 2024-10-19 19:15:23 +01:00
address_of_extern_var_as_const.zig test cases: taking address of extern var as constant 2023-06-27 19:08:27 -04: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: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
bad_inferred_variable_type.zig test: update cases to silence 'var is never mutated' errors 2023-11-19 09:56:51 +00:00
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 test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
comptime_aggregate_print.zig compiler: rework comptime pointer representation and access 2024-04-17 13:41:25 +01:00
decl_value_arena.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
exit.zig disable plan9 test 2024-09-26 21:02:14 -07:00
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_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
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
large_add_function.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
maximum_sized_integer_literal.zig test cases: maximum sized integer literal 2023-06-27 19:08:27 -04: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 test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +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
print_u32s.zig fix compilation failures found by CI 2024-03-19 16:18:18 -07:00
README.md tests: translate-c and run-translated-c to the test harness 2023-10-17 11:55:17 +03:00
recursive_fibonacci.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
returning_undefined_sentinel_terminated_const_u8_slice.zig test cases: returning undefined [:0]const u8 2023-06-27 19:57:23 -04: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
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
spirv_mergable_pointers.zig spirv: forbid merging logical pointers 2024-10-27 16:31:45 +01:00
tail_call_noreturn.zig test cases: fix typo in filename 2023-06-27 19:57:23 -04:00
taking_pointer_of_global_tagged_union.zig test cases: taking pointer of global tagged union 2023-06-27 19:57:23 -04: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
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_vars.zig compiler: implement destructuring syntax 2023-09-15 11:33:53 -07: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.