Skip to content

Commit

Permalink
Woohoo! The java builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwynne committed Jun 10, 2010
1 parent bb43ca4 commit c405e32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
17 changes: 17 additions & 0 deletions java/src/test/java/gherkin/I18nLexerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
import static org.mockito.Mockito.verify;

public class I18nLexerTest {
@Test
public void shouldScanMultiLineFeature() {
Listener listener = mock(Listener.class);
Lexer lexer = new I18nLexer(listener);

String feature = "Feature: Hello\n" +
" World\n" +
" Scenario Outline:\n" +
" Given I have an empty stack\n" +
" When I pøsh <x> onto the stack";

lexer.scan(feature);

verify(listener).feature("Feature", "Hello", "World", 1);
verify(listener).step("When ", "I pøsh <x> onto the stack", 5);
}

@Test
public void shouldScanUtf8FeatureInSourceProperly() {
Listener listener = mock(Listener.class);
Expand Down
13 changes: 11 additions & 2 deletions ragel/lexer.java.rl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,20 @@ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {


private String nameFromContents(String contents) {
return contents; // TODO
if (contents.isEmpty()) return "";
String[] lines = contents.split("\r?\n");
return lines[0];
}

private String descriptionFromContents(String contents) {
return contents; // TODO
String[] lines = contents.split("\r?\n");
if (lines.length < 2) return "";

StringBuilder out = new StringBuilder();
out.append(lines[1]);
for (int i = 2; i < lines.length; ++i)
out.append("\n").append(lines[i]);
return out.toString();
}

private String multilineStrip(String text) {
Expand Down

0 comments on commit c405e32

Please sign in to comment.