Skip to main content
ClaudeWave
Skill85 estrellas del repoactualizado 3mo ago

interval-guided-regression-test-update

Automatically updates regression tests based on interval analysis to maintain coverage of key program intervals. Use when code changes affect value ranges, conditionals, or control flow, and existing tests need updating to maintain interval coverage. Analyzes interval information from updated code, identifies coverage gaps, adjusts test inputs and assertions, removes redundant tests, and generates new tests for uncovered intervals. Supports Python, Java, JavaScript, and C/C++ with various test frameworks (pytest, JUnit, Jest, Google Test).

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/ArabelaTso/Skills-4-SE /tmp/interval-guided-regression-test-update && cp -r /tmp/interval-guided-regression-test-update/skills/interval-guided-regression-test-update ~/.claude/skills/interval-guided-regression-test-update
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Interval-Guided Regression Test Update

Automatically update regression tests to maintain interval coverage when program code changes.

## Core Concept

**Intervals** represent ranges of values that variables can take during execution. When code changes, intervals may be added, removed, or modified. This skill ensures regression tests continue to cover all important intervals.

**Example:**
```python
# Old code
def process(x):
    if x < 10:
        return x * 2
    else:
        return x + 10

# Intervals: [0, 10), [10, ∞)

# New code (added negative handling)
def process(x):
    if x < 0:
        return -x
    elif x < 10:
        return x * 2
    else:
        return x + 10

# Intervals: (-∞, 0), [0, 10), [10, ∞)
# Need to add test for new interval: x < 0
```

## Workflow

### 1. Analyze Existing Tests

Parse the current regression test suite:
- Identify test inputs
- Determine which intervals each test covers
- Calculate current interval coverage

```python
# Example test analysis
test_process_small: input=5, covers [0, 10)
test_process_large: input=15, covers [10, ∞)
# Coverage: 2/2 intervals = 100%
```

### 2. Extract Interval Information

Obtain interval information from the updated program:

**From static analysis:**
- Parse conditionals (if, switch, etc.)
- Extract comparison operators
- Derive interval constraints

**From profiling:**
- Run existing tests
- Track observed value ranges
- Identify intervals exercised

**From symbolic execution:**
- Execute with symbolic values
- Collect path constraints
- Derive interval constraints

See [references/interval-analysis.md](references/interval-analysis.md) for detailed extraction methods.

### 3. Identify Coverage Gaps

Compare current coverage with new intervals:

```python
old_intervals = {[0, 10), [10, ∞)}
new_intervals = {(-∞, 0), [0, 10), [10, ∞)}

added_intervals = {(-∞, 0)}  # Need new test
removed_intervals = {}
modified_intervals = {}
```

### 4. Update Tests

Apply appropriate update strategies:

**Add tests for new intervals:**
```python
# New test for (-∞, 0)
def test_process_negative():
    assert process(-5) == 5
```

**Adjust inputs for modified intervals:**
```python
# If boundary changed from x < 10 to x < 20
# Old: test_process_large with input=15
# New: test_process_large with input=25
```

**Update assertions for changed behavior:**
```python
# If logic changed
# Old: assert process(5) == 10
# New: assert process(5) == 15
```

**Remove redundant tests:**
```python
# If intervals merged, remove duplicate coverage
```

See [references/test-update-strategies.md](references/test-update-strategies.md) for detailed strategies.

### 5. Validate Updated Tests

Run the updated test suite:
- Execute all tests
- Verify all pass
- Check interval coverage
- Identify any remaining gaps

### 6. Generate Coverage Report

Provide comprehensive summary:
- Before/after interval coverage
- Tests added, modified, removed
- Validation results
- Remaining gaps (if any)

## Quick Start Examples

### Example 1: New Interval Added

**Scenario:** Function adds handling for negative numbers

**Original code:**
```python
def abs_double(x):
    if x < 10:
        return x * 2
    else:
        return x + 10
```

**Original tests:**
```python
def test_small():
    assert abs_double(5) == 10

def test_large():
    assert abs_double(15) == 25
```

**Updated code:**
```python
def abs_double(x):
    if x < 0:
        return -x * 2
    elif x < 10:
        return x * 2
    else:
        return x + 10
```

**Updated tests:**
```python
def test_negative():  # NEW
    assert abs_double(-5) == 10

def test_small():
    assert abs_double(5) == 10

def test_large():
    assert abs_double(15) == 25
```

**Summary:**
- Added interval: (-∞, 0)
- Added test: test_negative
- Coverage: 2/2 → 3/3 (100%)

### Example 2: Interval Boundary Changed

**Scenario:** Threshold value modified

**Original code:**
```python
def categorize(score):
    if score < 60:
        return "fail"
    else:
        return "pass"
```

**Original tests:**
```python
def test_fail():
    assert categorize(50) == "fail"

def test_pass():
    assert categorize(70) == "pass"
```

**Updated code:**
```python
def categorize(score):
    if score < 50:  # Changed from 60
        return "fail"
    else:
        return "pass"
```

**Updated tests:**
```python
def test_fail():
    assert categorize(40) == "fail"  # Changed input from 50

def test_pass():
    assert categorize(60) == "pass"  # Changed input from 70
```

**Summary:**
- Modified interval: [0, 60) → [0, 50)
- Modified interval: [60, ∞) → [50, ∞)
- Updated 2 test inputs
- Coverage: 2/2 → 2/2 (100%)

### Example 3: Intervals Merged

**Scenario:** Simplified logic combines cases

**Original code:**
```python
def classify(x):
    if x < 0:
        return "negative"
    elif x == 0:
        return "zero"
    else:
        return "positive"
```

**Original tests:**
```python
def test_negative():
    assert classify(-5) == "negative"

def test_zero():
    assert classify(0) == "zero"

def test_positive():
    assert classify(5) == "positive"
```

**Updated code:**
```python
def classify(x):
    if x <= 0:
        return "non-positive"
    else:
        return "positive"
```

**Updated tests:**
```python
def test_non_positive():  # Merged
    assert classify(-5) == "non-positive"
    assert classify(0) == "non-positive"

def test_positive():
    assert classify(5) == "positive"
```

**Summary:**
- Merged intervals: (-∞, 0) and {0} → (-∞, 0]
- Removed test: test_zero (redundant)
- Updated test: test_negative → test_non_positive
- Coverage: 3/3 → 2/2 (100%)

## Update Strategies

### Strategy 1: Input Adjustment

Modify test inputs to cover new or changed intervals.

**When to use:**
- New interval added
- Interval boundary changed
- Need to cover previously uncovered interval

**How:**
1. Identify target interval
2. Select representative value from interval
3. Update test input
4. Verify test still valid

### Strategy 2: Assertion Update
abstract-domain-explorerSkill

Applies abstract interpretation using different abstract domains (intervals, octagons, polyhedra, sign, congruence) to statically analyze program variables and infer invariants, value ranges, and relationships. Use when analyzing program properties, inferring loop invariants, detecting potential errors, or understanding variable relationships through static analysis.

abstract-invariant-generatorSkill

Uses abstract interpretation to automatically infer loop invariants, function preconditions, and postconditions for formal verification. Generates invariants that capture program behavior and support correctness proofs in Dafny, Isabelle, Coq, and other verification systems. Use when adding formal specifications to code, generating verification conditions, inferring contracts for functions, or discovering loop invariants for proofs.

abstract-state-analyzerSkill

Performs abstract interpretation over source code to infer possible program states, variable ranges, and data properties without executing the program. Reports potential runtime errors including out-of-bounds accesses, null dereferences, type inconsistencies, division by zero, and integer overflows. Use when analyzing code for potential runtime errors, performing static analysis, checking safety properties, or verifying program behavior without execution.

abstract-trace-summarizerSkill

Performs abstract interpretation to produce summarized execution traces and high-level program behavior representations. Highlights key control flow paths, variable relationships, loop invariants, function summaries, and potential runtime states using abstract domains (intervals, signs, nullness, etc.). Use when analyzing program behavior, understanding execution paths, computing loop invariants, tracking variable ranges, detecting potential runtime errors, or generating program summaries without concrete execution.

acsl-annotation-assistantSkill

Create ACSL (ANSI/ISO C Specification Language) formal annotations for C/C++ programs. Use this skill when working with formal verification, adding function contracts (requires/ensures), loop invariants, assertions, memory safety annotations, or any ACSL specifications. Supports Frama-C verification and generates comprehensive formal specifications for C/C++ code.

agent-browserSkill

CLI-based browser automation with persistent page state using ref-based element interaction. Use when users ask to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

ambiguity-detectorSkill

Detects and analyzes ambiguous language in software requirements and user stories. Use when reviewing requirements documents, user stories, specifications, or any software requirement text to identify vague quantifiers, unclear scope, undefined terms, missing edge cases, subjective language, and incomplete specifications. Provides detailed analysis with clarifying questions and suggested improvements.

api-design-assistantSkill

Design and review APIs with suggestions for endpoints, parameters, return types, and best practices. Use when designing new APIs from requirements, reviewing existing API designs, generating API documentation, or getting implementation guidance. Supports REST APIs with focus on endpoint structure, request/response schemas, authentication, pagination, filtering, versioning, and OpenAPI specifications. Triggers when users ask to design, review, document, or improve APIs.