sw-examples: test-if.sw3

Raw file here.
-- a test case for the new if/else statement:

op |if test> #=>
    the |start> => |true>
    the |next> => |true>
    if( |yes> ):
        the |rule 1> => |it worked!>
        the |rule 2> => |I hope ... >
    else:
        the |rule 3> => |else works too!>
    end:
    the |end> => |not quite yet ... >
    if( |yes> ):
        the |rule 4> => |and this too?>
        the |rule 5> => |blah ... >
        if( |yes> ):
            the |rule 6> => |more blah ... >
            the |rule 7> => |... >
            if( |yes> ):
                the |rule 8> => |even more nested!>
                the |rule 9> => |... >
            end:
        end:
    end:
    the |real end> => |true>


-- this now works!
-- we had a bug in the equality operator ==
if-test (*,*) #=>
    if( |__self1> == |__self2> ):
        print |it worked!>
    else:
        print |it failed!>
    end:


-- this correctly returns it worked.
if-test2 (*,*) #=>
    if( is-equal( |__self1>, |__self2>) ):
        print |it worked!>
    else:
        print |it failed!>
    end:


-- test if operators other than == and != are effected by the bug:
-- nope, they are fine.
if-test3 (*,*) #=>
    if( |__self1> < |__self2> ):
        print |is less than>
    else:
        print |is not less than>
    end:




Home