✅ Add unit-level tests for `parseClassicConditionExpression`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 84/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- cpp
- 领域
- testing-qa
调研方向
从 src/common/parsing/CodePreprocessing.cpp 中的 parseClassicConditionExpression 开始,并检查 test/test_custom_code.cpp 中现有的覆盖范围。在 test_parsing.cpp 或新的测试文件中添加一个 fixture,检查针对所列有效、无效和 permissive 情况返回的 std::optional。完成标准是直接针对所有指定输入测试 parser,包括可能因 issue #468 而改变的行为。
由索引模型根据 Issue 内容生成。
描述
🤖 AI text below 🤖
Problem statement
parseClassicConditionExpression (in src/common/parsing/CodePreprocessing.cpp) has no direct unit tests. Every test that exercises it today lives in test/test_custom_code.cpp and runs the full end-to-end pipeline: load QASM code, spin up a DDSimulationState, run the simulation, and inspect amplitudes or classical bits.
Two problems with that coverage:
- A parser bug shows up as a failed amplitude assertion, not as "the parser returned the wrong
ClassicCondition". Localizing the root cause takes longer than it should. - Edge cases of the parser itself (malformed input, whitespace, leading paren, trailing garbage, invalid brackets, empty operand) are not systematically covered because writing a full QASM program to trigger each one is disproportionate.
Surfaced during the review of PR #463 while considering the follow-ups for parseClassicConditionExpression.
Proposed solution
Add a fixture (either in the existing test_parsing.cpp or in a new file) that calls parseClassicConditionExpression directly with a string and checks the returned std::optional<ClassicCondition> against expected values. Cover:
- Valid cases: one test per comparator (
==,!=,<,<=,>,>=), bracketed forms (c[0] == 1), bare register (c), bare bit (c[0]), input with leading(, input with surrounding whitespace. - Invalid cases: empty string, missing operand on either side, non-numeric right-hand side, malformed brackets (open only, close only, index empty, non-digit index, bracket not at the end), out-of-range integer literal.
- Document currently permissive behavior (e.g.
c2]accepted as a register name,@#accepted). These tests can start green against the current behavior and flip to expectstd::nulloptonce #468 lands.
Out of scope
- Unit tests for other parsers in the file (
parseFunctionDefinition,parseClassicControlledGate, etc.). Same idea, separate issue. - Testing
parseBitRegisterRefdirectly. It lives in the anonymous namespace of the.cpp; the tests here cover it indirectly throughparseClassicConditionExpression, which is what the outside world sees.
- 主要语言
- C++
- 星标
- 21
- 派生
- 8
- 平均合并
- 5 小时 17 分钟
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
munich-quantum-toolkit/debugger 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 66/100
munich-quantum-toolkit/debugger#468 ·
维护者通常 1 天内回复
-
✨ Improve CLI UX: line editing, function-key shortcuts, and help bar可能已有人在做 @rturrado 于 32 天前认领。 未关闭
难度 5/5 一周以上 新手友好度 35/100
munich-quantum-toolkit/debugger#467 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
munich-quantum-toolkit/debugger#465 ·
维护者通常 1 天内回复
-
c++ enhancement help wanted
难度 4/5 3-5 天 新手友好度 48/100
munich-quantum-toolkit/debugger#168 ·
维护者通常 1 天内回复
-
dependencies
难度 5/5 一周以上 新手友好度 10/100
munich-quantum-toolkit/debugger#55 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 munich-quantum-toolkit/debugger 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Mac mini M6 (16 GB): Q2_0 streaming works - measured 11.7->27.2 tok/s + arena fix for sub-32 GB Macs未关闭
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
champion good first issue remake source/qq
难度 2/5 1-3 小时 新手友好度 65/100
metasequoiaime/msime-windows#1025 ·
维护者通常 1 天内回复
-
backlog bug
难度 2/5 1-3 小时 新手友好度 75/100
EchoTools/nevr-runtime#653 ·
维护者通常 1 天内回复
-
`--fail-require-skip` never fires: run_tests.py searches stdout, but the unittest binary writes the skip summary to stderr可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复