RegressionTests__MutabilityTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2324 98d710589596
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#MutabilityTest
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:''
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	category:'tests-Regression-Numbers'
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!MutabilityTest class methodsFor:'documentation'!
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
documentation
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
"
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
    documentation to be added.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    class:
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
        <a short class summary here, describing what instances represent>
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    responsibilities:    
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
        <describing what my main role is>
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
    collaborators:    
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
        <describing with whom and how I talk to>
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
    API:
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
        <public api and main messages>
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
        
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    example:
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
        <a one-line examples on how to use - can also be in a separate example method>
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
    implementation:
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
        <implementation points>
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
    [author:]
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
        Claus Gittinger
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    [instance variables:]
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    [class variables:]
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    [see also:]
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
! !
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!MutabilityTest methodsFor:'tests'!
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
test01_immutability
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    "literals are immutable - if specified so"
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
    52
    
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
    53
    <pragma: +STXExtendedArrayLiterals>
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
    54
    <pragma: +arraysAreImmutable>
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    |arr arr2|
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    arr := #[1 2 3 4].
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "/ unboxed s8
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    arr := #s8(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    "/ unboxed s16
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    arr := #s16(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    "/ unboxed s32
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
    85
    arr := #s32(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "/ unboxed s64
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    arr := #s64(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    "/ unboxed u1
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    arr := #u1(0 1 1 0).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    self should:[arr at:1 put:1] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    self shouldnt:[arr2 at:1 put:1] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    self should:[arr2 at:1 put:2] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    "/ unboxed u8
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    arr := #u8(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    "/ unboxed u16
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    arr := #u16(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    "/ unboxed u32
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    arr := #u32(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    "/ unboxed u64
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    arr := #s64(1 2 3 4).
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    "/ unboxed f16
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   149
    arr := #f16(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    "/ unboxed f32
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   158
    arr := #f32(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    "/ unboxed f64
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   167
    arr := #f64(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
    self assert:(arr isImmutable).  "/ because it comes from a literal
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    self should:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    arr2 := arr copy.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
    self assert:(arr2 isImmutable not). 
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    self shouldnt:[arr2 at:1 put:10] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
    
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
    "
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
     self run:#test01_mutability
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
     self new test01_mutability
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    "
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
    "Created: / 09-06-2019 / 15:49:37 / Claus Gittinger"
2305
2df2743279fd #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2296
diff changeset
   181
    "Modified: / 10-06-2019 / 20:50:21 / Claus Gittinger"
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   182
    "Modified: / 17-06-2019 / 15:11:09 / Stefan Reise"
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
!
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
test02_mutability
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "literals are mutable - if specified so"
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
    
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   188
    <pragma: +STXExtendedArrayLiterals>
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   189
    <pragma: -arraysAreImmutable>
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    |arr|
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   193
    self skipIf:(self class compiledMethodAt:#test01_immutability)
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   194
                byteCode isNil
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   195
         description:'skipped because stc-compiled literals are always immutable'.
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   196
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   197
    arr := #[1 2 3 4].
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    "/ unboxed s8
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   202
    arr := #s8(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    "/ unboxed s16
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   207
    arr := #s16(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    "/ unboxed s32
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   212
    arr := #s32(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    "/ unboxed s64
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   217
    arr := #s64(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    "/ unboxed u1
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   222
    arr := #u1(0 1 1 0).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    self shouldnt:[arr at:1 put:1] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    self should:[arr at:1 put:2] raise:Error.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    "/ unboxed u8
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   228
    arr := #u8(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    "/ unboxed u16
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   233
    arr := #u16(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "/ unboxed u32
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   238
    arr := #u32(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    "/ unboxed u64
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   243
    arr := #s64(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    "/ unboxed f16
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   248
    arr := #f16(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    "/ unboxed f32
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   253
    arr := #f32(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    "/ unboxed f64
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   258
    arr := #f64(1 2 3 4).
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    self assert:(arr isImmutable not).  "/ because I specifid so
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    self shouldnt:[arr at:1 put:10] raise:NoModificationError.
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    "
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
     self run:#test01_mutability
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
     self new test01_mutability
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    "Created: / 09-06-2019 / 15:49:46 / Claus Gittinger"
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   268
    "Modified: / 17-06-2019 / 15:11:06 / Stefan Reise"
2296
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
! !
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
!MutabilityTest class methodsFor:'documentation'!
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
version_CVS
7138d2e03876 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
    ^ '$Header$'
2324
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   275
! !
98d710589596 #BUGFIX by Stefan Reise
sr
parents: 2313
diff changeset
   276