@@ -78,6 +78,186 @@ describe('angular', function() {
78
78
expect ( copy ( objWithRegExp . re ) === objWithRegExp . re ) . toBeFalsy ( ) ;
79
79
} ) ;
80
80
81
+ it ( "should copy a Uint8Array with no destination" , function ( ) {
82
+ if ( typeof Uint8Array !== 'undefined' ) {
83
+ var src = new Uint8Array ( 2 ) ;
84
+ src [ 1 ] = 1 ;
85
+ var dst = copy ( src ) ;
86
+ expect ( copy ( src ) instanceof Uint8Array ) . toBeTruthy ( ) ;
87
+ expect ( dst ) . toEqual ( src ) ;
88
+ expect ( dst ) . not . toBe ( src ) ;
89
+ }
90
+ } ) ;
91
+
92
+ it ( "should copy a Uint8ClampedArray with no destination" , function ( ) {
93
+ if ( typeof Uint8ClampedArray !== 'undefined' ) {
94
+ var src = new Uint8ClampedArray ( 2 ) ;
95
+ src [ 1 ] = 1 ;
96
+ var dst = copy ( src ) ;
97
+ expect ( copy ( src ) instanceof Uint8ClampedArray ) . toBeTruthy ( ) ;
98
+ expect ( dst ) . toEqual ( src ) ;
99
+ expect ( dst ) . not . toBe ( src ) ;
100
+ }
101
+ } ) ;
102
+
103
+ it ( "should copy a Uint16Array with no destination" , function ( ) {
104
+ if ( typeof Uint16Array !== 'undefined' ) {
105
+ var src = new Uint16Array ( 2 ) ;
106
+ src [ 1 ] = 1 ;
107
+ var dst = copy ( src ) ;
108
+ expect ( copy ( src ) instanceof Uint16Array ) . toBeTruthy ( ) ;
109
+ expect ( dst ) . toEqual ( src ) ;
110
+ expect ( dst ) . not . toBe ( src ) ;
111
+ }
112
+ } ) ;
113
+
114
+ it ( "should copy a Uint32Array with no destination" , function ( ) {
115
+ if ( typeof Uint32Array !== 'undefined' ) {
116
+ var src = new Uint32Array ( 2 ) ;
117
+ src [ 1 ] = 1 ;
118
+ var dst = copy ( src ) ;
119
+ expect ( copy ( src ) instanceof Uint32Array ) . toBeTruthy ( ) ;
120
+ expect ( dst ) . toEqual ( src ) ;
121
+ expect ( dst ) . not . toBe ( src ) ;
122
+ }
123
+ } ) ;
124
+
125
+ it ( "should copy a Int8Array with no destination" , function ( ) {
126
+ if ( typeof Int8Array !== 'undefined' ) {
127
+ var src = new Int8Array ( 2 ) ;
128
+ src [ 1 ] = 1 ;
129
+ var dst = copy ( src ) ;
130
+ expect ( copy ( src ) instanceof Int8Array ) . toBeTruthy ( ) ;
131
+ expect ( dst ) . toEqual ( src ) ;
132
+ expect ( dst ) . not . toBe ( src ) ;
133
+ }
134
+ } ) ;
135
+
136
+ it ( "should copy a Int16Array with no destination" , function ( ) {
137
+ if ( typeof Int16Array !== 'undefined' ) {
138
+ var src = new Int16Array ( 2 ) ;
139
+ src [ 1 ] = 1 ;
140
+ var dst = copy ( src ) ;
141
+ expect ( copy ( src ) instanceof Int16Array ) . toBeTruthy ( ) ;
142
+ expect ( dst ) . toEqual ( src ) ;
143
+ expect ( dst ) . not . toBe ( src ) ;
144
+ }
145
+ } ) ;
146
+
147
+ it ( "should copy a Int32Array with no destination" , function ( ) {
148
+ if ( typeof Int32Array !== 'undefined' ) {
149
+ var src = new Int32Array ( 2 ) ;
150
+ src [ 1 ] = 1 ;
151
+ var dst = copy ( src ) ;
152
+ expect ( copy ( src ) instanceof Int32Array ) . toBeTruthy ( ) ;
153
+ expect ( dst ) . toEqual ( src ) ;
154
+ expect ( dst ) . not . toBe ( src ) ;
155
+ }
156
+ } ) ;
157
+
158
+ it ( "should copy a Float32Array with no destination" , function ( ) {
159
+ if ( typeof Float32Array !== 'undefined' ) {
160
+ var src = new Float32Array ( 2 ) ;
161
+ src [ 1 ] = 1 ;
162
+ var dst = copy ( src ) ;
163
+ expect ( copy ( src ) instanceof Float32Array ) . toBeTruthy ( ) ;
164
+ expect ( dst ) . toEqual ( src ) ;
165
+ expect ( dst ) . not . toBe ( src ) ;
166
+ }
167
+ } ) ;
168
+
169
+ it ( "should copy a Float64Array with no destination" , function ( ) {
170
+ if ( typeof Float64Array !== 'undefined' ) {
171
+ var src = new Float64Array ( 2 ) ;
172
+ src [ 1 ] = 1 ;
173
+ var dst = copy ( src ) ;
174
+ expect ( copy ( src ) instanceof Float64Array ) . toBeTruthy ( ) ;
175
+ expect ( dst ) . toEqual ( src ) ;
176
+ expect ( dst ) . not . toBe ( src ) ;
177
+ }
178
+ } ) ;
179
+
180
+ it ( "should throw an exception if a Uint8Array is the destination" , function ( ) {
181
+ if ( typeof Uint8Array !== 'undefined' ) {
182
+ var src = new Uint8Array ( ) ;
183
+ var dst = new Uint8Array ( 5 ) ;
184
+ expect ( function ( ) { copy ( src , dst ) ; } )
185
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
186
+ }
187
+ } ) ;
188
+
189
+ it ( "should throw an exception if a Uint8ClampedArray is the destination" , function ( ) {
190
+ if ( typeof Uint8ClampedArray !== 'undefined' ) {
191
+ var src = new Uint8ClampedArray ( ) ;
192
+ var dst = new Uint8ClampedArray ( 5 ) ;
193
+ expect ( function ( ) { copy ( src , dst ) ; } )
194
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
195
+ }
196
+ } ) ;
197
+
198
+ it ( "should throw an exception if a Uint16Array is the destination" , function ( ) {
199
+ if ( typeof Uint16Array !== 'undefined' ) {
200
+ var src = new Uint16Array ( ) ;
201
+ var dst = new Uint16Array ( 5 ) ;
202
+ expect ( function ( ) { copy ( src , dst ) ; } )
203
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
204
+ }
205
+ } ) ;
206
+
207
+ it ( "should throw an exception if a Uint32Array is the destination" , function ( ) {
208
+ if ( typeof Uint32Array !== 'undefined' ) {
209
+ var src = new Uint32Array ( ) ;
210
+ var dst = new Uint32Array ( 5 ) ;
211
+ expect ( function ( ) { copy ( src , dst ) ; } )
212
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
213
+ }
214
+ } ) ;
215
+
216
+ it ( "should throw an exception if a Int8Array is the destination" , function ( ) {
217
+ if ( typeof Int8Array !== 'undefined' ) {
218
+ var src = new Int8Array ( ) ;
219
+ var dst = new Int8Array ( 5 ) ;
220
+ expect ( function ( ) { copy ( src , dst ) ; } )
221
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
222
+ }
223
+ } ) ;
224
+
225
+ it ( "should throw an exception if a Int16Array is the destination" , function ( ) {
226
+ if ( typeof Int16Array !== 'undefined' ) {
227
+ var src = new Int16Array ( ) ;
228
+ var dst = new Int16Array ( 5 ) ;
229
+ expect ( function ( ) { copy ( src , dst ) ; } )
230
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
231
+ }
232
+ } ) ;
233
+
234
+ it ( "should throw an exception if a Int32Array is the destination" , function ( ) {
235
+ if ( typeof Int32Array !== 'undefined' ) {
236
+ var src = new Int32Array ( ) ;
237
+ var dst = new Int32Array ( 5 ) ;
238
+ expect ( function ( ) { copy ( src , dst ) ; } )
239
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
240
+ }
241
+ } ) ;
242
+
243
+ it ( "should throw an exception if a Float32Array is the destination" , function ( ) {
244
+ if ( typeof Float32Array !== 'undefined' ) {
245
+ var src = new Float32Array ( ) ;
246
+ var dst = new Float32Array ( 5 ) ;
247
+ expect ( function ( ) { copy ( src , dst ) ; } )
248
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
249
+ }
250
+ } ) ;
251
+
252
+ it ( "should throw an exception if a Float64Array is the destination" , function ( ) {
253
+ if ( typeof Float64Array !== 'undefined' ) {
254
+ var src = new Float64Array ( ) ;
255
+ var dst = new Float64Array ( 5 ) ;
256
+ expect ( function ( ) { copy ( src , dst ) ; } )
257
+ . toThrowMinErr ( "ng" , "cpta" , "Can't copy! TypedArray destination cannot be mutated." ) ;
258
+ }
259
+ } ) ;
260
+
81
261
it ( "should deeply copy an array into an existing array" , function ( ) {
82
262
var src = [ 1 , { name :"value" } ] ;
83
263
var dst = [ { key :"v" } ] ;
0 commit comments