int main(string[] args) {
    Log.set_handler("GLib-GObject", LogLevelFlags.LEVEL_CRITICAL, (domain, level, message) => {});
    try {
        PhpefRuntimeEmbed.engine_start(args);
        var eol = PhpefRuntimeEmbed.get_constant("PHP_EOL");
        if (eol.to_php_string() != "\n") {
            stderr.printf("PHP_EOL lookup mismatch: %s\n", eol.to_php_string());
            PhpefRuntimeEmbed.engine_stop();
            return 1;
        }
        var version = PhpefRuntimeEmbed.get_constant("PHP_VERSION");
        if (version.to_php_string() == "") {
            stderr.printf("PHP_VERSION lookup returned empty string\n");
            PhpefRuntimeEmbed.engine_stop();
            return 1;
        }
        var categorized = PhpefRuntimeEmbed.phpfunc_get_defined_constants(PhpefRuntimeCore.Zval.from_bool(true));
        if (categorized.kind != PhpefRuntimeCore.ValueKind.ARRAY) {
            stderr.printf("get_defined_constants(true) did not return an array\n");
            PhpefRuntimeEmbed.engine_stop();
            return 1;
        }
        bool found_core = false;
        bool found_standard = false;
        bool found_php_eol = false;
        bool found_directory_separator = false;
        foreach (var category in categorized.as_array_entries()) {
            if (category.key == null || category.value.kind != PhpefRuntimeCore.ValueKind.ARRAY) {
                continue;
            }
            var category_name = category.key.to_php_string();
            if (category_name == "Core") {
                found_core = true;
            }
            if (category_name == "standard") {
                found_standard = true;
            }
            foreach (var constant_entry in category.value.as_array_entries()) {
                if (constant_entry.key == null) {
                    continue;
                }
                var constant_name = constant_entry.key.to_php_string();
                if (category_name == "Core" && constant_name == "PHP_EOL" && constant_entry.value.to_php_string() == "\n") {
                    found_php_eol = true;
                }
                if (category_name == "standard" && constant_name == "DIRECTORY_SEPARATOR" && constant_entry.value.to_php_string() == "/") {
                    found_directory_separator = true;
                }
            }
        }
        if (!found_core || !found_standard || !found_php_eol || !found_directory_separator) {
            stderr.printf("get_defined_constants(true) missing expected Core/standard constants\n");
            PhpefRuntimeEmbed.engine_stop();
            return 1;
        }

        try {
            PhpefRuntimeEmbed.get_constant("PHPEF_RUNTIME_EMBED_UNDEFINED_TEST_CONSTANT");
            stderr.printf("Undefined constant lookup unexpectedly succeeded\n");
            PhpefRuntimeEmbed.engine_stop();
            return 1;
        } catch (Error e) {
            if (!e.message.contains("Undefined constant")) {
                stderr.printf("Unexpected undefined-constant error: %s\n", e.message);
                PhpefRuntimeEmbed.engine_stop();
                return 1;
            }
        }
        PhpefRuntimeEmbed.engine_stop();
        return 0;
    } catch (Error e) {
        stderr.printf("Unexpected RuntimeEmbed constant lookup error: %s\n", e.message);
        PhpefRuntimeEmbed.engine_stop();
        return 1;
    }
}
