Browse Source

Added a test for casts

ceriel 37 years ago
parent
commit
cb22dd8e6a
2 changed files with 7 additions and 0 deletions
  1. 5 0
      lang/cem/ctest/ctconv/conv.c
  2. 2 0
      lang/cem/ctest/ctconv/conv.cem.g

+ 5 - 0
lang/cem/ctest/ctconv/conv.c

@@ -99,6 +99,11 @@ t1() {
 	printf("\t\t\t\t\tfloat %f\n",f) ;
 #endif
 
+	printf("Casts from long\n");
+	l = 75000;
+	printf("\tchar %5d, int %d, unsigned short %6o, long %11ld\n",
+		(char) l,(int) l,(unsigned short)l ,l) ;
+
 #ifndef NOFLOAT
 	printf("From float\n") ;
 	f = 121.5 ;

+ 2 - 0
lang/cem/ctest/ctconv/conv.cem.g

@@ -21,6 +21,8 @@ From integer
 From long
 	char    -3, int     -3, unsigned 37777777775, long          -3
 					float -3.000000
+Casts from long
+	char    -8, int 75000, unsigned short  22370, long       75000
 From float
 	char   121, int    121, unsigned    171, long         121, float 121.500000
 	char     0, int      0, unsigned      0, long           0, float 0.000100