Skip to content
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
8 changes: 6 additions & 2 deletions src/main/java/net/marcellperger/mathexpr/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public MathSymbol parseExpr() throws ExprParseException {
}

public @Nullable MathSymbol parseParens() throws ExprParseException {
advanceExpectNext('(');
advanceExpectNext_ignoreWs('(');
MathSymbol sym = parseExpr();
advanceExpectNext(')');
advanceExpectNext_ignoreWs(')');
return sym;
}

Expand Down Expand Up @@ -171,6 +171,10 @@ protected void advanceExpectNext(char expected) {
char actual = advance();
if(actual != expected) throw new ExprParseRtException("Expected '%c', got '%c'".formatted(expected, actual));
}
protected void advanceExpectNext_ignoreWs(char expected) {
discardWhitespace();
advanceExpectNext(expected);
}

protected boolean matchesNext(@NotNull String expected) {
return src.startsWith(expected, /*start*/idx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

Expand Down Expand Up @@ -147,8 +146,6 @@ void parse_pow(boolean disableCache) {
assertParsesTo(CommonData.getBigData3Pow_groupingParens());
}
}

@Disabled("[SKIP] Failing, will fix in a later PR")
@ParameterizedTest
@ValueSource(booleans = {true, false})
void parensWhitespaceBug(boolean disableCache) {
Expand All @@ -157,8 +154,6 @@ void parensWhitespaceBug(boolean disableCache) {
assertInfixParsesTo("( 1.2 )", MUL_PREC, new BasicDoubleSymbol(1.2));
assertParsesTo("( 1.2 )", new BasicDoubleSymbol(1.2));
assertParsesTo(" 1.2 ", new BasicDoubleSymbol(1.2));
// This is not - could be a bug in the future
assertInfixParsesTo(" 1.2 ", 0, new BasicDoubleSymbol(1.2));
}
}

Expand Down