#BUGFIX by cg
class: RegressionTests::MiscArithmeticTests
added: #test02_unboxedArrays
"{ Encoding: utf8 }"
"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
TestCase subclass:#MiscArithmeticTests
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'tests-Regression-Numbers'
!
!MiscArithmeticTests class methodsFor:'documentation'!
documentation
"
documentation to be added.
class:
<a short class summary here, describing what instances represent>
responsibilities:
<describing what my main role is>
collaborators:
<describing with whom and how I talk to>
API:
<public api and main messages>
example:
<a one-line examples on how to use - can also be in a separate example method>
implementation:
<implementation points>
[author:]
Claus Gittinger
[instance variables:]
[class variables:]
[see also:]
"
! !
!MiscArithmeticTests methodsFor:'tests'!
test01_sum
<pragma: +STXExtendedArrayLiterals>
"tests the accumlated error when summing up many floats"
|arr sum|
arr := #(1e100 1 -1e100 1) asDoubleArray.
sum := arr sum.
sum = 2 ifFalse:[
Transcript showCR:'ignored expected error in sum'.
].
sum := arr esum.
self assert:(sum = 2).
arr := #(1e38 1 -1e38 1) asFloatArray.
sum := arr sum.
sum = 2 ifFalse:[
Transcript showCR:'ignored expected error in sum'.
].
sum := arr esum.
self assert:(sum = 2).
"/ same using literals
arr := #f32(1e38 1 -1e38 1).
sum := arr esum.
self assert:(sum = 2).
arr := #f64(1e100 1 -1e100 1).
sum := arr esum.
self assert:(sum = 2).
"
self run:#test01_sum
self new test01_sum
"
"Created: / 09-06-2019 / 10:35:16 / Claus Gittinger"
"Modified: / 09-06-2019 / 14:20:16 / Claus Gittinger"
!
test02_unboxedArrays
<pragma: +STXExtendedArrayLiterals>
<pragma: +arraysAreImmutable>
|arr arr2|
arr := #[1 2 3 4].
self assert:(arr isImmutable). "/ because it comes from a literal
self should:[arr at:1 put:10] raise:Error.
arr2 := arr copy.
self assert:(arr2 isImmutable not).
self shouldnt:[arr2 at:1 put:10] raise:Error.
arr := #s8(1 2 3 4).
self assert:(arr isImmutable). "/ because it comes from a literal
self should:[arr at:1 put:10] raise:Error.
arr2 := arr copy.
self assert:(arr2 isImmutable not).
self shouldnt:[arr2 at:1 put:10] raise:Error.
arr := #s16(1 2 3 4).
self assert:(arr isImmutable). "/ because it comes from a literal
self should:[arr at:1 put:10] raise:Error.
arr2 := arr copy.
self assert:(arr2 isImmutable not).
self shouldnt:[arr2 at:1 put:10] raise:Error.
"
self run:#test02_unboxedArrays
self new test02_unboxedArrays
"
"Created: / 09-06-2019 / 15:02:17 / Claus Gittinger"
! !
!MiscArithmeticTests class methodsFor:'documentation'!
version_CVS
^ '$Header$'
! !