Make use of practice exercise scenarios
还没有人认领这个 Issue。
评估
调研方向
首先检查 canonical-data.json 中列出的场景条目,以及使用这些条目的 PHP 练习测试生成器或学生存根。确定哪些场景从不实现、始终实现或可选实现,然后验证可选场景可以由提议的常量控制,并且所需的测试仍会按预期运行。
由索引模型根据 Issue 内容生成。
描述
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
{
[...]
}
- 主要语言
- PHP
- 星标
- 167
- 派生
- 150
- 平均合并
- 1 天 18 小时
- 30 天内合并 PR
- 7
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
exercism/php 的其他 Issue
-
难度 5/5 一周以上 新手友好度 20/100
-
难度 5/5 一周以上 新手友好度 25/100
-
Discussion: Test generator design可能重新可做 @mk-mxp 于 372 天前认领,目前没有进行中的 PR。 未关闭
-
难度 5/5 一周以上 新手友好度 20/100
-
Tracking: Test generator MVP可能重新可做 @mk-mxp 于 962 天前认领,目前没有进行中的 PR。 未关闭
相似的 Issue
-
Translation TwigBridge
难度 2/5 1-3 小时 新手友好度 68/100
symfony/symfony-docs#23308 ·
维护者通常 3 天内回复
-
sync-en
难度 1/5 1 小时以内 新手友好度 84/100
维护者通常 1 天内回复
-
sync-en
难度 1/5 1 小时以内 新手友好度 84/100
维护者通常 4 天内回复
-
难度 1/5 1 小时以内 新手友好度 84/100
WordPress/hosting-handbook#506 ·
维护者通常 2 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 79/100
mirai-mamori/Sakurairo#1435 · 1 条评论 ·