OpenParable
Skip to content
← Back to skills

Gen Property Test

Testing & Quality
gen-property-test

Gen Property Test is an Agent Skill for testing & quality published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Generate fast-check property tests following project conventions

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/data/gen-property-test/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/gen-property-test, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Generate Property Test

Generate a property-based test for the {{ method }} method on the Decimal class.

Project Conventions

This project uses fast-check for property-based testing. Follow these patterns:

Custom Arbitrary

Use the existing decimalArb pattern from src/core/decimal.property.test.ts:

import * as fc from "fast-check";
import { Decimal } from "./decimal";

// Arbitrary for valid decimal values
const decimalArb = fc
  .tuple(
    fc.bigInt({ min: -10n ** 18n, max: 10n ** 18n }),
    fc.integer({ min: 0, max: 8 })
  )
  .map(([significand, scale]) => {
    const str = significand.toString();
    if (scale === 0) return Decimal.from(str);
    const insertPoint = str.length - scale;
    if (insertPoint <= 0) {
      return Decimal.from(`0.${"0".repeat(-insertPoint)}${str.replace("-", "")}`);
    }
    return Decimal.from(`${str.slice(0, insertPoint)}.${str.slice(insertPoint)}`);
  });

Test Structure

import { describe, test, expect } from "bun:test";
import * as fc from "fast-check";

describe("{{ method }} properties", () => {
  test("property name", () => {
    fc.assert(
      fc.property(decimalArb, (a) => {
        // Return boolean for invariant
        return /* invariant expression */;
      })
    );
  });
});

Mathematical Invariants to Consider

For arithmetic operations, consider these properties:

PropertyFormulaApplies To
Identitya.op(identity) = aadd(0), multiply(1)
Commutativitya.op(b) = b.op(a)add, multiply
Associativity(a.op(b)).op(c) = a.op(b.op(c))add, multiply
Inversea.op(a.inverse()) = identityadd/negate, multiply/reciprocal
Distributivitya.mul(b.add(c)) = a.mul(b).add(a.mul(c))multiply over add
Idempotenceop(a, a) = amin, max
Absorptionmin(a, max(a, b)) = amin/max

Output Location

Add tests to: src/core/decimal.property.test.ts

Your Task

  1. Read src/core/decimal.property.test.ts to understand existing patterns
  2. Read src/core/decimal.ts to understand the {{ method }} implementation
  3. Generate property tests for {{ method }} covering relevant invariants
  4. Add tests to the existing property test file in the appropriate describe block