Skip to content

Add tests for the Stim compiler#3376

Open
orpuente-MS wants to merge 55 commits into
mainfrom
oscarpuente/stim-compiler-tests
Open

Add tests for the Stim compiler#3376
orpuente-MS wants to merge 55 commits into
mainfrom
oscarpuente/stim-compiler-tests

Conversation

@orpuente-MS

@orpuente-MS orpuente-MS commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Categories of tests covered by this PR:

Lexer

  • Int and Float Numeric literals generate the right Tokens
  • leading newlines at beginning of file work fine
  • trailing newlines at end of file work fine
  • newlines in between instructions work fine
  • Comments work fine
  • Instruction name is lexed correctly
  • Single char token is lexed correctly
  • Rec / Sweep / Tag are lexed correctly
  • Unrecognized characters error works

Parser

  • Instruction arguments parse correctly
  • Instruction tags parse correctly
  • Instruction targets parse correctly
  • Instruction shapes parse correctly (with / without args, tags, targets)
  • Blocs parse correctly
  • Newlines parse correctly, comments don't interfere with parser
  • Numbers are parsed correctly (both uint and doubles)
  • General errors are generated correctly
  • Span is correct
  • Edge cases

QIR Codegen

Gates

  • single-qubit gates generate correct QIR
  • single-qubit gates with broadcasting generate correct QIR
  • two-qubit gates generate correct QIR
  • two-qubit gates with broadcasting generate correct QIR
  • two-qubit gates with odd number of targets yield error messages
  • unsupported gates yield error messages

Noise Channels

  • Noise channels get compiled to the right NoiseConfig object
  • single-qubit error channels generate correct QIR
  • single-qubit error channels with broadcasting generate correct QIR
  • two-qubit error channels generate correct QIR
  • two-qubit error channels with broadcasting generate correct QIR
  • two-qubit error channels with odd number of targets yield error messages
  • I_ERROR and II_ERROR work without paren arguments
  • the rest of error channels without paren arguments yield error messages

Preselect

  • preselect_expect with a previous preselect_begin generates correct QIR
  • multiple preselect_expect generate correct QIR
  • preselect_expect without a previous preselect_begin yields an error message

orpuente-MS and others added 30 commits June 23, 2026 09:53
@orpuente-MS orpuente-MS marked this pull request as ready for review June 26, 2026 21:14
Comment thread source/compiler/stim_compiler/src/qir.rs Dismissed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants