diff --git a/src/main/java/io/usethesource/vallang/io/StandardTextReader.java b/src/main/java/io/usethesource/vallang/io/StandardTextReader.java index 2b0e8cc54..a8e1d83f7 100644 --- a/src/main/java/io/usethesource/vallang/io/StandardTextReader.java +++ b/src/main/java/io/usethesource/vallang/io/StandardTextReader.java @@ -742,7 +742,7 @@ private IValue readString(Type expected) throws IOException { if (current == -1) { throw new FactParseError("End of input before finding end of String", stream.offset); } - builder.append(current); + builder.append((char)current); } current = stream.read(); } diff --git a/src/test/java/io/usethesource/vallang/basic/LazyStringOperationsTest.java b/src/test/java/io/usethesource/vallang/basic/LazyStringOperationsTest.java index e0a85095d..bc98fe5d0 100644 --- a/src/test/java/io/usethesource/vallang/basic/LazyStringOperationsTest.java +++ b/src/test/java/io/usethesource/vallang/basic/LazyStringOperationsTest.java @@ -194,7 +194,7 @@ public void testStringReplace(IValueFactory vf) { @ParameterizedTest @ArgumentsSource(ValueProvider.class) public void neverRunOutOfStack(IValueFactory vf) { - int outofStack = 30000; + int outofStack = 100000; // first we have to know for sure that we would run out of stack with @see // outOfStack iterations: diff --git a/src/test/java/io/usethesource/vallang/issues/RegressionTests.java b/src/test/java/io/usethesource/vallang/issues/RegressionTests.java index 987447d2e..19ba0c6cf 100644 --- a/src/test/java/io/usethesource/vallang/issues/RegressionTests.java +++ b/src/test/java/io/usethesource/vallang/issues/RegressionTests.java @@ -5,6 +5,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; import java.io.StringWriter; import org.junit.jupiter.params.ParameterizedTest; @@ -14,8 +16,10 @@ import io.usethesource.vallang.IConstructor; import io.usethesource.vallang.ISet; import io.usethesource.vallang.ISourceLocation; +import io.usethesource.vallang.IString; import io.usethesource.vallang.IValueFactory; import io.usethesource.vallang.ValueProvider; +import io.usethesource.vallang.io.StandardTextReader; import io.usethesource.vallang.io.StandardTextWriter; import io.usethesource.vallang.type.Type; import io.usethesource.vallang.type.TypeFactory; @@ -60,5 +64,18 @@ void keywordFieldsMakeConstructorsDifferent(IValueFactory vf, TypeFactory tf, Ty assertFalse(cons1.equals(cons2)); } - + + private IString readString(IValueFactory valueFactory, TypeStore typeStore, String s) throws IOException { + Reader reader = new StringReader(s); + StandardTextReader textReader = new StandardTextReader(); + return (IString) textReader.read(valueFactory, typeStore, TypeFactory.getInstance().stringType(), reader); + + } + + @ParameterizedTest @ArgumentsSource(ValueProvider.class) + void escapeNormalCharacters(IValueFactory valueFactory, TypeStore typeStore) throws IOException { + IString s = readString(valueFactory, typeStore, "\"\\$\""); + assertEquals("$", s.getValue()); + } + }