Skip to content

Commit

Permalink
Merge pull request #258 from usethesource/escape-character-default-bug
Browse files Browse the repository at this point in the history
Escape character default bug
  • Loading branch information
DavyLandman authored Jun 18, 2024
2 parents e1b5b37 + 16ad307 commit 004f2e1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}

}

0 comments on commit 004f2e1

Please sign in to comment.