RegressionTests__UninterpretedBytesTest.st
branchjv
changeset 1500 d406a10b2965
parent 1499 26a16a04219b
parent 1447 2351db93aa5b
child 1567 e17701a073f9
equal deleted inserted replaced
1499:26a16a04219b 1500:d406a10b2965
    65     self assert:(bytes byteAt:1) == 16rFF.
    65     self assert:(bytes byteAt:1) == 16rFF.
    66     self assert:(bytes signedByteAt:1) == -1.
    66     self assert:(bytes signedByteAt:1) == -1.
    67 
    67 
    68     "/ check immutablility checks
    68     "/ check immutablility checks
    69     bytes :=  #[ 16rFF 16r00 ] beImmutable.
    69     bytes :=  #[ 16rFF 16r00 ] beImmutable.
    70     self 
    70     self
    71         should:[        
    71 	should:[
    72             bytes byteAt:1 put:0
    72 	    bytes byteAt:1 put:0
    73         ]
    73 	]
    74         raise:NoModificationError.
    74 	raise:NoModificationError.
    75     self assert:(bytes at:1) == 16rFF.
    75     self assert:(bytes at:1) == 16rFF.
    76 
    76 
    77     "/ check bounds checks
    77     "/ check bounds checks
    78     #(3 0 -1 -2) do:[:badIndex |
    78     #(3 0 -1 -2) do:[:badIndex |
    79         self 
    79 	self
    80             should:[        
    80 	    should:[
    81                 #[ 16rFF 16r00 ] byteAt:badIndex
    81 		#[ 16rFF 16r00 ] byteAt:badIndex
    82             ]
    82 	    ]
    83             raise:SubscriptOutOfBoundsError.
    83 	    raise:SubscriptOutOfBoundsError.
    84 
    84 
    85         self 
    85 	self
    86             should:[        
    86 	    should:[
    87                 #[ 16rFF 16r00 ] signedByteAt:badIndex
    87 		#[ 16rFF 16r00 ] signedByteAt:badIndex
    88             ]
    88 	    ]
    89             raise:SubscriptOutOfBoundsError.
    89 	    raise:SubscriptOutOfBoundsError.
    90 
    90 
    91         self 
    91 	self
    92             should:[        
    92 	    should:[
    93                 #[ 16rFF 16r00 ] byteAt:badIndex put:0
    93 		#[ 16rFF 16r00 ] byteAt:badIndex put:0
    94             ]
    94 	    ]
    95             raise:SubscriptOutOfBoundsError.
    95 	    raise:SubscriptOutOfBoundsError.
    96 
    96 
    97         self 
    97 	self
    98             should:[        
    98 	    should:[
    99                 #[ 16rFF 16r00 ] signedByteAt:badIndex put:0
    99 		#[ 16rFF 16r00 ] signedByteAt:badIndex put:0
   100             ]
   100 	    ]
   101             raise:SubscriptOutOfBoundsError.
   101 	    raise:SubscriptOutOfBoundsError.
   102     ]
   102     ]
   103 
   103 
   104     "
   104     "
   105      self run:#test00_byteAccess
   105      self run:#test00_byteAccess
   106     "
   106     "
   107 !
   107 !
   108 
   108 
   109 test01_int16Access
   109 test01_int16Access
   110     |check bytes|
   110     |check bytes|
   111 
   111 
   112     check := 
   112     check :=
   113         [:bytes1 :bytes2 |
   113 	[:bytes1 :bytes2 |
   114             |wBytes|
   114 	    |wBytes|
   115 
   115 
   116             "/ bytes1 := #[ 16r10 16r20 16r30 16r40 ].
   116 	    "/ bytes1 := #[ 16r10 16r20 16r30 16r40 ].
   117             self assert:(bytes1 unsignedInt16At:1 MSB:true)  = 16r1020.
   117 	    self assert:(bytes1 unsignedInt16At:1 MSB:true)  = 16r1020.
   118             self assert:(bytes1 unsignedInt16At:1 MSB:false) = 16r2010.
   118 	    self assert:(bytes1 unsignedInt16At:1 MSB:false) = 16r2010.
   119             self assert:(bytes1 unsignedInt16At:2 MSB:true)  = 16r2030.
   119 	    self assert:(bytes1 unsignedInt16At:2 MSB:true)  = 16r2030.
   120             self assert:(bytes1 unsignedInt16At:2 MSB:false) = 16r3020.
   120 	    self assert:(bytes1 unsignedInt16At:2 MSB:false) = 16r3020.
   121             self assert:(bytes1 unsignedInt16At:3 MSB:true)  = 16r3040.
   121 	    self assert:(bytes1 unsignedInt16At:3 MSB:true)  = 16r3040.
   122             self assert:(bytes1 unsignedInt16At:3 MSB:false) = 16r4030.
   122 	    self assert:(bytes1 unsignedInt16At:3 MSB:false) = 16r4030.
   123 
   123 
   124             self assert:(bytes1 signedInt16At:1 MSB:true)  = 16r1020.
   124 	    self assert:(bytes1 signedInt16At:1 MSB:true)  = 16r1020.
   125             self assert:(bytes1 signedInt16At:1 MSB:false) = 16r2010.
   125 	    self assert:(bytes1 signedInt16At:1 MSB:false) = 16r2010.
   126             self assert:(bytes1 signedInt16At:2 MSB:true)  = 16r2030.
   126 	    self assert:(bytes1 signedInt16At:2 MSB:true)  = 16r2030.
   127             self assert:(bytes1 signedInt16At:2 MSB:false) = 16r3020.
   127 	    self assert:(bytes1 signedInt16At:2 MSB:false) = 16r3020.
   128             self assert:(bytes1 signedInt16At:3 MSB:true)  = 16r3040.
   128 	    self assert:(bytes1 signedInt16At:3 MSB:true)  = 16r3040.
   129             self assert:(bytes1 signedInt16At:3 MSB:false) = 16r4030.
   129 	    self assert:(bytes1 signedInt16At:3 MSB:false) = 16r4030.
   130 
   130 
   131             "/ bytes2 := #[ 16rFF 16r7F 16r80 16r81 ].
   131 	    "/ bytes2 := #[ 16rFF 16r7F 16r80 16r81 ].
   132             self assert:(bytes2 unsignedInt16At:1 MSB:true)  = 16rFF7F.
   132 	    self assert:(bytes2 unsignedInt16At:1 MSB:true)  = 16rFF7F.
   133             self assert:(bytes2 unsignedInt16At:1 MSB:false) = 16r7FFF.
   133 	    self assert:(bytes2 unsignedInt16At:1 MSB:false) = 16r7FFF.
   134             self assert:(bytes2 unsignedInt16At:2 MSB:true)  = 16r7F80.
   134 	    self assert:(bytes2 unsignedInt16At:2 MSB:true)  = 16r7F80.
   135             self assert:(bytes2 unsignedInt16At:2 MSB:false) = 16r807F.
   135 	    self assert:(bytes2 unsignedInt16At:2 MSB:false) = 16r807F.
   136             self assert:(bytes2 unsignedInt16At:3 MSB:true)  = 16r8081.
   136 	    self assert:(bytes2 unsignedInt16At:3 MSB:true)  = 16r8081.
   137             self assert:(bytes2 unsignedInt16At:3 MSB:false) = 16r8180.
   137 	    self assert:(bytes2 unsignedInt16At:3 MSB:false) = 16r8180.
   138 
   138 
   139             self assert:(bytes2 signedInt16At:1 MSB:true)  = -129.  "/ 16rFF7F signExtendedShortValue
   139 	    self assert:(bytes2 signedInt16At:1 MSB:true)  = -129.  "/ 16rFF7F signExtendedShortValue
   140             self assert:(bytes2 signedInt16At:1 MSB:false) = 16r7FFF.
   140 	    self assert:(bytes2 signedInt16At:1 MSB:false) = 16r7FFF.
   141             self assert:(bytes2 signedInt16At:2 MSB:true)  = 16r7F80.
   141 	    self assert:(bytes2 signedInt16At:2 MSB:true)  = 16r7F80.
   142             self assert:(bytes2 signedInt16At:2 MSB:false) = -32641. "/ 16r807F signExtendedShortValue.
   142 	    self assert:(bytes2 signedInt16At:2 MSB:false) = -32641. "/ 16r807F signExtendedShortValue.
   143             self assert:(bytes2 signedInt16At:3 MSB:true)  = -32639. "/ 16r8081 signExtendedShortValue.
   143 	    self assert:(bytes2 signedInt16At:3 MSB:true)  = -32639. "/ 16r8081 signExtendedShortValue.
   144             self assert:(bytes2 signedInt16At:3 MSB:false) = -32384. "/ 16r8180 signExtendedShortValue.
   144 	    self assert:(bytes2 signedInt16At:3 MSB:false) = -32384. "/ 16r8180 signExtendedShortValue.
   145 
   145 
   146             wBytes := bytes2 copy.
   146 	    wBytes := bytes2 copy.
   147 
   147 
   148             wBytes unsignedInt16At:1 put:16r1020 MSB:false.
   148 	    wBytes unsignedInt16At:1 put:16r1020 MSB:false.
   149             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r1020.
   149 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r1020.
   150             self assert:(wBytes signedInt16At:1 MSB:false) = 16r1020.
   150 	    self assert:(wBytes signedInt16At:1 MSB:false) = 16r1020.
   151 
   151 
   152             wBytes unsignedInt16At:1 put:16r1020 MSB:true.
   152 	    wBytes unsignedInt16At:1 put:16r1020 MSB:true.
   153             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r2010.
   153 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r2010.
   154             self assert:(wBytes signedInt16At:1 MSB:false) = 16r2010.
   154 	    self assert:(wBytes signedInt16At:1 MSB:false) = 16r2010.
   155 
   155 
   156             wBytes unsignedInt16At:1 put:16rFFFE MSB:false.
   156 	    wBytes unsignedInt16At:1 put:16rFFFE MSB:false.
   157             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16rFFFE.
   157 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16rFFFE.
   158             self assert:(wBytes signedInt16At:1 MSB:false) = -2.
   158 	    self assert:(wBytes signedInt16At:1 MSB:false) = -2.
   159 
   159 
   160             wBytes unsignedInt16At:1 put:16rFFFE MSB:true.
   160 	    wBytes unsignedInt16At:1 put:16rFFFE MSB:true.
   161             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16rFEFF.
   161 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16rFEFF.
   162             self assert:(wBytes signedInt16At:1 MSB:false) = -257.  "/ 16rFEFF signExtendedShortValue
   162 	    self assert:(wBytes signedInt16At:1 MSB:false) = -257.  "/ 16rFEFF signExtendedShortValue
   163 
   163 
   164             wBytes signedInt16At:1 put:16r1020 MSB:false.
   164 	    wBytes signedInt16At:1 put:16r1020 MSB:false.
   165             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r1020.
   165 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r1020.
   166             self assert:(wBytes signedInt16At:1 MSB:false) = 16r1020.
   166 	    self assert:(wBytes signedInt16At:1 MSB:false) = 16r1020.
   167 
   167 
   168             wBytes signedInt16At:1 put:16r1020 MSB:true.
   168 	    wBytes signedInt16At:1 put:16r1020 MSB:true.
   169             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r2010.
   169 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16r2010.
   170             self assert:(wBytes signedInt16At:1 MSB:false) = 16r2010.
   170 	    self assert:(wBytes signedInt16At:1 MSB:false) = 16r2010.
   171 
   171 
   172             wBytes signedInt16At:1 put:-3 MSB:false.
   172 	    wBytes signedInt16At:1 put:-3 MSB:false.
   173             self assert:(wBytes unsignedInt16At:1 MSB:false) = 16rFFFD.
   173 	    self assert:(wBytes unsignedInt16At:1 MSB:false) = 16rFFFD.
   174             self assert:(wBytes signedInt16At:1 MSB:false) = -3.
   174 	    self assert:(wBytes signedInt16At:1 MSB:false) = -3.
   175         ].
   175 	].
   176 
   176 
   177     check 
   177     check
   178         value: #[ 16r10 16r20 16r30 16r40 ]
   178 	value: #[ 16r10 16r20 16r30 16r40 ]
   179         value: #[ 16rFF 16r7F 16r80 16r81 ].
   179 	value: #[ 16rFF 16r7F 16r80 16r81 ].
   180 
   180 
   181     check 
   181     check
   182         value: (WordArray with:16r2010 with:16r4030)
   182 	value: (WordArray with:16r2010 with:16r4030)
   183         value: (WordArray with:16r7FFF with:16r8180).
   183 	value: (WordArray with:16r7FFF with:16r8180).
   184 
   184 
   185     check 
   185     check
   186         value: (IntegerArray with:16r40302010)
   186 	value: (IntegerArray with:16r40302010)
   187         value: (IntegerArray with:16r81807FFF).
   187 	value: (IntegerArray with:16r81807FFF).
   188 
   188 
   189     "/ check immutablility checks
   189     "/ check immutablility checks
   190     bytes :=  #[ 1 2 ] beImmutable.
   190     bytes :=  #[ 1 2 ] beImmutable.
   191     self 
   191     self
   192         should:[        
   192 	should:[
   193             bytes unsignedInt16At:1 put:0
   193 	    bytes unsignedInt16At:1 put:0
   194         ]
   194 	]
   195         raise:NoModificationError.
   195 	raise:NoModificationError.
   196     self assert:(bytes at:1) == 1.
   196     self assert:(bytes at:1) == 1.
   197     self assert:(bytes at:2) == 2.
   197     self assert:(bytes at:2) == 2.
   198 
   198 
   199     "/ check bounds checks
   199     "/ check bounds checks
   200     #(2 0 -1 -2) do:[:badIndex |
   200     #(2 0 -1 -2) do:[:badIndex |
   201         self 
   201 	self
   202             should:[        
   202 	    should:[
   203                 #[ 16rFF 16r00 ] unsignedInt16At:badIndex MSB:true
   203 		#[ 16rFF 16r00 ] unsignedInt16At:badIndex MSB:true
   204             ]
   204 	    ]
   205             raise:SubscriptOutOfBoundsError.
   205 	    raise:SubscriptOutOfBoundsError.
   206 
   206 
   207         self 
   207 	self
   208             should:[        
   208 	    should:[
   209                 #[ 16rFF 16r00 ] unsignedInt16At:badIndex MSB:false
   209 		#[ 16rFF 16r00 ] unsignedInt16At:badIndex MSB:false
   210             ]
   210 	    ]
   211             raise:SubscriptOutOfBoundsError.
   211 	    raise:SubscriptOutOfBoundsError.
   212     ]
   212     ]
   213 
   213 
   214     "
   214     "
   215      self run:#test01_int16Access
   215      self run:#test01_int16Access
   216     "
   216     "
   270     self assert:(bytes unsignedInt32At:1 MSB:false) = 16rFFFFFFFD.
   270     self assert:(bytes unsignedInt32At:1 MSB:false) = 16rFFFFFFFD.
   271     self assert:(bytes signedInt32At:1 MSB:false) = -3.
   271     self assert:(bytes signedInt32At:1 MSB:false) = -3.
   272 
   272 
   273     "/ check immutablility checks
   273     "/ check immutablility checks
   274     bytes :=  #[ 1 2 3 4 ] beImmutable.
   274     bytes :=  #[ 1 2 3 4 ] beImmutable.
   275     self 
   275     self
   276         should:[        
   276 	should:[
   277             bytes unsignedInt32At:1 put:0
   277 	    bytes unsignedInt32At:1 put:0
   278         ]
   278 	]
   279         raise:NoModificationError.
   279 	raise:NoModificationError.
   280     self assert:(bytes at:1) == 1.
   280     self assert:(bytes at:1) == 1.
   281     self assert:(bytes at:2) == 2.
   281     self assert:(bytes at:2) == 2.
   282     self assert:(bytes at:3) == 3.
   282     self assert:(bytes at:3) == 3.
   283     self assert:(bytes at:4) == 4.
   283     self assert:(bytes at:4) == 4.
   284 
   284 
   285     "/ check bounds checks
   285     "/ check bounds checks
   286     #(2 0 -1 -2) do:[:badIndex |
   286     #(2 0 -1 -2) do:[:badIndex |
   287         self 
   287 	self
   288             should:[        
   288 	    should:[
   289                 #[ 16rFF 16r01 16r02 16r03 ] unsignedInt32At:badIndex MSB:true
   289 		#[ 16rFF 16r01 16r02 16r03 ] unsignedInt32At:badIndex MSB:true
   290             ]
   290 	    ]
   291             raise:SubscriptOutOfBoundsError.
   291 	    raise:SubscriptOutOfBoundsError.
   292 
   292 
   293         self 
   293 	self
   294             should:[        
   294 	    should:[
   295                 #[ 16rFF 16r01 16r02 16r03 ] unsignedInt32At:badIndex MSB:false
   295 		#[ 16rFF 16r01 16r02 16r03 ] unsignedInt32At:badIndex MSB:false
   296             ]
   296 	    ]
   297             raise:SubscriptOutOfBoundsError.
   297 	    raise:SubscriptOutOfBoundsError.
   298     ]
   298     ]
   299 
   299 
   300     "
   300     "
   301      self run:#test02_int32Access
   301      self run:#test02_int32Access
   302     "
   302     "
   338     self assert:(bytes signedInt64At:1 MSB:true)  = -6876855410854182864. "/ 16rA090807060504030 signExtendedLongLongValue.
   338     self assert:(bytes signedInt64At:1 MSB:true)  = -6876855410854182864. "/ 16rA090807060504030 signExtendedLongLongValue.
   339     self assert:(bytes signedInt64At:1 MSB:false)   = 16r30405060708090A0.
   339     self assert:(bytes signedInt64At:1 MSB:false)   = 16r30405060708090A0.
   340 
   340 
   341     "/ check immutablility checks
   341     "/ check immutablility checks
   342     bytes :=  #[ 1 2 3 4 5 6 7 8 ] beImmutable.
   342     bytes :=  #[ 1 2 3 4 5 6 7 8 ] beImmutable.
   343     self 
   343     self
   344         should:[        
   344 	should:[
   345             bytes unsignedInt64At:1 put:0
   345 	    bytes unsignedInt64At:1 put:0
   346         ]
   346 	]
   347         raise:NoModificationError.
   347 	raise:NoModificationError.
   348     self assert:(bytes at:1) == 1.
   348     self assert:(bytes at:1) == 1.
   349     self assert:(bytes at:2) == 2.
   349     self assert:(bytes at:2) == 2.
   350     self assert:(bytes at:3) == 3.
   350     self assert:(bytes at:3) == 3.
   351     self assert:(bytes at:4) == 4.
   351     self assert:(bytes at:4) == 4.
   352     self assert:(bytes at:5) == 5.
   352     self assert:(bytes at:5) == 5.
   354     self assert:(bytes at:7) == 7.
   354     self assert:(bytes at:7) == 7.
   355     self assert:(bytes at:8) == 8.
   355     self assert:(bytes at:8) == 8.
   356 
   356 
   357     "/ check bounds checks
   357     "/ check bounds checks
   358     #(2 0 -1 -2) do:[:badIndex |
   358     #(2 0 -1 -2) do:[:badIndex |
   359         self 
   359 	self
   360             should:[        
   360 	    should:[
   361                 #[ 16rFF 16r01 16r02 16r03 16r04 16r05 16r06 16r07 ] unsignedInt64At:badIndex MSB:true
   361 		#[ 16rFF 16r01 16r02 16r03 16r04 16r05 16r06 16r07 ] unsignedInt64At:badIndex MSB:true
   362             ]
   362 	    ]
   363             raise:SubscriptOutOfBoundsError.
   363 	    raise:SubscriptOutOfBoundsError.
   364 
   364 
   365         self 
   365 	self
   366             should:[        
   366 	    should:[
   367                 #[ 16rFF 16r01 16r02 16r03 16r04 16r05 16r06 16r07 ] unsignedInt64At:badIndex MSB:false
   367 		#[ 16rFF 16r01 16r02 16r03 16r04 16r05 16r06 16r07 ] unsignedInt64At:badIndex MSB:false
   368             ]
   368 	    ]
   369             raise:SubscriptOutOfBoundsError.
   369 	    raise:SubscriptOutOfBoundsError.
   370     ]
   370     ]
   371 
   371 
   372     "
   372     "
   373      self run:#test03_int64Access
   373      self run:#test03_int64Access
   374     "
   374     "
   398     bytes doubleAt:1 put:345.
   398     bytes doubleAt:1 put:345.
   399     self assert:(bytes = #[0 0 0 0 0 144 117 64]).
   399     self assert:(bytes = #[0 0 0 0 0 144 117 64]).
   400 
   400 
   401     "/ check bounds checks
   401     "/ check bounds checks
   402     #(2 0 -1 -2) do:[:badIndex |
   402     #(2 0 -1 -2) do:[:badIndex |
   403         self 
   403 	self
   404             should:[        
   404 	    should:[
   405                 #[ 16rFF 16r01 16r02 16r03 ] floatAt:badIndex MSB:true
   405 		#[ 16rFF 16r01 16r02 16r03 ] floatAt:badIndex MSB:true
   406             ]
   406 	    ]
   407             raise:SubscriptOutOfBoundsError.
   407 	    raise:SubscriptOutOfBoundsError.
   408 
   408 
   409         self 
   409 	self
   410             should:[        
   410 	    should:[
   411                 #[ 16rFF 16r01 16r02 16r03 ] floatAt:badIndex MSB:false
   411 		#[ 16rFF 16r01 16r02 16r03 ] floatAt:badIndex MSB:false
   412             ]
   412 	    ]
   413             raise:SubscriptOutOfBoundsError.
   413 	    raise:SubscriptOutOfBoundsError.
   414 
   414 
   415         self 
   415 	self
   416             should:[        
   416 	    should:[
   417                 #[ 16rFF 16r01 16r02 16r03 16rFF 16r01 16r02 16r03 ] doubleAt:badIndex MSB:true
   417 		#[ 16rFF 16r01 16r02 16r03 16rFF 16r01 16r02 16r03 ] doubleAt:badIndex MSB:true
   418             ]
   418 	    ]
   419             raise:SubscriptOutOfBoundsError.
   419 	    raise:SubscriptOutOfBoundsError.
   420 
   420 
   421         self 
   421 	self
   422             should:[        
   422 	    should:[
   423                 #[ 16rFF 16r01 16r02 16r03 16rFF 16r01 16r02 16r03 ] doubleAt:badIndex MSB:false
   423 		#[ 16rFF 16r01 16r02 16r03 16rFF 16r01 16r02 16r03 ] doubleAt:badIndex MSB:false
   424             ]
   424 	    ]
   425             raise:SubscriptOutOfBoundsError.
   425 	    raise:SubscriptOutOfBoundsError.
   426     ]
   426     ]
   427 
   427 
   428     "
   428     "
   429      self run:#test10_floatAccess
   429      self run:#test10_floatAccess
   430     "
   430     "