Skip to content

Commit 78ed555

Browse files
Add failing test, TODO: fix in a later PR
1 parent 6ab1df6 commit 78ed555

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/test/java/net/marcellperger/mathexpr/parser/ParserTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.jetbrains.annotations.Contract;
77
import org.jetbrains.annotations.NotNull;
88
import org.jetbrains.annotations.Nullable;
9+
import org.junit.jupiter.api.Disabled;
910
import org.junit.jupiter.params.ParameterizedTest;
1011
import org.junit.jupiter.params.provider.ValueSource;
1112

@@ -36,7 +37,8 @@ void assertInfixParsesTo_inner(String src, int level, MathSymbol expected) {
3637
// Expects it to be full parse
3738
Parser p = new Parser(src);
3839
MathSymbol actual = assertDoesNotThrow(() -> p.parseInfixPrecedenceLevel(level));
39-
assertEquals(src.substring(0, p.idx), src, "Didn't fully parse the string"); // = isEof() but better msg
40+
assertEquals('"' + src + '"', '"' + src.substring(0, p.idx) + '"',
41+
"Didn't fully parse the string"); // = isEof() but better msg
4042
assertTrue(p.isEof());
4143
assertEquals(expected, actual);
4244
}
@@ -146,6 +148,21 @@ void parse_pow(boolean disableCache) {
146148
}
147149
}
148150

151+
152+
@Disabled("[SKIP] Failing, will fix in a later PR")
153+
@ParameterizedTest
154+
@ValueSource(booleans = {true, false})
155+
void parensWhitespaceBug(boolean disableCache) {
156+
try(var ignored = setNocacheAttr(disableCache)) {
157+
// These 3 are fine
158+
assertInfixParsesTo("( 1.2 )", MUL_PREC, new BasicDoubleSymbol(1.2));
159+
assertParsesTo("( 1.2 )", new BasicDoubleSymbol(1.2));
160+
assertParsesTo(" 1.2 ", new BasicDoubleSymbol(1.2));
161+
// This is not - could be a bug in the future
162+
assertInfixParsesTo(" 1.2 ", 0, new BasicDoubleSymbol(1.2));
163+
}
164+
}
165+
149166
protected WithNocache setNocacheAttr(boolean disableCache) {
150167
return new WithNocache(this, disableCache);
151168
}

0 commit comments

Comments
 (0)