Skip to content

Commit

Permalink
Fix 2 unit tests that failed on some versions of windows (just simple…
Browse files Browse the repository at this point in the history
… newline comparisons)
  • Loading branch information
jjlauer committed Nov 5, 2024
1 parent 8349996 commit 91534b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.File;
import java.util.List;

import static com.fizzed.rocker.compiler.TestHelper.normalizeNewlines;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

Expand Down Expand Up @@ -787,7 +788,7 @@ public void testIfElseStatement() throws Exception {

unit = model.findUnitByOccurrence(IfBlockElse.class, 2);
assertThat(unit.getExpression(), nullValue());
assertThat(unit.getSourceRef().getText(), is("}\nelse {\nspacy\n}"));
assertThat(normalizeNewlines(unit.getSourceRef().getText()), is("}\nelse {\nspacy\n}"));
}

@Test
Expand All @@ -812,7 +813,7 @@ public void testIfElseIfStatement() throws Exception {
// Check that else is there as well.
IfBlockElse elseUnit = model.findUnitByOccurrence(IfBlockElse.class, 1);
assertThat(elseUnit.getExpression(), nullValue());
assertThat(elseUnit.getSourceRef().getText(), is("}\nelse {else}"));
assertThat(normalizeNewlines(elseUnit.getSourceRef().getText()), is("}\nelse {else}"));

// Finally since we had nested javascript in the template, we should find no more occurrences
// of if, else if and else.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.fizzed.rocker.compiler;

public class TestHelper {

static public String normalizeNewlines(String v) {
if (v != null) {
return v.replaceAll("\r\n", "\n");
}
return null;
}

}

0 comments on commit 91534b1

Please sign in to comment.