From e69554a278550a6d578ec1df9a769c6fd362a267 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Fri, 25 Nov 2016 17:15:38 +0100 Subject: [PATCH] Make sure string literals contain line breaks Fix the lexer to include the newlines. Signed-off-by: Stefan Marr --- core-lib/TestSuite/StringTests.som | 8 ++++++++ src/som/compiler/Lexer.java | 1 + 2 files changed, 9 insertions(+) diff --git a/core-lib/TestSuite/StringTests.som b/core-lib/TestSuite/StringTests.som index 9c91cd368..22f5f9211 100644 --- a/core-lib/TestSuite/StringTests.som +++ b/core-lib/TestSuite/StringTests.som @@ -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 diff --git a/src/som/compiler/Lexer.java b/src/som/compiler/Lexer.java index 12c19b1fa..24be1a4d0 100644 --- a/src/som/compiler/Lexer.java +++ b/src/som/compiler/Lexer.java @@ -293,6 +293,7 @@ private void lexString() { if (fillBuffer() == -1) { return; } + state.text.append('\n'); } }