% Autogenerated with DRAKON Editor 1.27

-module(erltest).
-export([mult/2, run/0, switch/1]).

assert(Expected, Actual) ->
    % item 20
    case Expected == Actual of true -> 
        % item 19
        void
    ; false ->
        % item 42
        io:format("expected: ~w~n", [Expected]),
        io:format("actual: ~w~n", [Actual]),
        % item 23
        throw("assert failed")
    end
.

mult(Left, Right) ->
    % item 12
    Left * Right
.

nested_if(X, Y, Z) ->
    % item 31
    case X == 10 of true -> 
        % item 30
        x
    ; false ->
        % item 33
        case Y == 10 of true -> 
            % item 37
            y
        ; false ->
            % item 35
            case Z == 10 of true -> 
                % item 38
                z
            ; false ->
                % item 40
                none
            end
        end
    end
.

run() ->
    % item 6
    assert(15, mult(5, 3)),
    % item 41
    assert(x, nested_if(10, 20, 30)),
    assert(y, nested_if(20, 10, 30)),
    assert(z, nested_if(30, 20, 10)),
    assert(none, nested_if(40, 20, 30)),
    assert(x, nested_if(10, 10, 10)),
    % item 76
    assert({10, 100, 20}, sil_if(10, 10, 20)),
    assert({10, 200, 20}, sil_if(10, -10, 20)),
    % item 93
    assert(one, switch(1)),
    assert(two, switch(2)),
    assert(three, switch(3)),
    % item 24
    success
.

sil_if(X, Y, Z) ->
    % item 57
    case X > 0 of true -> 
        % item 58
        X2 = X,
        % item 65
        case Y > 0 of true -> 
            % item 66
            Y2 = 100,
            Z2 = Z
        ; false ->
            % item 67
            Y2 = 200,
            Z2 = Z
        end
    ; false ->
        % item 59
        X2 = -X,
        % item 70
        case Z > 0 of true -> 
            % item 71
            Z2 = 1000,
            Y2 = Y
        ; false ->
            % item 72
            Z2 = 3000,
            Y2 = Y
        end
    end,
    % item 75
    {X2, Y2, Z2}
.

switch(X) ->
    case X of
        1 ->
            % item 90
            one
        ;
        2 ->
            % item 91
            two
        ;
        3 ->
            % item 92
            three
    end
.


