codewars / docs

The Codewars Docs :construction: WIP
https://docs.codewars.com
MIT License
56 stars 201 forks source link

Suggestion: documenting the (actual, expected) order for all languages #390

Open interrupt-routine opened 2 years ago

interrupt-routine commented 2 years ago

This applies to all languages for which the test framework boils down to functions in the form : assert_equal(actual, expected).

For some languages (e.g. Python, JS, C ...) the order is (actual, expected), for some others (Java, C# ...) the order is (expected, actual). This results in a lot of mistakes; issues complaining that "actual and expected are flipped" are widespread. It is hard to remember the order for the dozens of languages that codewars support, especially when trying to fix issues in a language with which one is not familiar. My suggestion is to add a page in the codewars docs that would contain a table listing the parameters' order for each language to which it applies, so that it can be checked quickly.

For example something like this:

Language Parameters order
C (actual, expected)
C# (expected, actual)
JavaScript (actual, expected)
Java (expected, actual)
Python (actual, expected)

Alternatively, this could be added on a per-language basis on each language's doc page.

hobovsky commented 2 years ago

Every language supported by Codewars (https://docs.codewars.com/languages) has its documentation page. The page for every language mentions what testing framework is used, and what assertion library is used. For home-grown frameworks, like Codewars Python Testing Framework, documentation should contain reference of test utilities, assertions, etc. (like here for Python). For external frameworks and libraries, authors are expected to refer to documentation provided by these (C uses Criterion, C# uses NUnit, Java uses JUnit, etc.). Ideally, Codewars docs should contain links to home page of all external libraries provided by runner.

So basically things you are asking for are already (mostly) documented. If something is not, for some language, or some framework, it should be added, but for majority of cases I think it's already there.

Did you find any language or test framework which is not documented, or not linked, clearly enough in Codewars docs?

interrupt-routine commented 2 years ago

Obviously, after a certain amount of research, I will end up finding the documentation snippet I'm looking for. If you want a specific example : the documentation for C# is just a link to nunit.org. After a bunch of additional clicks, I will land on https://docs.nunit.org/articles/nunit/writing-tests/assertions/classic-assertions/Assert.AreEqual.html that will tell me what I want to know. But the reality is, that there are dozens of C# katas with expected and actual flipped, probably because it's the other way around in most languages. I just thought documenting it clearly and concisely somewhere would help alleviate the problem, especially when fixing language versions in which one is not familiar (not everyone can remember the details of 40+ frameworks). Anyway, that was just an idea...

hobovsky commented 2 years ago

Don't get me wrong, I am not saying your idea is bad. What I am saying is that I am not sure that such page would help. Your proposal basically boils down to adding a documentation page for people who did not bother to read docs in the first place.

Additionally, order of expected and actual is not the only thing translators get wrong, and it will be difficult to create a summary of all most important aspects of all testing frameworks on a single page.

The amount of "expected and actual are swapped" has significantly decreased compared to what it used to be several months ago. I'd risk a statement that many (but obviously not all) occurrences of such issue have already been identified, and fixed. When you find any new one, just raise an issue and someone will fix it.