CASE statement

This test case it part of the test suite proposed for new devices.

Test case ID: R0035
Language: ST

Code:
tests2/t0035.st
TYPE
    SPEED : ( SLOW , MEDIUM , FAST );
END_TYPE;

(* CASE STATEMENT *)

PROGRAM Test_R0035 

VAR
    RPM_Setting : SPEED;
    RPM: INT;
    X,Y,Z ,W : INT;
        B1:BYTE;
END_VAR


    X := 200;
    
    CASE X OF
        SINT#100 :           Y := 1; 
        -101 .. 102:          Y := 2;
        123, 124:            Y := 3;   
        125,199..201,300:    Y := 4;  (* MATCH *)
        200 :       Y := 5;     (* NO match, the previous wins*)
        ELSE        Y := 6;
    END_CASE;
    
    CASE RPM_Setting OF
        SPEED#MEDIUM :      
              RPM := 100;
        SPEED#SLOW, SPEED#FAST :  
              RPM := 300;  
              RPM := RPM/2;  (* this matches *)
        ELSE                     
              RPM := 0;
    END_CASE;

 
    
    Z := 1000;
    
    CASE Y OF
        1 :        ; 
        2,-3,4:     
            Z := 2000;    (* MATCH *)    
            CASE Y OF
               2 : Z := 4000;
              ELSE Z := 5000;   (* MATCH *)
            END_CASE;            
        5:  Z := 8000;   
    END_CASE;

        (* we accept bit types *)
    B1 := 2;
    CASE B1 OF
            1 : W := 10;
            2:  W := 20;
            ELSE W:=30;
       END_CASE;

_GEB_ASSERT_(RPM = 150);
_GEB_ASSERT_(W = 20);
_GEB_ASSERT_(X = 200);
_GEB_ASSERT_(Y = 4);
_GEB_ASSERT_(Z = 5000);

END_PROGRAM