use of org.mvel2.CompileException in project mvel by mikebrock.
the class CoreConfidenceTests method testStrictTypingCompilation.
public void testStrictTypingCompilation() {
// OptimizerFactory.setDefaultOptimizer(OptimizerFactory.DYNAMIC);
ExpressionCompiler compiler = new ExpressionCompiler("a.foo;\nb.foo;\n x = 5");
ParserContext ctx = new ParserContext();
ctx.setStrictTypeEnforcement(true);
try {
compiler.compile(ctx);
} catch (CompileException e) {
e.printStackTrace();
return;
}
assertTrue(false);
// OptimizerFactory.setDefaultOptimizer(OptimizerFactory.DYNAMIC);
}
use of org.mvel2.CompileException in project mvel by mikebrock.
the class TypesAndInferenceTests method testSetAccessorOverloadedEqualsStrictMode2.
public void testSetAccessorOverloadedEqualsStrictMode2() {
ParserContext ctx = new ParserContext();
ctx.setStrongTyping(true);
ctx.addInput("foo", Foo.class);
try {
CompiledExpression expr = new ExpressionCompiler("foo.aValue = 'bar'").compile(ctx);
} catch (CompileException e) {
assertTrue(false);
}
}
use of org.mvel2.CompileException in project mvel by mikebrock.
the class Fuzzer method main.
public static void main(String[] args) throws IOException {
DecimalFormat df = new DecimalFormat("###,###.##");
StringAppender append = new StringAppender();
int len;
long start = currentTimeMillis();
long time;
double rate;
int seed;
boolean flip = false;
Random rand = new Random(System.currentTimeMillis());
Random rand1 = new Random(System.currentTimeMillis() + 1);
Random rand2 = new Random(rand1.nextInt());
Random rand3 = new Random(rand.nextInt(SALTS.length - 1));
Random rand4 = new Random(rand3.nextInt());
for (int run = 0; run < MAX; run++) {
len = (int) (random() * 500) + 10;
append.reset();
for (int i = 0; i < len; i++) {
append.append(CHAR_TABLE[((SALTS[((rand.nextInt(1000)) + 1) % SALTS.length]) * ((flip = !flip) ? rand1.nextInt(1000) : rand2.nextInt(1000)) + 1) % CHAR_TABLE.length]);
SALTS[rand3.nextInt(SALTS.length - 1)] ^= rand4.nextInt(1000) + 1;
}
try {
MVEL.eval(append.toString());
} catch (UnresolveablePropertyException e) {
//ignore
} catch (CompileException e) {
//ignore
} catch (ArithmeticException e) {
//ignore
} catch (ScriptRuntimeException e) {
//ignore
} catch (Exception e) {
System.out.println("untrapped error!\n---\n" + append.toString() + "\n---\n");
System.out.flush();
e.printStackTrace();
System.err.flush();
}
if (run % 25000 == 0 && run != 0) {
rate = run / (time = (currentTimeMillis() - start) / 1000);
System.out.println("Run: " + df.format(run) + " times; " + df.format(time) + "secs; " + df.format(rate) + " avg. per second.");
}
}
}
Aggregations