33import net .marcellperger .mathexpr .*;
44import net .marcellperger .mathexpr .util .Util ;
55import net .marcellperger .mathexpr .util .UtilCollectors ;
6+
7+ import org .jetbrains .annotations .Contract ;
68import org .jetbrains .annotations .NotNull ;
79import org .jetbrains .annotations .Nullable ;
810import org .junit .jupiter .api .Test ;
11+ import org .junit .jupiter .params .ParameterizedTest ;
12+ import org .junit .jupiter .params .provider .ValueSource ;
913
1014import java .lang .reflect .Field ;
1115import java .util .Arrays ;
@@ -127,7 +131,7 @@ void parsePrecedenceLevel() {
127131 new DivOperation (new DivOperation (new BasicDoubleSymbol (.9 ), new BasicDoubleSymbol (2. )), new BasicDoubleSymbol (3.3 )));
128132 }
129133
130- @ Test
134+ @ Test // TODO make this not test/inline it
131135 void parsePrecedenceLevel_pow () {
132136 assertInfixParsesTo ("1.2**9.1" , POW_PREC ,
133137 new PowOperation (new BasicDoubleSymbol (1.2 ), new BasicDoubleSymbol (9.1 )));
@@ -151,34 +155,51 @@ void parse_pow() {
151155 assertParsesTo (CommonData .getBigData3Pow_groupingParens ());
152156 }
153157
154- @ Test // TODO can we do parametrized tests?
155- void parsePrecedenceLevel_pow_nocache () {
156- try (var ignored = new WithNocache (this )) {
158+ @ ParameterizedTest
159+ @ ValueSource (booleans ={true , false })
160+ void parsePrecedenceLevel_pow_nocache (boolean disableCache ) {
161+ try (var ignored = new WithNocache (this , disableCache )) {
157162 parsePrecedenceLevel_pow ();
158163 }
159164 }
160165
161- @ Test // TODO can we do parametrized tests?
162- void parse_pow_nocache () {
163- try (var ignored = new WithNocache (this )) {
166+ // TODO do more parameterized tests
167+ @ ParameterizedTest
168+ @ ValueSource (booleans ={true , false })
169+ void parse_pow_nocache (boolean disableCache ) {
170+ try (var ignored = new WithNocache (this , disableCache )) {
164171 parse_pow ();
165172 }
166173 }
167174
168- @ Test
169- void parsePrecedenceLevel_nocache () {
170- try (var ignored = new WithNocache (this )) {
175+ @ ParameterizedTest
176+ @ ValueSource (booleans ={true , false })
177+ void parsePrecedenceLevel_nocache (boolean disableCache ) {
178+ try (var ignored = new WithNocache (this , disableCache )) {
171179 parsePrecedenceLevel ();
172180 }
173181 }
174182
175183 static class WithNocache implements AutoCloseable {
176184 boolean origNocache ;
185+ boolean doDisable ;
177186 ParserTest inst ;
178187
179188 WithNocache (ParserTest inst_ ) {
180189 inst = inst_ ;
190+ start ();
191+ }
192+ WithNocache (ParserTest inst_ , boolean doDisable_ ) {
193+ inst = inst_ ;
194+ doDisable = doDisable_ ;
195+ start ();
196+ }
197+
198+ @ Contract ("->this" )
199+ public WithNocache start () {
181200 origNocache = inst .nocache ;
201+ inst .nocache = doDisable ;
202+ return this ;
182203 }
183204
184205 public void close () {
0 commit comments