{"id":16705126,"url":"https://github.com/oxinabox/interfacetesting.jl","last_synced_at":"2025-06-26T06:36:24.779Z","repository":{"id":51615798,"uuid":"84322630","full_name":"oxinabox/InterfaceTesting.jl","owner":"oxinabox","description":"(Julia 0.5 only) Concept still good, but needs updating for julia 1.0","archived":false,"fork":false,"pushed_at":"2020-02-08T15:37:48.000Z","size":10,"stargazers_count":12,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-10T05:14:01.246Z","etag":null,"topics":["iterators","julia","testing"],"latest_commit_sha":null,"homepage":"","language":"Julia","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/oxinabox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-08T13:22:15.000Z","updated_at":"2022-08-02T13:28:48.000Z","dependencies_parsed_at":"2022-08-22T00:00:26.030Z","dependency_job_id":null,"html_url":"https://github.com/oxinabox/InterfaceTesting.jl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oxinabox/InterfaceTesting.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxinabox%2FInterfaceTesting.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxinabox%2FInterfaceTesting.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxinabox%2FInterfaceTesting.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxinabox%2FInterfaceTesting.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxinabox","download_url":"https://codeload.github.com/oxinabox/InterfaceTesting.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxinabox%2FInterfaceTesting.jl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262016973,"owners_count":23245575,"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":["iterators","julia","testing"],"created_at":"2024-10-12T19:28:48.569Z","updated_at":"2025-06-26T06:36:24.754Z","avatar_url":"https://github.com/oxinabox.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# InterfaceTesting.jl\n[![Build Status](https://travis-ci.org/oxinabox/InterfaceTesting.jl.svg?branch=master)](https://travis-ci.org/oxinabox/InterfaceTesting.jl)\n\n\nJulia has several [\"Informal Interfaces\"](http://docs.julialang.org/en/stable/manual/interfaces/).\nUnlike many mainstream static languages,\ninterfaces are not statically defined.\nNor, can it be directly required that concrete types of an abstract type implement certain methods.\n\nThe Iterator interface is very common.\nIt is also very easy to mess up.\nEg by forgetting to define `iteratorsize`,\nor by defining it on the values, rather than on the types.\n\n\nThis package makes testing it simple.\n\nIf in your src file you have defined an iterator `SomeRandomNumbers`\n\n```julia\nmodule CountingGames\n    export SomeRandomNumbers\n    immutable SomeRandomNumbers end\n    Base.start(::SomeRandomNumbers) = 1\n    Base.done(::SomeRandomNumbers, state) = state\u003e100\n    Base.iteratorsize(::Type{SomeRandomNumbers}) = Base.SizeUnknown()\n    function Base.next(::SomeRandomNumbers, state)\n        ret = rand(1:10)\n        ret, state+ret\n    end\nend\n```\n\nthen you can check it meets all the requirements by writing a tests:\n\n```julia\nusing Base.Test\nusing CountingGames\nusing InterfaceTesting\n\ntest_iterator_interface(SomeRandomNumbers)\n```\n\nThis will run a `@testset` to check everything is defined correctly:\n\n```\nTest Summary:                   | Pass  Total\n  CountingGames.SomeRandomNumbers |    5      5\n```\n#### On testing parametric types\nIf your type takes a parameter, eg `Foo{T}`, you are better to run the tests with that parameter filled in.\nEg `test_iterator_interface(Foo{Int})` rather than `test_iterator_interface(Foo)`.\nBecause of how dispatch to parametric types works.\n`Foo{T} != Foo` but `Foo{T} \u003c: Foo`.\nThis means that if you have defined `iteratorsize{T}{::Type{Foo{T}})`\ngenerally the `test_iterator_interface(Foo)` will fail as that definion does not apply to `Foo`.\nIt is complicated like that.\nBut the take away should be to fill in your type parameters when using these tests.\n\n### Supported Interfaces\n\nThe focus of this package is the testing of the Iterator interface, with its several traits and complexities.\nit does support several others, though these have not had as much testing or thought put in.\n\n -  [Iterator interface](http://docs.julialang.org/en/stable/manual/interfaces/#iteration). method: `test_iterator_interface`\n -  [Indexing interface](http://docs.julialang.org/en/stable/manual/interfaces/#indexing). method: `test_index_interface`\n -  [AbstractArray interface](http://docs.julialang.org/en/stable/manual/interfaces/#abstract-arrays). method: `test_abstractarray_interface`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxinabox%2Finterfacetesting.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxinabox%2Finterfacetesting.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxinabox%2Finterfacetesting.jl/lists"}