package com.inet.lib.less;

import org.junit.Test;

import static org.junit.Assert.*;

public class ErrorTest {

    @Test
    public void parenthesisWithComma() {
        Less.compile( null, ".a { a: (red); }", false );
        try {
            Less.compile( null, ".a { a: (red,green); }", false );
            fail( "LessException expected" );
        } catch( LessException lex ) {
            String message = lex.getMessage();
            assertEquals( "Unrecognised input", message.substring( 0, message.indexOf( '\n' ) ) );
        }
    }

    @Test
    public void maxDiffTypes() {
        try {
            Less.compile( null, ".a { a: max( 1px, 1% ); }", false );
            fail( "LessException expected" );
        } catch( LessException lex ) {
            String message = lex.getMessage();
            assertEquals( "Incompatible types", message.substring( 0, message.indexOf( '\n' ) ) );
        }
    }

    @Test
    public void minDiffTypes() {
        try {
            Less.compile( null, ".a { a: min( 1px, 1% ); }", false );
            fail( "LessException expected" );
        } catch( LessException lex ) {
            String message = lex.getMessage();
            assertEquals( "Incompatible types", message.substring( 0, message.indexOf( '\n' ) ) );
        }
    }
}

@@ -1291,11 +1291,329 @@
  %7D%0A    %7D
+%0A%0A    /**%0A     * test for a JIT error%0A     * https://github.com/i-net-software/jlessc/issues/20%0A     */%0A    @Test%0A    public void colorConst() %7B%0A        for( int i = 0; i %3C 10000; i++ ) %7B%0A            assertEquals( Integer.toString( i ), %22.t%7Bc:#d3d3d3%7D%22, Less.compile( null, %22.t%7Bc:lightgrey%7D%22, true ) );%0A        %7D%0A    %7D
 %0A%7D%0A

Test for JIT error see #20