package org.mvel2.tests.core;

import org.mvel2.MVEL;

import java.util.HashMap;

/**
 * Tests to ensure MVEL fails when it should.
 */
public class FailureTests extends AbstractTest {
    public void testBadParserConstruct() {
        try {
            test("a = 0; a =+++ 5;");
        }
        catch (Exception e) {
            System.out.println(e);
        }

    }

    public void testShouldFail() {
        try {
            MVEL.eval("i = 0; i < 99 dksadlka", new HashMap());
        }
        catch (Exception e) {
            return;
        }
        assertTrue(false);
    }

    public void testShouldFail2() {
        try {
            MVEL.compileExpression("i = 0; i < 99 dksadlka");
        }
        catch (Exception e) {
            return;
        }
        assertTrue(false);
    }

    public void testShouldFail3() {
        try {
            MVEL.compileExpression("def foo() { 'bar' }; foo(123);");
        }
        catch (Exception e) {
            e.printStackTrace();
            return;
        }
        assertTrue(false);
    }

    public void testShouldFail4() {
        try {
            MVEL.eval("hour zzz", createTestMap());
        }
        catch (Exception e) {
            e.printStackTrace();
            return;
        }
        assertTrue(false);
    }

    public void testShouldFail5() {
        try {
            MVEL.eval("[");
        }
        catch (Exception e) {
            e.printStackTrace();
            return;
        }
        assertTrue(false);
    }
}

@@ -328,42 +328,53 @@
     
- System.out.println(e);%0A        %7D%0A
+return;%0A        %7D%0A%0A        assertTrue(false);
 %0A   
@@ -974,41 +974,8 @@
 ) %7B%0A
-            e.printStackTrace();%0A
     
@@ -1180,41 +1180,8 @@
 ) %7B%0A
-            e.printStackTrace();%0A
     
@@ -1374,28 +1374,191 @@
     
-e.printStackTrace();
+return;%0A        %7D%0A        assertTrue(false);%0A    %7D%0A%0A    public void testShouldFail6() %7B%0A        try %7B%0A            MVEL.eval(%22new int%5B%5D %7B1.5%7D%22);%0A        %7D%0A        catch (Exception e) %7B
 %0A   

check in minor regression