Skip to content

Commit

Permalink
Fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Feb 11, 2025
1 parent 2f04cb1 commit d08423a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ public void StartEmbed(UsfmParserState state, string marker)
NextElement(marker);
}

StartEmbed(state, CreateVerseRefs());
StartEmbed(state, CreateNonVerseRef());
}

public virtual void StartEmbed(UsfmParserState state, IReadOnlyList<ScriptureRef> scriptureRefs) { }
public virtual void StartEmbed(UsfmParserState state, ScriptureRef scriptureRef) { }

public virtual void EndEmbed(
UsfmParserState state,
Expand Down
8 changes: 4 additions & 4 deletions src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ bool closed
base.EndChar(state, marker, attributes, closed);
}

public override void StartEmbed(UsfmParserState state, IReadOnlyList<ScriptureRef> scriptureRefs)
public override void StartEmbed(UsfmParserState state, ScriptureRef scriptureRef)
{
_embedRowTexts = AdvanceRows(scriptureRefs).ToList();
_embedRowTexts = AdvanceRows(new[] { scriptureRef }).ToList();
_embedUpdated = _embedRowTexts.Count > 0;

// strip out notes in verses that are being replaced
Expand Down Expand Up @@ -407,8 +407,8 @@ private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true)
ClearNewTokens();

// figure out when to skip the existing text
bool embedInNewVerseText = _replace.Any(r => r);
if (embedInNewVerseText && _embedUpdated)
bool embedInNewVerseText = _replace.Any(r => r) && inEmbed;
if (embedInNewVerseText || _embedUpdated)
{
if (_embedBehavior == UpdateUsfmIntraVerseMarkerBehavior.Strip)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void GetUsfm_PreferExisting()
{
var rows = new List<(IReadOnlyList<ScriptureRef>, string)>
{
(ScrRef("MAT 1:6"), "Update 1"),
(ScrRef("MAT 1:7"), "Update 2"),
(ScrRef("MAT 1:1"), "Update 1"),
(ScrRef("MAT 1:2"), "Update 2"),
};
var usfm =
@"\id MAT - Test
Expand Down
4 changes: 2 additions & 2 deletions tests/SIL.Machine.Tests/Corpora/UsfmFileTextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void GetRows_NonEmptyText_AllText()
Assert.That(rows[1].Text, Is.EqualTo("Matthew"));

Assert.That(rows[2].Ref, Is.EqualTo(ScriptureRef.Parse("MAT 1:0/3:ip", corpus.Versification)));
Assert.That(rows[2].Text, Is.EqualTo("An introduction to Matthew with an empty comment"));
Assert.That(rows[2].Text, Is.EqualTo("An introduction to Matthew"));

Assert.That(rows[3].Ref, Is.EqualTo(ScriptureRef.Parse("MAT 1:0/3:ip/1:fe", corpus.Versification)));
Assert.That(rows[3].Text, Is.EqualTo("This is an endnote."));
Expand Down Expand Up @@ -256,7 +256,7 @@ public void GetRows_IncludeMarkers_AllText()

IText text = corpus["MAT"];
TextRow[] rows = text.GetRows().ToArray();
Assert.That(rows, Has.Length.EqualTo(47));
Assert.That(rows, Has.Length.EqualTo(46));

Assert.That(rows[2].Ref, Is.EqualTo(ScriptureRef.Parse("MAT 1:0/3:ip", corpus.Versification)));
Assert.That(rows[2].Text, Is.EqualTo("An introduction to Matthew\\fe + \\ft This is an endnote.\\fe*"));
Expand Down

0 comments on commit d08423a

Please sign in to comment.