zig/test/cases
mlugg 38b83d9d93 Zir: eliminate field_call_bind and field_call_bind_named
This commit removes the `field_call_bind` and `field_call_bind_named` ZIR
instructions, replacing them with a `field_call` instruction which does the bind
and call in one.

`field_call_bind` is an unfortunate instruction. It's tied into one very
specific usage pattern - its result can only be used as a callee. This means
that it creates a value of a "pseudo-type" of sorts, `bound_fn` - this type used
to exist in Zig, but now we just hide it from the user and have AstGen ensure
it's only used in one way. This is quite silly - `Type` and `Value` should, as
much as possible, reflect real Zig types and values.

It makes sense to instead encode the `a.b()` syntax as its own ZIR instruction,
so that's what we do here. This commit introduces a new instruction,
`field_call`. It's like `call`, but rather than a callee ref, it contains a ref
to the object pointer (`&a` in `a.b()`) and the string field name (`b`). This
eliminates `bound_fn` from the language, and slightly decreases the size of
generated ZIR - stats below.

This commit does remove a few usages which used to be allowed:
- `@field(a, "b")()`
- `@call(.auto, a.b, .{})`
- `@call(.auto, @field(a, "b"), .{})`

These forms used to work just like `a.b()`, but are no longer allowed. I believe
this is the correct choice for a few reasons:
- `a.b()` is a purely *syntactic* form; for instance, `(a.b)()` is not valid.
  This means it is *not* inconsistent to not allow it in these cases; the
  special case here isn't "a field access as a callee", but rather this exact
  syntactic form.
- The second argument to `@call` looks much more visually distinct from the
  callee in standard call syntax. To me, this makes it seem strange for that
  argument to not work like a normal expression in this context.
- A more practical argument: it's confusing! `@field` and `@call` are used in
  very different contexts to standard function calls: the former normally hints
  at some comptime machinery, and the latter that you want more precise control
  over parts of a function call. In these contexts, you don't want implicit
  arguments adding extra confusion: you want to be very explicit about what
  you're doing.

Lastly, some stats. I mentioned before that this change slightly reduces the
size of ZIR - this is due to two instructions (`field_call_bind` then `call`)
being replaced with one (`field_call`). Here are some numbers:

+--------------+----------+----------+--------+
| File         | Before   | After    | Change |
+--------------+----------+----------+--------+
| Sema.zig     | 4.72M    | 4.53M    | -4%    |
| AstGen.zig   | 1.52M    | 1.48M    | -3%    |
| hash_map.zig | 283.9K   | 276.2K   | -3%    |
| math.zig     | 312.6K   | 305.3K   | -2%    |
+--------------+----------+----------+--------+
2023-05-20 12:27:48 -07:00
..
compile_errors Zir: eliminate field_call_bind and field_call_bind_named 2023-05-20 12:27:48 -07:00
llvm test-cases: fix incorrectly linking libc when backend is llvm 2023-03-15 10:48:15 -07:00
safety update test cases for new memcpy/memset semantics 2023-04-25 11:23:41 -07:00
x86_64-linux Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
adding_numbers_at_runtime_and_comptime.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
adding_numbers_at_runtime_and_comptime.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
adding_numbers_at_runtime_and_comptime.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
ambiguous_reference.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
arithmetic_operations.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
arithmetic_operations.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
arithmetic_operations.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
arithmetic_operations.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
arithmetic_operations.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
arithmetic_operations.5.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
arithmetic_operations.6.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.5.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.6.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.7.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.8.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.9.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.10.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.11.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.12.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.13.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.14.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.15.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.16.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.17.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
assert_function.18.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
bad_inferred_variable_type.zig adjust tests that didn't pass CI 2022-06-30 21:47:26 +03:00
binary_operands.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.2.zig stage2: Split @mulWithOverflow tests 2022-05-07 20:02:02 +02:00
binary_operands.3.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.4.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.5.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.6.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.7.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.8.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.9.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.10.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.11.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.12.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.13.zig stage2: Split @mulWithOverflow tests 2022-05-07 20:02:02 +02:00
binary_operands.14.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.15.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.16.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.17.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.18.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.19.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.20.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.21.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.22.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.23.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.24.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
binary_operands.25.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
break_continue.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
break_continue.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
break_continue.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
break_continue.3.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
catch_at_comptime.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
catch_at_comptime.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
catch_at_comptime.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
catch_at_comptime.3.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
catch_at_comptime.4.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
comparison_of_non-tagged_union_and_enum_literal.zig Sema: improve @call errors 2022-06-30 09:57:38 +02:00
compile_error.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
compile_log.0.zig test-cases: add missing compile log output 2023-03-15 10:48:15 -07:00
compile_log.1.zig test-cases: add missing compile log output 2023-03-15 10:48:15 -07:00
comptime_aggregate_print.zig add support for .field_ptr in elemValueAdvanced 2023-04-26 17:31:42 +03:00
comptime_var.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
comptime_var.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
comptime_var.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
comptime_var.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
comptime_var.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
comptime_var.5.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
comptime_var.6.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditional_branches.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditional_branches.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditions.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditions.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditions.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditions.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditions.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
conditions.5.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
decl_value_arena.zig sema: Rework Decl.value_arena to fix another memory corruption issue 2023-04-27 01:11:57 -04:00
double_ampersand.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
double_ampersand.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
double_ampersand.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
enum_values.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
enum_values.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
error_in_nested_declaration.zig stage2: correct node offset of nested declarations 2022-08-09 11:59:10 +03:00
error_unions.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
error_unions.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
error_unions.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
error_unions.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
error_unions.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
error_unions.5.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
errors.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
errors.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
errors.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
errors.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
exit.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
extern_variable_has_no_type.0.zig Sema: allow runtime only instructions to be emitted in outside functions 2022-10-20 20:11:00 +03:00
extern_variable_has_no_type.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
f32_passed_to_variadic_fn.zig test-cases: fix incorrectly linking libc when backend is llvm 2023-03-15 10:48:15 -07:00
fn_typeinfo_passed_to_comptime_fn.zig test-cases: fix incorrectly linking libc when backend is llvm 2023-03-15 10:48:15 -07:00
function_calls.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
function_calls.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
function_calls.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
function_calls.3.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
function_pointers.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
function_redeclaration.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
global_variable_redeclaration.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
hello_world_with_updates.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
hello_world_with_updates.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
hello_world_with_updates.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
hello_world_with_updates.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
hello_world_with_updates.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
hello_world_with_updates.5.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
hello_world_with_updates.6.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
inner_func_accessing_outer_var.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
int_to_ptr.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
int_to_ptr.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
large_add_function.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
locals.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
locals.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
lower_unnamed_consts_structs.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
lower_unnamed_consts_structs.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
lower_unnamed_consts_structs.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
merge_error_sets.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
merge_error_sets.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
multiplying_numbers_at_runtime_and_comptime.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
multiplying_numbers_at_runtime_and_comptime.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
multiplying_numbers_at_runtime_and_comptime.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
non_leaf_functions.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
only_1_function_and_it_gets_updated.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
only_1_function_and_it_gets_updated.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
optional_payload.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
optional_payload.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
optional_payload.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
optional_payload.3.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
optionals.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
optionals.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
optionals.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
optionals.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
optionals.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
orelse_at_comptime.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
orelse_at_comptime.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
parameters_and_return_values.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
parameters_and_return_values.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
passing_u0_to_function.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
pointers.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
pointers.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
print_u32s.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
README.md migrate runtime safety tests to the new test harness 2022-05-13 14:03:20 -07:00
recursive_fibonacci.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
redundant_comptime.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
redundant_comptime.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +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: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
runtime_bitwise_or.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02: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
spilling_registers.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
spilling_registers.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
structs.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
structs.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
structs.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
structs.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
structs.4.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
switch.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
switch.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
switch.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
switch.3.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
taill_call_noreturn.zig update usages of @call 2022-12-13 13:14:20 +02:00
try_in_comptime_in_struct_in_test.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
type_of.0.zig remove pointless discards in test cases 2022-09-13 02:04:20 -07:00
type_of.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
type_of.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
unused_labels.0.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
unused_labels.1.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
unused_labels.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
unused_labels.3.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
unused_vars.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
variable_shadowing.0.zig disable spuriously failing test on Windows 2022-09-14 16:12:55 -07:00
variable_shadowing.1.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.2.zig test: move compile errors and incremental tests into common dir 2022-05-04 23:51:16 +02:00
variable_shadowing.3.zig update test-cases for new for loop syntax 2023-02-18 19:17:21 -07:00
variable_shadowing.4.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.5.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.6.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.7.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.8.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.9.zig AstGen: use 'shadows' instead of 'redeclaration' when names are in different scopes 2022-10-07 11:04:02 +03:00
variable_shadowing.10.zig AstGen: fix catch payoad not checking for shadowing 2022-07-07 21:38:32 +03:00
while_loops.0.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
while_loops.1.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01:00
while_loops.2.zig Unify incremental test cases and disable many 2023-04-20 20:49:36 +01: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=1
//
// :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=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.