{"id":20345185,"url":"https://github.com/tshm/elm-doctest","last_synced_at":"2025-04-12T00:40:35.194Z","repository":{"id":8372130,"uuid":"58150422","full_name":"tshm/elm-doctest","owner":"tshm","description":"doctest runner against Elm-lang source files","archived":false,"fork":false,"pushed_at":"2024-03-02T11:24:41.000Z","size":413,"stargazers_count":16,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T16:50:08.843Z","etag":null,"topics":["doctest","elm","test-runner","unittest"],"latest_commit_sha":null,"homepage":null,"language":"Elm","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tshm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-05T17:59:52.000Z","updated_at":"2025-04-09T10:11:04.000Z","dependencies_parsed_at":"2022-08-29T00:11:24.303Z","dependency_job_id":null,"html_url":"https://github.com/tshm/elm-doctest","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tshm%2Felm-doctest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tshm%2Felm-doctest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tshm%2Felm-doctest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tshm%2Felm-doctest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tshm","download_url":"https://codeload.github.com/tshm/elm-doctest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501960,"owners_count":21114681,"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":["doctest","elm","test-runner","unittest"],"created_at":"2024-11-14T22:07:03.891Z","updated_at":"2025-04-12T00:40:35.165Z","avatar_url":"https://github.com/tshm.png","language":"Elm","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/tshm/elm-doctest/actions/workflows/node.js.yml/badge.svg)](https://github.com/tshm/elm-doctest/actions/workflows/node.js.yml)\n[![npm version](https://badge.fury.io/js/elm-doctest.svg)](https://badge.fury.io/js/elm-doctest)\n\n# elm-doctest\n\n[doctest](https://en.wikipedia.org/wiki/Docstring)\nrunner against Elm-lang source files\n\n## installation\n\n```shell\nnpm install elm-doctest\n```\n\nIt depends on `elm` and assumes that `elm-make` and `elm-repl` are available\neither via systemwide installation or npm module installation.\nMake sure `elm-make` succeeds with your elm source files.\n\n## how does it work?\n\nIt utilizes `elm-repl` for expression evaluation and compare the values\nagainst the expected value.\n(It does not comapre stringified values like haskell doctest does via\nGHCi outputs.)\n\nIt only evaluates the expressions that follows `-- \u003e\u003e\u003e`\n(i.e. Elm comment symbol followed by space and three LT chars\nuntil end of the line)\nand the expression on the next line after `-- `.\n\nFor example, if the comment states:\n\n```Elm\n-- \u003e\u003e\u003e x =\n-- \u003e\u003e\u003e   1 + 2\n--\n-- \u003e\u003e\u003e x * 2\n-- 6\n```\n\nThen, elm-doctest asks elm-repl to evaluate the\nactual code section in the source file and\neffectively following expression:\n\n```Elm\n((1 + 2) * 2) == (6)\n```\n\nIf value reported by `elm-repl` is `True` then test passes, fail otherwise.\n\n## usage\n\n```\nUsage: elm-doctest [--watch] [--help] [--elm-path PATH]\n                   [--pretest CMD] FILES...\n  run doctest against given Elm files\n\nAvailable options:\n  -h,--help             Show this help text\n  --pretest CMD         Command to run before doc-test\n  --elm-path PATH       Path to elm executable\n  -w,--watch            Watch and run tests when target files get updated\n```\n\n## example\n\nModuleTobeTested.elm:\n\n```Elm\nmodule ModuleTobeTested exposing(..)\n\n-- |\n-- \u003e\u003e\u003e add 3 5\n-- 8\n--\n-- \u003e\u003e\u003e removeZeros [0, 1, 2, 3, 0]\n-- [1, 2, 3]\n--\n-- \u003e\u003e\u003e greetingTo \"World\"\n-- \"Konnichiwa World\"\n--\nadd : Int -\u003e Int -\u003e Int\nadd x y = x + y\n\ngreetingTo : String -\u003e String\ngreetingTo x = \"Hello \" ++ x\n\nremoveZeros : List Int -\u003e List Int\nremoveZeros = List.filter (\\x -\u003e x /= 0)\n```\n\nevaluation `elm-doctest ModuleTobeTested.elm` outputs\n\n```\nStarting elm-doctest ...\n\n processing: test/TestData/TestFail.elm\n### Failure in test/TestData/TestFail.elm:10: expression\n  greetingTo \"World\"\nexpected: \"Konnichiwa World\"\n but got: \"Hello World\"\nExamples: 3  Failures: 1\n```\n\n## limitation\n\nAs it utilizes `elm-repl`, the script must be runnable\ninside `elm-repl`.\nFor example, code which imports `elm-lang/navigation@1.0.0`\nmodule cannot be tested.\nSince the stdout is used to evaluate the test result,\navoid using `Debug.log`.\n\nAlso, make sure elm-make runs without error.\nYou can auto run elm-make by using `--pretest` command-line\noption.\n\n## license\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftshm%2Felm-doctest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftshm%2Felm-doctest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftshm%2Felm-doctest/lists"}