Skip to content

Commit

Permalink
Make sure string literals contain line breaks
Browse files Browse the repository at this point in the history
Fix the lexer to include the newlines.

Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed Nov 28, 2016
1 parent 79ac2eb commit e69554a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core-lib/TestSuite/StringTests.som
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ class StringTests usingPlatform: platform testFramework: minitest = (
1234567890
1234567890'
)

public testMultLineStringPreserveNewlines = (
| str |
str := '123
567'.
assert: '\n' equals: (str charAt: 4).
assert: 7 equals: str length.
)

public testEscapeSequences = (
(* Tests for escape sequences, not all of them are reliable represented
Expand Down
1 change: 1 addition & 0 deletions src/som/compiler/Lexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ private void lexString() {
if (fillBuffer() == -1) {
return;
}
state.text.append('\n');
}
}

Expand Down

0 comments on commit e69554a

Please sign in to comment.