{"id":15015372,"url":"https://github.com/kfly8/syntax-keyword-assert","last_synced_at":"2026-02-12T05:04:30.444Z","repository":{"id":252709488,"uuid":"841062656","full_name":"kfly8/Syntax-Keyword-Assert","owner":"kfly8","description":"assert keyword for Perl with zero runtime cost in production","archived":false,"fork":false,"pushed_at":"2024-12-22T01:10:17.000Z","size":72,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T00:18:13.951Z","etag":null,"topics":["assert","perl"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kfly8.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-11T14:30:00.000Z","updated_at":"2024-12-18T09:01:33.000Z","dependencies_parsed_at":"2024-08-24T14:31:11.393Z","dependency_job_id":"9cbc505a-c348-45b3-9b93-611e944bd993","html_url":"https://github.com/kfly8/Syntax-Keyword-Assert","commit_stats":null,"previous_names":["kfly8/syntax-keyword-assert"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/kfly8/Syntax-Keyword-Assert","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2FSyntax-Keyword-Assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2FSyntax-Keyword-Assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2FSyntax-Keyword-Assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2FSyntax-Keyword-Assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kfly8","download_url":"https://codeload.github.com/kfly8/Syntax-Keyword-Assert/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfly8%2FSyntax-Keyword-Assert/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272732279,"owners_count":24984127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","perl"],"created_at":"2024-09-24T19:47:08.692Z","updated_at":"2026-02-12T05:04:30.439Z","avatar_url":"https://github.com/kfly8.png","language":"Perl","readme":"[![Actions Status](https://github.com/kfly8/Syntax-Keyword-Assert/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/kfly8/Syntax-Keyword-Assert/actions?workflow=test) [![Coverage Status](https://img.shields.io/coveralls/kfly8/Syntax-Keyword-Assert/main.svg?style=flat)](https://coveralls.io/r/kfly8/Syntax-Keyword-Assert?branch=main) [![MetaCPAN Release](https://badge.fury.io/pl/Syntax-Keyword-Assert.svg)](https://metacpan.org/release/Syntax-Keyword-Assert)\n# NAME\n\nSyntax::Keyword::Assert - assert keyword for Perl with zero runtime cost\n\n# SYNOPSIS\n\n```perl\nuse Syntax::Keyword::Assert;\n\nmy $obj = bless {}, \"Foo\";\nassert($obj isa \"Bar\");\n# =\u003e Assertion failed (Foo=HASH(0x11e022818) isa \"Bar\")\n\nassert($x \u003e 0, \"x must be positive\");\n# =\u003e x must be positive\n```\n\n# DESCRIPTION\n\nSyntax::Keyword::Assert provides a syntax extension for Perl that introduces a `assert` keyword.\n\nBy default assertions are enabled, but can be disabled by setting `$ENV{PERL_ASSERT_ENABLED}` to false before this module is loaded:\n\n```\nBEGIN { $ENV{PERL_ASSERT_ENABLED} = 0 }  # Disable assertions\n```\n\nWhen assertions are disabled, the `assert` are completely ignored at compile phase, resulting in zero runtime cost. This makes Syntax::Keyword::Assert ideal for use in production environments, as it does not introduce any performance penalties when assertions are not needed.\n\n# KEYWORDS\n\n## assert\n\n```\nassert(EXPR)\nassert(EXPR, MESSAGE)\n```\n\nIf EXPR is truthy in scalar context, then happens nothing. Otherwise, it dies with a user-friendly error message.\n\nHere are some examples:\n\n```perl\nassert(\"apple\" eq \"banana\");  # =\u003e Assertion failed (\"apple\" eq \"banana\")\nassert(123 != 123);           # =\u003e Assertion failed (123 != 123)\nassert(1 \u003e 10);               # =\u003e Assertion failed (1 \u003e 10)\n```\n\nYou can provide a custom error message as the second argument:\n\n```perl\nassert($x \u003e 0, \"x must be positive\");\n# =\u003e x must be positive\n```\n\nThe message expression is lazily evaluated. It is only evaluated when the assertion fails.\nThis is equivalent to:\n\n```\n$cond || do { die $msg }\n```\n\nThis means you can use expensive computations or side effects in the message without worrying about performance when the assertion passes:\n\n```\nassert($x \u003e 0, expensive_debug_info());\n# expensive_debug_info() is NOT called if $x \u003e 0\n```\n\n# SEE ALSO\n\n- [PerlX::Assert](https://metacpan.org/pod/PerlX%3A%3AAssert)\n\n    This module also uses keyword plugin, but it depends on [Keyword::Simple](https://metacpan.org/pod/Keyword%3A%3ASimple). And this module's error message does not include the failed expression.\n\n- [Devel::Assert](https://metacpan.org/pod/Devel%3A%3AAssert)\n\n    This module provides a similar functionality, but it does not use a keyword plugin.\n\n# LICENSE\n\nCopyright (C) kobaken.\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# AUTHOR\n\nkobaken \u003ckentafly88@gmail.com\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfly8%2Fsyntax-keyword-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfly8%2Fsyntax-keyword-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfly8%2Fsyntax-keyword-assert/lists"}