alef 0.115.3

Opinionated polyglot binding generator for Rust libraries
Documentation
{# ~keep PHPUnit assertion failures can be Exceptions, so evaluate assertions after the application catch. #}
{% if pattern or field_checks %}
        $caughtException = null;
        try {
{% for line in setup_lines %}
            {{ line }}
{% endfor %}
{% if collect_snippet %}
            ${{ result_var }} = {{ call_expr }};
            {{ collect_snippet }}
{% else %}
            {{ call_expr }};
{% endif %}
        } catch (\Exception $e) {
            $caughtException = $e;
        }
        $this->assertInstanceOf(\Exception::class, $caughtException);
{% if skip_marker %}
{{ skip_marker }}
{% endif %}
{% if pattern %}
        $this->assertTrue(preg_match({{ pattern }}, $caughtException->getMessage()) === 1 || preg_match({{ pattern }}, get_class($caughtException)) === 1, 'expected exception message or class name to match {{ message_value }}');
{% endif %}
{% if field_checks %}
{{ field_checks }}
{% endif %}
{% else %}
{% if skip_marker %}
{{ skip_marker }}
{% endif %}
        $this->expectException(\Exception::class);
{% for line in setup_lines %}
        {{ line }}
{% endfor %}
{% if collect_snippet %}
        ${{ result_var }} = {{ call_expr }};
        {{ collect_snippet }}
{% else %}
        {{ call_expr }};
{% endif %}
{% endif %}