Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ porting a test — several `VerseRefTests` cases can't pass yet, and it's not ob
needs `Versification.getLastBook/getLastChapter/getLastVerse`, which needs the `.vrs`
versification data ported — see the stalled `improve-verseref` branch.
- **`VerseRef.isExcluded`** is hardcoded `return false` with a `TODO`.
- **`VerseRef.set verseNum`** is a mis-port still carrying a `ToDo`: it assigns the backing field
but omits the C# negative guard _and_ the `verse = null` that clears a range string. So setting
`verseNum` on `'LUK 3:4b-5a'` leaves a stale `'4b-5a'` in the `verse` getter.
- **`BBBCCCVVVS`** is declared but not implemented.
- **The numeric constructor bypasses the setters**, assigning `_bookNum`/`_chapterNum`/`_verseNum`
directly. So the C# `Invalid` test's constructor-throws cases (e.g. `new VerseRef(2, -42, 1)`)
Expand Down
34 changes: 34 additions & 0 deletions src/verse-ref.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,40 @@ describe('VerseRef', () => {
vref.chapterNum = 0;
expect(vref.chapterNum).toEqual(0);
});

it('should throw when verseNum is negative', () => {
const vref = new VerseRef('LUK 3:4', ScrVers.English);
expect(() => {
vref.verseNum = -1;
}).toThrow(VerseRefException);
});

it('should not throw when verseNum is zero', () => {
const vref = new VerseRef('LUK 3:4', ScrVers.English);
vref.verseNum = 0;
expect(vref.verseNum).toEqual(0);
});

it('should clear a verse range when verseNum is set', () => {
const vref = new VerseRef('LUK', '3', '4b-5a', ScrVers.English);
expect(vref.verse).toEqual('4b-5a');
expect(vref.hasMultiple).toBe(true);

vref.verseNum = 9;

expect(vref.verseNum).toEqual(9);
expect(vref.verse).toEqual('9');
expect(vref.hasMultiple).toBe(false);
});

it('should clear a verse segment when verseNum is set', () => {
const vref = new VerseRef('LUK', '3', '4b', ScrVers.English);
expect(vref.verse).toEqual('4b');

vref.verseNum = 9;

expect(vref.verse).toEqual('9');
});
});

describe('String', () => {
Expand Down
5 changes: 4 additions & 1 deletion src/verse-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,11 @@ export class VerseRef {
return this._verseNum;
}
set verseNum(value: number) {
// ToDo: replace or remove this placeholder
if (value < 0) {
throw new VerseRefException('VerseNum can not be negative');
}
this._verseNum = value;
this._verse = undefined;
}

/**
Expand Down
Loading