Make use of practice exercise scenarios
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reviewing the listed canonical-data.json scenario entries and the PHP exercise test generators or student stubs that consume them. Define which scenarios are never, always, or optionally implemented, then verify that optional scenarios can be controlled by the proposed constants and that required tests still run as intended.
Written by the indexing model from the issue text.
Description
Problem
Some practice exercises have scenarios "to allow for selectively including/excluding test cases based on a property of the test case". We currently have not defined how these are treated within the PHP track.
At the time of writing, these are the scenarios in use within exercises:
~/.cache/exercism/configlet/problem-specifications$ fgrep -H -e 'scenario' -r --include='*.json' exercises/
exercises/bank-account/canonical-data.json: "scenarios": ["concurrent"],
exercises/dnd-character/canonical-data.json: "scenarios": ["random"],
exercises/high-scores/canonical-data.json: "scenarios": ["immutable"],
exercises/protein-translation/canonical-data.json: "scenarios": ["input-validation", "runtime-validation"],
exercises/parallel-letter-frequency/canonical-data.json: "scenarios": ["unicode"],
exercises/parallel-letter-frequency/canonical-data.json: "scenarios": ["concurrent"],
exercises/reverse-string/canonical-data.json: "scenarios": ["unicode"],
exercises/gigasecond/canonical-data.json: "scenarios": ["date"],
exercises/gigasecond/canonical-data.json: "scenarios": ["datetime"],
exercises/gigasecond/canonical-data.json: "scenarios": ["immutable"],
exercises/diffie-hellman/canonical-data.json: "scenarios": ["random"],
exercises/diffie-hellman/canonical-data.json: "scenarios": ["immutable"],
exercises/forth/canonical-data.json: "scenarios": ["local-scope"],
exercises/armstrong-numbers/canonical-data.json: "scenarios": ["big-integer"],
exercises/simple-cipher/canonical-data.json: "scenarios": ["random"],
exercises/triangle/canonical-data.json: "scenarios": ["floating-point"],
exercises/anagram/canonical-data.json: "scenarios": ["unicode"],
Suggestion
Scenarios can be grouped into categories based on how we want to treat them:
- Never implemented: We do not implement those test cases at all.
- Always implemented: We always include those test cases as required tests.
- Optionally implemented: Students should be able to opt-in to implement their solution so they pass those test cases in addition to the required tests.
We decide, which scenarios we want to treat as "optional", "always" or "never". I think, this a way to use the categories:
- Never implemented:
concurrent,library-test, any unknown scenario - Always implemented:
date,datetime,floating-point,local-scope - Optionally implemented:
big-integer,immutable,input-validation,random,runtime-validation,unicode
Based on these categories, test generators can simply skip over "never" scenarios and treat "always" scenarios like "no scenario".
For the "optional" ones I suggest using PHP constants in students files (define('BIG_INTEGER', 1);) and inside the test methods if (!defined('BIG_INTEGER') || constant('BIG_INTEGER' !== 1)) { $this->markTestSkipped(); }. Using the functions to create / read the constants avoids the problems that arise, when including the students file into a class method (as we do in the test class).
The constants provide a means to easily pre-define them in the students stub file:
[...]
// Change this constant value to 1 if you want to test your solution using Unicode strings:
define('UNICODE', 0);
class ExerciseName
{
[...]
}
- Dominant language
- PHP
- Stars
- 167
- Forks
- 151
- Avg merge
- 5h 50m
- Merged PRs (30d)
- 3
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from exercism/php
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Discussion: Test generator designMay be free again @mk-mxp claimed this 394 days ago, and no pull request is open. Open
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Similar issues
-
Issue: ready for confirmation Reported on 2.4.9 Triage: Dev.Experience
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
magento/magento2#41773 · 1 comment ·
Maintainers usually reply within 5 days
-
[BUG] Add bounds validation for numberOfContestants in TeamsGroup::apiCreate()Possibly taken @RAJJADHAV10 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
omegaup/omegaup#10512 · 1 comment ·
Maintainers usually reply within 5 days
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sorocharge/sorocharge-php#14 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
filesender/filesender#2898 ·
Maintainers usually reply within 1 day
-
cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day