#*

@test logical.vm

This template is used for Velocity regression testing.
If you alter this template make sure you change the
corresponding comparison file so that the regression
test doesn't fail incorrectly.

*#

#set($foo = 5)

#if ($foo gt 1)
    \$foo is greater then 1
#end

#if ($foo lt 10)
    \$foo is less than 10
#end

#if ($foo ge 5)
    \$foo is great than or equal to 5
#end

#if ($foo le 5)
    \$foo is less than or equal to 5
#end

#set($foo = false)

#if ( not ($foo eq true))
    foo is false
#end

--

#set($t = true)
#set($f = false)

Logical OR :

#if($t or $f)
 right
#else
 wrong
#end

#if( not ($f or $t) )
 wrong
#else
 right
#end

#if( $null or $t )
 right
#else
 wrong
#end

#if( $t or $null )
 right
#else
 wrong
#end

#if( $f or $null)
 wrong
#else
 right
#end

#if( $null or $null )
 wrong
#else
 right
#end

Logical AND :

#if( $t and $t)
 right
#else
 wrong
#end

#if( $f and $f )
 wrong
#else
 right
#end

#if( not ($f and $f) )
 right
#else
 wrong
#end

#if( $t and $f )
 wrong
#else
 right
#end

#if( $t and $null )
 wrong
#else
 right
#end

#if( $null and $t )
 wrong
#else
 right
#end

#if( $f and $null )
 wrong
#else
 right
#end

#if( not ($null and $null) )
 right
#else
 wrong
#end

----------
equivalence
-----------

#set($int = 1)
#set($str = "str")
#set($bool = true)

#if( $int eq $str)
wrong
#else
right
#end

#if( $int eq 1 )
right
#else
wrong
#end

#if ( $int eq 2 )
wrong
#else
right
#end

#if( $str eq 2 )
wrong
#else
right
#end

#if( $str eq "str")
right
#else
wrong
#end

#if( $str eq $nonexistantreference )
wrong
#else
right
#end

#if( $str eq $bool )
wrong
#else
right
#end

#if ($bool eq true )
right
#else
wrong
#end

#if( $bool eq false )
wrong
#else
right
#end

-----------
comparisons
-----------
#set($int = 1)
#set($str = "str")
#set($bool = true)

#if( $int gt 0 )
right
#else
wrong
#end

#if( $str gt 0 )
wrong
#else
right
#end

#if( $nonexistant gt 0 )
wrong
#else
right
#end

#if( $int ge 0 )
right
#else
wrong
#end

#if( $str ge 0 )
wrong
#else
right
#end

#if( $nonexistant ge 0 )
wrong
#else
right
#end

#if( $int lt 10 )
right
#else
wrong
#end

#if( $str lt 10 )
wrong
#else
right
#end

#if( $nonexistant lt 10 )
wrong
#else
right
#end

#if( $int le 10 )
right
#else
wrong
#end

#if( $str le 10 )
wrong
#else
right
#end

#if( $nonexistant le 10 )
wrong
#else
right
#end

----------------------
goofy but legal stuff
----------------------
#set($lala = ( false or true ) )
Should equal true : $lala

#set($fofo = ( true and true ) )
Should equal true : $fofo

#set($fofo = ( true and ( false or true ) ) )
Should equal true : $fofo

#set($fofo = ( ($t or $f) and $t))
Should equal true : $fofo


#set($x = not true)

#if($x eq false)
right
#else
wrong
#end

#set($y = not $x)

#if($y eq true)
right
#else
wrong
#end

Test to see if we can do logical assignment from any expression

#set($val = (3 eq 3))
#if($val eq true)
right
#else
wrong
#end

#set($val = (1 lt 2))
#if( $val eq true)
right
#else
wrong
#end


#set($val = (1 le 2))
#if( $val eq true)
right
#else
wrong
#end


#set($val = (7 gt 2))
#if( $val eq true)
right
#else
wrong
#end

#set($val = (7 ge 2))
#if( $val eq true)
right
#else
wrong
#end

#set($val = ( 1 ne 2))
#if( $val eq true)
right
#else
wrong
#end
