Skip to content

Comments

Add comprehensive tests for IR package#3

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-more-tests-for-ir-package
Draft

Add comprehensive tests for IR package#3
Copilot wants to merge 3 commits intomasterfrom
copilot/add-more-tests-for-ir-package

Conversation

Copy link

Copilot AI commented Dec 4, 2025

Adds test coverage for IR package components that were previously untested.

New test file: test/ir_tests.mbt

Constants

  • ConstantFP truncation/extension (fptrunc, fpext)
  • ConstantInt bounds checking (isMaxValue, isMinValue) and comparison predicates
  • ConstantFP comparison with NaN handling (ordered vs unordered)
  • ConstantStruct creation, element access, extractValue
  • ConstantArray/ConstantVector operations
  • ConstantPointerNull with address spaces

Types

  • PointerType with different address spaces and caching
  • Context type getters (getLabelTy, getMetadataTy, getFP128Ty, getTokenTy)
  • getConstZero/getConstOne for various types

IRBuilder

  • Arithmetic: createSRem, createURem, createUDiv, createExactUDiv, createExactSDiv, createNeg, createFRem
  • Comparisons: ICmp (UGT, UGE, ULT, ULE, SGE, SLE), FCmp (OGE, OLE)
  • BasicBlock predecessor tracking

Module operations

  • getFunction, addGlobalVariable, addGlobalConstant, addGlobalString

IRBuilder state

  • getInsertBlock, getInsertFunction, getContext, getModule
test "ConstantInt comparison predicates" {
  let ctx = Context::new()
  let i32_5 = ctx.getConstInt32(5)
  let i32_m5 = ctx.getConstInt32(-5)
  
  inspect(i32_m5.compare(SLT, i32_5), content="i1 true")  // signed: -5 < 5
  inspect(i32_m5.compare(UGT, i32_5), content="i1 true")  // unsigned: -5 is large
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cli.moonbitlang.com
    • Triggering command: /usr/bin/curl curl REDACTED -sSf (dns block)
    • Triggering command: /usr/bin/curl curl -fsSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

try to add more tests for IR package


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 4, 2025 16:33
…lder, Module, Context, and BasicBlock

Co-authored-by: bobzhang <747051+bobzhang@users.noreply.github.com>
Co-authored-by: bobzhang <747051+bobzhang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add more tests for IR package Add comprehensive tests for IR package Dec 4, 2025
Copilot AI requested a review from bobzhang December 4, 2025 16:45
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.

2 participants