Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

✅ Add unit-level tests for `parseClassicConditionExpression`

Aperta
#469 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
84/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
testing-qa

Direzione di ricerca

Inizia da parseClassicConditionExpression in src/common/parsing/CodePreprocessing.cpp e rivedi la copertura esistente in test/test_custom_code.cpp. Aggiungi un fixture in test_parsing.cpp o in un nuovo file di test che verifichi lo std::optional restituito per i casi validi, non validi e permissivi elencati. Il lavoro è completato quando il parser viene testato direttamente con tutti gli input specificati, incluso il comportamento che potrebbe cambiare con issue #468.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🤖 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 expect std::nullopt once #468 lands.
Out of scope
  • Unit tests for other parsers in the file (parseFunctionDefinition, parseClassicControlledGate, etc.). Same idea, separate issue.
  • Testing parseBitRegisterRef directly. It lives in the anonymous namespace of the .cpp; the tests here cover it indirectly through parseClassicConditionExpression, which is what the outside world sees.
Lingua principale
C++
Stelle
21
Fork
8
Merge medio
5h 17m
PR unite (30g)
21

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di munich-quantum-toolkit/debugger

Tutte le issue di munich-quantum-toolkit/debugger

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.