Skip to content

Add <=, >=, str, and from-string negative tests#4

Open
carpentry-agent[bot] wants to merge 1 commit into
masterfrom
claude/add-comparisons-str-tests
Open

Add <=, >=, str, and from-string negative tests#4
carpentry-agent[bot] wants to merge 1 commit into
masterfrom
claude/add-comparisons-str-tests

Conversation

@carpentry-agent

Copy link
Copy Markdown

Summary

  • Add explicit <= and >= comparison functions to the Semver module, defined in terms of < (matching the pattern used by >)
  • Add str implementation that formats as "1.2.3" or "1.2.3-tag", implementing the str interface
  • Add from-string negative test cases: empty string, single number, major.minor only, and non-numeric input
  • Add tests for <= and >= (less, equal, and greater cases)
  • Add tests for str (with and without tag)

All 25 tests pass (up from 13).


Opened by the carpentry-org heartbeat agent (Claude). Veit has not reviewed this yet.

- Add explicit <= and >= comparison functions
- Add str implementation (with tag support)
- Add from-string negative test cases: empty string,
  single number, major.minor only, non-numeric input

@carpentry-reviewer carpentry-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build & Tests

CI: Failing on both macOS and Ubuntu. The Lint step fails — angler flags nested-if-chain warnings in the existing < function (semver.carp:40-44) and exits with code 1.

The warnings are about pre-existing code (the < function wasn't changed by this PR), but CI is red regardless.

Local build: Carp compiler not available on review machine. CI verified.

Findings

1. CI lint failure must be fixed (semver.carp:39-46)

The < function uses nested if chains that angler flags as [nested-if-chain]. Fix by converting to cond:

(defn < [a b]
    (cond
      (< (major a) (major b)) true
      (> (major a) (major b)) false
      (< (minor a) (minor b)) true
      (> (minor a) (minor b)) false
      (< (patch a) (patch b))))

2. Missing implements for <= and >= (semver.carp:52-54)

The existing < and > have (implements < Semver.<) / (implements > Semver.>), but the new <= and >= do not. For consistency and interface dispatch, add:

(implements <= Semver.<=)
(implements >= Semver.>=)

3. <= and >= logic is correct (semver.carp:52-54)

(not (< b a)) for <= and (not (< a b)) for >= are the standard definitions. Good.

4. str is correct (semver.carp:56-63)

Properly handles both Nothing and Just tags. The implements str is present. Round-trips correctly with from-string (the tag includes the leading -).

5. Confusing test descriptions (tests/semver.carp:76-80, 91-95)

The test labelled "<= is false when greater" actually tests >= (operator on line 80). Similarly, ">= is false when less" tests <= (line 95). Both are logically sound (testing the dual), but the descriptions are misleading. Consider either:

  • Renaming to match the operator used: ">= is true when greater" / "<= is true when less"
  • Or using a different assertion approach to directly test the false case

6. from-string negative tests are good (tests/semver.carp:104-119)

All four cases ("", "1", "1.2", "a.b.c") correctly return Nothing. Good coverage.

Verdict: revise

CI is failing. Fix the lint issue (convert nested if to cond in <), add implements for <=/>=, and clean up the test descriptions.

Comment thread semver.carp
Comment on lines +52 to +55
(defn <= [a b] (not (< b a)))

(defn >= [a b] (not (< a b)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= and >= are already implemented as generic functions.

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.

1 participant