//_Header //******************************************************************* // NOVA CONTROL SYSTEM --- Lawrence Livermore Laboratory // // Copyright 1984 by The Regents of the University of California //******************************************************************* // //_Module_Name: MTHCMPTST _File: [VCLIB.TEST.LSI]MTHCMPTST.PRX // //_Description: // Arithmatic comparison test //_Call: //_Remarks: // Test #1 : A = B // Test #2 : A <> B // Test #3 : A < B // Test #4 : A <= B // Test #5 : A > B // Test #6 : A >= B // Condition #1 : A and B zero // Condition #2 : A zero, B min positive // Condition #3 : A zero, B min negitive // Condition #4 : A and B small positive // Condition #5 : A and B large positive // Condition #6 : A and B small negitive // Condition #7 : A and B large negitive // Condition #8 : A min positive, B max positive // Condition #9 : A min negitive, B max negitive // Condition #10 : A max positive, B max negitive // Condition #11 : A and B min positive // Condition #12 : A and B min negitive // Condition #13 : A and B max positive // Condition #14 : A and B max negitive //_Identifier: { none } //******************************************************************* //_Author: T. A. SHERMAN _Creation_Date: 7-OCT-1984 //_Revisions: // 1.000 7-OCT-1984 TAS Initial Key-in. //******************************************************************* //_End Main Module MTHCMPTST Use TEXTIO Declare //Boundary values Zero = 0 Min_pos_integer = 1 Min_neg_integer = -1 Max_pos_4_bit_integer = 7 Max_neg_4_bit_integer = -8 Max_pos_8_bit_integer = 127 Max_neg_8_bit_integer = -128 Max_pos_12_bit_integer = 2047 Max_neg_12_bit_integer = -2048 Max_pos_16_bit_integer = 32767 Max_neg_16_bit_integer = -32768 Max_pos_20_bit_integer = 524287 Max_neg_20_bit_integer = -524288 Max_pos_24_bit_integer = 8388607 Max_neg_24_bit_integer = -8388608 Max_pos_28_bit_integer = 134217727 Max_neg_28_bit_integer = -134217728 Max_pos_32_bit_integer = 16!7FFFFFFF Max_neg_32_bit_integer = 16!80000000 // Max_pos_32_bit_integer = 2147483647 // Max_neg_32_bit_integer = -2147483648 Max_pos_64_bit_integer = 16!7FFFFFFFFFFFFFFF Max_neg_64_bit_integer = 16!8000000000000000 //Objects A_4 : static 4 bit integer // Half byte object B_4 : static 4 bit integer A_8 : static 8 bit integer // One byte object B_8 : static 8 bit integer A_12 : static 12 bit integer // One and a half byte object B_12 : static 12 bit integer A_16 : static 16 bit integer // One word object ( two bytes ) B_16 : static 16 bit integer A_20 : static 20 bit integer // Two and a half byte object B_20 : static 20 bit integer A_24 : static 24 bit integer // Three byte object B_24 : static 24 bit integer A_28 : static 28 bit integer // Three and a half byte object B_28 : static 28 bit integer A_32 : static 32 bit integer // Two word object ( four bytes ) B_32 : static 32 bit integer A_64 : static 64 bit integer B_64 : static 64 bit integer Error_count : static integer initially 0 EndDeclare Procedure Pass () EndProcedure Procedure Failure ( size: integer, test: integer, cond: integer ) Out_string ( TTY, "Failure -- " ) Out_integer ( TTY, size ) Out_string ( TTY, " Bit Arithmatic comparison test #" ) Out_integer ( TTY, test ) Out_string ( TTY, ", condition #" ) Out_integer ( TTY, cond ) Out_record ( TTY ) Error_count *= +1 EndProcedure TTY_line ( "64 Bit Arithmatic Comparison Tests" ) // 64 bit tests // Condition #1 : A and B zero A_64 := zero B_64 := zero // Test #1 : A = B If A_64 = B_64 do Pass () Otherwise Failure ( 64,1,1 ) EndIf // Test #2 : A <> B If A_64 <> B_64 do Failure ( 64,2,1 ) Otherwise Pass () EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,1 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,1 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,1 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,1 ) EndIf // Condition #2 : A zero, B min positive A_64 := zero B_64 := min_pos_integer // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,2 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,2 ) EndIf // Test #3 : A < B If A_64 < B_64 do Pass () Otherwise Failure ( 64,3,2 ) EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,2 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,2 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Failure ( 64,6,2 ) Otherwise Pass () EndIf // Condition #3 : A zero, B min negitive A_64 := zero B_64 := min_neg_integer // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,3 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,3 ) EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,3 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Failure ( 64,4,3 ) Otherwise Pass () EndIf // Test #5 : A > B If A_64 > B_64 do Pass () Otherwise Failure ( 64,5,3 ) EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,3 ) EndIf // Condition #4 : A and B small positive A_64 := min_pos_integer B_64 := min_pos_integer + 1 // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,4 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,4 ) EndIf // Test #3 : A < B If A_64 < B_64 do Pass () Otherwise Failure ( 64,3,4 ) EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,4 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,4 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Failure ( 64,6,4 ) Otherwise Pass () EndIf // Condition #5 : A and B large positive A_64 := max_pos_64_bit_integer B_64 := max_pos_64_bit_integer - 1 // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,5 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,5 ) EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,5 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Failure ( 64,4,5 ) Otherwise Pass () EndIf // Test #5 : A > B If A_64 > B_64 do Pass () Otherwise Failure ( 64,5,5 ) EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,5 ) EndIf // Condition #6 : A and B small negitive A_64 := min_neg_integer B_64 := min_neg_integer - 1 // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,6 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,6 ) EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,6 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Failure ( 64,4,6 ) Otherwise Pass () EndIf // Test #5 : A > B If A_64 > B_64 do Pass () Otherwise Failure ( 64,5,6 ) EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,6 ) EndIf // Condition #7 : A and B large negitive A_64 := max_neg_64_bit_integer B_64 := max_neg_64_bit_integer + 1 // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,7 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,7 ) EndIf // Test #3 : A < B If A_64 < B_64 do Pass () Otherwise Failure ( 64,3,7 ) EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,7 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,7 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Failure ( 64,6,7 ) Otherwise Pass () EndIf // Condition #8 : A min positive, B max positive A_64 := min_pos_integer B_64 := max_pos_64_bit_integer // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,8 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,8 ) EndIf // Test #3 : A < B If A_64 < B_64 do Pass () Otherwise Failure ( 64,3,8 ) EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,8 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,8 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Failure ( 64,6,8 ) Otherwise Pass () EndIf // Condition #9 : A min negitive, B max negitive A_64 := min_neg_integer B_64 := max_neg_64_bit_integer // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,9 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,9 ) EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,9 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Failure ( 64,4,9 ) Otherwise Pass () EndIf // Test #5 : A > B If A_64 > B_64 do Pass () Otherwise Failure ( 64,5,9 ) EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,9 ) EndIf // Condition #10 : A max positive, B max negitive A_64 := max_pos_64_bit_integer B_64 := max_neg_64_bit_integer // Test #1 : A = B If A_64 = B_64 do Failure ( 64,1,10 ) Otherwise Pass () EndIf // Test #2 : A <> B If A_64 <> B_64 do Pass () Otherwise Failure ( 64,2,10 ) EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,10 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Failure ( 64,4,10 ) Otherwise Pass () EndIf // Test #5 : A > B If A_64 > B_64 do Pass () Otherwise Failure ( 64,5,10 ) EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,10 ) EndIf // Condition #11 : A and B min positive A_64 := min_pos_integer B_64 := min_pos_integer // Test #1 : A = B If A_64 = B_64 do Pass () Otherwise Failure ( 64,1,11 ) EndIf // Test #2 : A <> B If A_64 <> B_64 do Failure ( 64,2,11 ) Otherwise Pass () EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,11 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,11 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,11 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,11 ) EndIf // Condition #12 : A and B min negitive A_64 := min_neg_integer B_64 := min_neg_integer // Test #1 : A = B If A_64 = B_64 do Pass () Otherwise Failure ( 64,1,12 ) EndIf // Test #2 : A <> B If A_64 <> B_64 do Failure ( 64,2,12 ) Otherwise Pass () EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,12 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,12 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,12 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,12 ) EndIf // Condition #13 : A and B max positive A_64 := max_pos_64_bit_integer B_64 := max_pos_64_bit_integer // Test #1 : A = B If A_64 = B_64 do Pass () Otherwise Failure ( 64,1,13 ) EndIf // Test #2 : A <> B If A_64 <> B_64 do Failure ( 64,2,13 ) Otherwise Pass () EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,13 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,13 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,13 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,13 ) EndIf // Condition #14 : A and B max negitive A_64 := max_neg_64_bit_integer B_64 := max_neg_64_bit_integer // Test #1 : A = B If A_64 = B_64 do Pass () Otherwise Failure ( 64,1,14 ) EndIf // Test #2 : A <> B If A_64 <> B_64 do Failure ( 64,2,14 ) Otherwise Pass () EndIf // Test #3 : A < B If A_64 < B_64 do Failure ( 64,3,14 ) Otherwise Pass () EndIf // Test #4 : A <= B If A_64 <= B_64 do Pass () Otherwise Failure ( 64,4,14 ) EndIf // Test #5 : A > B If A_64 > B_64 do Failure ( 64,5,14 ) Otherwise Pass () EndIf // Test #6 : A >= B If A_64 >= B_64 do Pass () Otherwise Failure ( 64,6,14 ) EndIf Out_string ( TTY, "Errors detected: " ) Out_integer ( TTY, error_count ) Out_record ( TTY ) EndModule