| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | ! (c)Joe Groff bsd license | 
					
						
							| 
									
										
										
										
											2010-01-22 06:39:56 -05:00
										 |  |  | USING: accessors arrays compiler.test continuations generalizations | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | kernel kernel.private locals math.vectors.conversion math.vectors.simd | 
					
						
							| 
									
										
										
										
											2010-05-18 22:59:07 -04:00
										 |  |  | sequences stack-checker tools.test sequences.generalizations ;
 | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | FROM: alien.c-types => char uchar short ushort int uint longlong ulonglong float double ;
 | 
					
						
							|  |  |  | IN: math.vectors.conversion.tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ERROR: optimized-vconvert-inconsistent | 
					
						
							|  |  |  |     unoptimized-result | 
					
						
							|  |  |  |     optimized-result ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-19 01:16:11 -04:00
										 |  |  | MACRO:: test-vconvert ( from-type to-type -- quot )
 | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  |     [ from-type to-type vconvert ] :> quot | 
					
						
							|  |  |  |     quot infer :> effect | 
					
						
							|  |  |  |     effect in>> length :> inputs | 
					
						
							|  |  |  |     effect out>> length :> outputs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     inputs from-type <array> :> declaration | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         inputs narray | 
					
						
							|  |  |  |         [ quot with-datastack ] | 
					
						
							|  |  |  |         [ [ [ declaration declare quot call ] compile-call ] with-datastack ] bi
 | 
					
						
							| 
									
										
										
										
											2015-08-13 19:13:05 -04:00
										 |  |  |         2dup = [ optimized-vconvert-inconsistent ] unless
 | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  |         drop outputs firstn | 
					
						
							|  |  |  |     ] ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-06 18:42:36 -04:00
										 |  |  | [ uint-4{ 5 1 2 6 } int-4 float-4 vconvert ] | 
					
						
							|  |  |  | [ bad-vconvert-input? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ int-4{ 1 2 3 4 } uint-4{ 5 1 2 6 } int-4 short-8 vconvert ] | 
					
						
							|  |  |  | [ bad-vconvert-input? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ uint-4{ 1 2 3 4 } int-4{ 5 1 2 6 } int-4 short-8 vconvert ] | 
					
						
							|  |  |  | [ bad-vconvert-input? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ uint-4{ 5 1 2 6 } int-4 longlong-2 vconvert ] | 
					
						
							|  |  |  | [ bad-vconvert-input? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { float-4{ -5.0 1.0 2.0 6.0 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ int-4{ -5 1 2 6 } int-4 float-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { int-4{ -5 1 2 6 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ float-4{ -5.0 1.0 2.0 6.0 } float-4 int-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { int-4{ -5 1 2 6 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ float-4{ -5.0 1.0 2.3 6.7 } float-4 int-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { double-2{ -5.0 1.0 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ longlong-2{ -5 1 } longlong-2 double-2 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { longlong-2{ -5 1 } } | 
					
						
							| 
									
										
										
										
											2009-11-24 23:53:40 -05:00
										 |  |  | [ double-2{ -5.0 1.0 } double-2 longlong-2 test-vconvert ] unit-test | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! TODO we should be able to do double->int pack | 
					
						
							| 
									
										
										
										
											2009-11-24 23:53:40 -05:00
										 |  |  | ! [ int-4{ -5 1 12 34 } ] | 
					
						
							|  |  |  | [ double-2{ -5.0 1.0 } double-2{ 12.0 34.0 } double-2 int-4 test-vconvert ] | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ error>> bad-vconvert? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { float-4{ -1.25 2.0 3.0 -4.0 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ double-2{ -1.25 2.0 } double-2{ 3.0 -4.0 } double-2 float-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { int-4{ -1 2 3 -4 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ longlong-2{ -1 2 } longlong-2{ 3 -4 } longlong-2 int-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { short-8{ -1 2 3 -32768 5 32767 -7 32767 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ int-4{ -1 2 3 -40000 } int-4{ 5 60000 -7 80000 } int-4 short-8 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { short-8{ -1 2 3 -32768 5 32767 -7 32767 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ | 
					
						
							| 
									
										
										
										
											2009-11-24 23:53:40 -05:00
										 |  |  |     int-4{ -1 2 3 -40000 } | 
					
						
							|  |  |  |     int-4{ 5 60000 -7 80000 } int-4 short-8 test-vconvert | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { ushort-8{ 0 2 3 0 5 60000 0 65535 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ int-4{ -1 2 3 -40000 } int-4{ 5 60000 -7 80000 } int-4 ushort-8 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { ushort-8{ 65535 2 3 65535 5 60000 65535 65535 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ uint-4{ -1 2 3 -40000 } uint-4{ 5 60000 -7 80000 } uint-4 ushort-8 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ uint-4{ -1 2 3 -40000 } uint-4{ 5 60000 -7 80000 } uint-4 short-8 test-vconvert ] | 
					
						
							|  |  |  | [ error>> bad-vconvert? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { ushort-8{ 0 1 2 3 128 129 130 131 } ushort-8{ 4 5 6 7 132 133 134 135 } } | 
					
						
							| 
									
										
										
										
											2009-10-16 15:25:33 -04:00
										 |  |  | [ | 
					
						
							|  |  |  |     uchar-16{ 0 1 2 3 128 129 130 131 4 5 6 7 132 133 134 135 } | 
					
						
							|  |  |  |     uchar-16 ushort-8 test-vconvert | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { double-2{ -1.25 2.0 } double-2{ 3.0 -4.0 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ float-4{ -1.25 2.0 3.0 -4.0 } float-4 double-2 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { int-4{ -1 2 3 -4 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ int-4{ -1 2 3 -4 } int-4 int-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { longlong-2{ -1 2 } longlong-2{ 3 -4 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ int-4{ -1 2 3 -4 } int-4 longlong-2 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ int-4{ -1 2 3 -4 } int-4 ulonglong-2 test-vconvert ] | 
					
						
							|  |  |  | [ error>> bad-vconvert? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { ulonglong-2{ 1 2 } ulonglong-2{ 3 4 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | [ uint-4{ 1 2 3 4 } uint-4 ulonglong-2 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { longlong-2{ 1 2 } longlong-2{ 3 4 } } | 
					
						
							| 
									
										
										
										
											2009-11-24 23:53:40 -05:00
										 |  |  | [ uint-4{ 1 2 3 4 } uint-4 longlong-2 test-vconvert ] unit-test | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { int-4{ 1 2 -3 -4 } int-4{ 5 -6 7 -8 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 21:21:08 -04:00
										 |  |  | [ short-8{ 1 2 -3 -4 5 -6 7 -8 } short-8 int-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { uint-4{ 1 2 3 4 } uint-4{ 5 6 7 8 } } | 
					
						
							| 
									
										
										
										
											2009-10-06 21:21:08 -04:00
										 |  |  | [ ushort-8{ 1 2 3 4 5 6 7 8 } ushort-8 uint-4 test-vconvert ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-03 12:39:59 -04:00
										 |  |  | { longlong-2{ 1 2 } longlong-2{ 3 4 } } | 
					
						
							| 
									
										
										
										
											2009-11-24 23:53:40 -05:00
										 |  |  | [ uint-4{ 1 2 3 4 } uint-4 longlong-2 test-vconvert ] unit-test | 
					
						
							| 
									
										
										
										
											2009-10-06 15:00:16 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! TODO we should be able to do multi-tier pack/unpack | 
					
						
							|  |  |  | ! [ longlong-2{ 1 2 } longlong-2{ 3 4 } longlong-2{ 5 6 } longlong-2{ 7 8 } ] | 
					
						
							|  |  |  | [ ushort-8{ 1 2 3 4 5 6 7 8 } ushort-8 longlong-2 test-vconvert ] | 
					
						
							|  |  |  | [ error>> bad-vconvert? ] must-fail-with | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! [ ushort-8{ 1 2 3 4 5 6 7 8 } ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     longlong-2{ 1 2 } | 
					
						
							|  |  |  |     longlong-2{ 3 4 } | 
					
						
							|  |  |  |     longlong-2{ 5 6 } | 
					
						
							|  |  |  |     longlong-2{ 7 8 } | 
					
						
							|  |  |  |     longlong-2 ushort-8 test-vconvert | 
					
						
							|  |  |  | ] | 
					
						
							|  |  |  | [ error>> bad-vconvert? ] must-fail-with |