{"id":21894327,"url":"https://github.com/thacuber2a03/toast","last_synced_at":"2026-03-19T21:20:19.123Z","repository":{"id":245355413,"uuid":"818011900","full_name":"thacuber2a03/toast","owner":"thacuber2a03","description":"A small testing framework written in Umka","archived":false,"fork":false,"pushed_at":"2024-09-22T02:20:16.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-03T04:31:50.826Z","etag":null,"topics":["testing","testing-framework","umka-lang"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thacuber2a03.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-06-20T23:09:58.000Z","updated_at":"2024-09-22T02:18:49.000Z","dependencies_parsed_at":"2024-06-21T18:24:21.804Z","dependency_job_id":"aceeea11-8ae0-4ea4-929d-7ab0bebcfcac","html_url":"https://github.com/thacuber2a03/toast","commit_stats":null,"previous_names":["thacuber2a03/tests.um"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thacuber2a03%2Ftoast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thacuber2a03%2Ftoast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thacuber2a03%2Ftoast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thacuber2a03%2Ftoast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thacuber2a03","download_url":"https://codeload.github.com/thacuber2a03/toast/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902928,"owners_count":20529115,"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","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":["testing","testing-framework","umka-lang"],"created_at":"2024-11-28T13:22:00.798Z","updated_at":"2026-01-04T09:04:58.842Z","avatar_url":"https://github.com/thacuber2a03.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# toast\n\nA small testing framework with no dependencies written in\nthe [Umka](https://github.com/vtereshkov/umka-lang) programming language.\n\n- Pretty simple; roughly less than 300 sloc (without comments), easy to read and modify/extend\n- Carries timing information and keeps track of test results\n- Can print testing information in a slick and straightforward format, or a verbose but in-depth one\n\u003c!-- might erase this line --\u003e\n\n## Installation\n\n### Manually\n\nDownload the \"toast.um\" file and place it somewhere in your project.\nThen, import it in your test file.\n\n### Through [UmBox](https://umbox.tophat2d.dev)\n\n\u003e [!WARNING]\n\u003e This will install the `master` branch version of the box, which might not be stable.\n\nRun `umbox install toast`.\nYou can also run `umbox init -p toast` to make a new box with Umka and toast preinstalled.\n\n## Usage\n\n### Creating a new test suite\n\nThe simplest (and currently, only) way to create a test suite is to make a new `Context`,\nregister one or more tests to it and then run it:\n\n```go\nfn main() {\n    T := toast::newContext()\n    T.registerTests({\n        { name: \"test 1\", func: test1 },\n        { name: \"test 2\", func: test2 }\n    })\n    T.registerTest(\"test 3\", test3)\n    T.run()\n}\n```\n\nEach test in the map passed to `registerTests` must have this signature:\n```go\ntype TestFn* = fn (T: ^Context)\n```\n\n### Test functions\n\nA sample test function goes like this:\n\n```go\nimport \"std.um\"\n\nfn sampleTest(T: ^toast::Context) {\n    recipes := getRecipes()\n\n    res := T.assert.isTrue(\n        validkey(recipes, \"specialDish\"),\n        \"the path to the special dish isn't listed\"\n    )\n\n    if !res { return }\n\n    f, e := std::fopen(recipes[\"specialDish\"], \"rb\")\n    if !T.assert.isOk(e) { return }\n\n    // ... do stuff with file ...\n\n    std::fclose(f)\n}\n```\n\nYou set up any needed modules and variables, and then call\none of the methods in the `.assert` struct to check for any conditions.\nAs of now, the result must be checked for a `false` value and the test returned from manually.\n\n### Custom assertions\n\nYou can also make custom assertion functions by, either mixing and matching assertions,\nor encoding your own logic with the help of the `fail` and `pass` functions.\n\nFor example, here's how `assert.sameType` would be written if it was a custom assertion function:\n\n```go\nfn assertSameType(T: ^toast::Context, a, b: any): bool {\n    T.startCustom()\n\n    if !selftypeeq(a, b) {\n        return T.endCustom(T.fail(\"expected a and b to have the same type\"))\n    }\n\n    return T.endCustom(true)\n}\n```\n\nIt can then be used as any other test function:\n\n```go\n// ...\n\n// this will pass\nif !assertSameType(T, 1, 2) { return }\n// this will fail\nif !assertSameType(T, 1, \"aeiou\") { return }\n\n// ...\n```\n\nHere's also a (rather pointless) equal values assertion implemented\nwith the `assert.isTrue` call (for any two comparable types `T` and `U`):\n\n```go\nfn assertEqual(T: ^toast::Context, a: T, b: U): bool {\n    T.startCustom()\n    return T.endCustom(T.assert.isTrue(\n        a == b, \"expected a and b to be equal\"\n    ))\n}\n```\n\n## Licensing\n\nThis library is released under the [BSD 2-Clause](./LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthacuber2a03%2Ftoast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthacuber2a03%2Ftoast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthacuber2a03%2Ftoast/lists"}