Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape character default bug #258

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}

}
Loading