| 
									
										
										
										
											2008-03-01 17:00:45 -05:00
										 |  |  | IN: alien.structs.tests | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | USING: alien alien.syntax alien.c-types kernel tools.test | 
					
						
							| 
									
										
										
										
											2008-04-20 06:15:46 -04:00
										 |  |  | sequences system libc words vocabs namespaces layouts ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | C-STRUCT: bar | 
					
						
							|  |  |  |     { "int" "x" } | 
					
						
							|  |  |  |     { { "int" 8 } "y" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 36 ] [ "bar" heap-size ] unit-test | 
					
						
							| 
									
										
										
										
											2008-08-31 08:45:33 -04:00
										 |  |  | [ t ] [ \ <displaced-alien> "bar" c-type-getter memq? ] unit-test | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-04-20 06:15:46 -04:00
										 |  |  | C-STRUCT: align-test | 
					
						
							|  |  |  |     { "int" "x" } | 
					
						
							|  |  |  |     { "double" "y" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | os winnt? cpu x86? and [ | 
					
						
							|  |  |  |     [ 16 ] [ "align-test" heap-size ] unit-test | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     cell 4 = [ | 
					
						
							|  |  |  |         C-STRUCT: one | 
					
						
							|  |  |  |         { "long" "a" } { "double" "b" } { "int" "c" } ;
 | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |         [ 24 ] [ "one" heap-size ] unit-test | 
					
						
							|  |  |  |     ] when
 | 
					
						
							|  |  |  | ] when
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-22 18:47:48 -04:00
										 |  |  | CONSTANT: MAX_FOOS 30
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | C-STRUCT: foox | 
					
						
							|  |  |  |     { { "int" MAX_FOOS } "x" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 120 ] [ "foox" heap-size ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | C-UNION: barx | 
					
						
							|  |  |  |     { "int" MAX_FOOS } | 
					
						
							|  |  |  |     "float" ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 120 ] [ "barx" heap-size ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | "help" vocab [ | 
					
						
							| 
									
										
										
										
											2008-11-30 23:21:37 -05:00
										 |  |  |     "print-topic" "help" lookup "help" set
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  |     [ ] [ \ foox-x "help" get execute ] unit-test | 
					
						
							|  |  |  |     [ ] [ \ set-foox-x "help" get execute ] unit-test | 
					
						
							|  |  |  | ] when
 | 
					
						
							| 
									
										
										
										
											2009-01-28 02:58:57 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | C-STRUCT: nested | 
					
						
							|  |  |  |     { "int" "x" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | C-STRUCT: nested-2 | 
					
						
							|  |  |  |     { "nested" "y" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ 4 ] [ | 
					
						
							|  |  |  |     "nested-2" <c-object> | 
					
						
							|  |  |  |     "nested" <c-object> | 
					
						
							|  |  |  |     4 over set-nested-x | 
					
						
							|  |  |  |     over set-nested-2-y | 
					
						
							|  |  |  |     nested-2-y | 
					
						
							|  |  |  |     nested-x | 
					
						
							|  |  |  | ] unit-test |