8
8
9
9
d8 . file . execute ( 'test/mjsunit/typedarray-helpers.js' ) ;
10
10
11
- class MyUint8Array extends Uint8Array { } ;
12
-
13
- const ctors = [
14
- Uint8Array ,
15
- Int8Array ,
16
- Uint16Array ,
17
- Int16Array ,
18
- Int32Array ,
19
- Float32Array ,
20
- Float64Array ,
21
- Uint8ClampedArray ,
22
- BigUint64Array ,
23
- BigInt64Array ,
24
- MyUint8Array
25
- ] ;
26
-
27
11
function CreateResizableArrayBuffer ( byteLength , maxByteLength ) {
28
12
return new ArrayBuffer ( byteLength , { maxByteLength : maxByteLength } ) ;
29
13
}
@@ -677,17 +661,12 @@ function CreateResizableArrayBuffer(byteLength, maxByteLength) {
677
661
function TestIteration ( ta , expected ) {
678
662
let values = [ ] ;
679
663
for ( const value of ta ) {
680
- values . push ( value ) ;
664
+ values . push ( Number ( value ) ) ;
681
665
}
682
666
assertEquals ( expected , values ) ;
683
667
}
684
668
685
669
for ( let ctor of ctors ) {
686
- if ( ctor == BigInt64Array || ctor == BigUint64Array ) {
687
- // This test doesn't work for BigInts.
688
- continue ;
689
- }
690
-
691
670
const buffer_byte_length = no_elements * ctor . BYTES_PER_ELEMENT ;
692
671
// We can use the same RAB for all the TAs below, since we won't modify it
693
672
// after writing the initial values.
@@ -698,7 +677,7 @@ function CreateResizableArrayBuffer(byteLength, maxByteLength) {
698
677
// Write some data into the array.
699
678
let ta_write = new ctor ( rab ) ;
700
679
for ( let i = 0 ; i < no_elements ; ++ i ) {
701
- ta_write [ i ] = i % 128 ;
680
+ WriteToTypedArray ( ta_write , i , i % 128 ) ;
702
681
}
703
682
704
683
// Create various different styles of TypedArrays with the RAB as the
@@ -741,11 +720,11 @@ function CreateResizableArrayBuffer(byteLength, maxByteLength) {
741
720
// Helpers for iteration tests.
742
721
function CreateRab ( buffer_byte_length , ctor ) {
743
722
const rab = CreateResizableArrayBuffer ( buffer_byte_length ,
744
- 2 * buffer_byte_length ) ;
723
+ 2 * buffer_byte_length ) ;
745
724
// Write some data into the array.
746
725
let ta_write = new ctor ( rab ) ;
747
726
for ( let i = 0 ; i < buffer_byte_length / ctor . BYTES_PER_ELEMENT ; ++ i ) {
748
- ta_write [ i ] = i % 128 ;
727
+ WriteToTypedArray ( ta_write , i , i % 128 ) ;
749
728
}
750
729
return rab ;
751
730
}
@@ -755,7 +734,7 @@ function TestIterationAndResize(ta, expected, rab, resize_after,
755
734
let values = [ ] ;
756
735
let resized = false ;
757
736
for ( const value of ta ) {
758
- values . push ( value ) ;
737
+ values . push ( Number ( value ) ) ;
759
738
if ( ! resized && values . length == resize_after ) {
760
739
rab . resize ( new_byte_length ) ;
761
740
resized = true ;
@@ -770,10 +749,6 @@ function TestIterationAndResize(ta, expected, rab, resize_after,
770
749
const offset = 2 ;
771
750
772
751
for ( let ctor of ctors ) {
773
- if ( ctor == BigInt64Array || ctor == BigUint64Array ) {
774
- // This test doesn't work for BigInts.
775
- continue ;
776
- }
777
752
const buffer_byte_length = no_elements * ctor . BYTES_PER_ELEMENT ;
778
753
const byte_offset = offset * ctor . BYTES_PER_ELEMENT ;
779
754
@@ -828,10 +803,6 @@ function TestIterationAndResize(ta, expected, rab, resize_after,
828
803
829
804
// We need to recreate the RAB between all TA tests, since we grow it.
830
805
for ( let ctor of ctors ) {
831
- if ( ctor == BigInt64Array || ctor == BigUint64Array ) {
832
- // This test doesn't work for BigInts.
833
- continue ;
834
- }
835
806
const buffer_byte_length = no_elements * ctor . BYTES_PER_ELEMENT ;
836
807
const byte_offset = offset * ctor . BYTES_PER_ELEMENT ;
837
808
@@ -875,10 +846,6 @@ function TestIterationAndResize(ta, expected, rab, resize_after,
875
846
const offset = 2 ;
876
847
877
848
for ( let ctor of ctors ) {
878
- if ( ctor == BigInt64Array || ctor == BigUint64Array ) {
879
- // This test doesn't work for BigInts.
880
- continue ;
881
- }
882
849
const buffer_byte_length = no_elements * ctor . BYTES_PER_ELEMENT ;
883
850
const byte_offset = offset * ctor . BYTES_PER_ELEMENT ;
884
851
@@ -935,10 +902,6 @@ function TestIterationAndResize(ta, expected, rab, resize_after,
935
902
const offset = 2 ;
936
903
937
904
for ( let ctor of ctors ) {
938
- if ( ctor == BigInt64Array || ctor == BigUint64Array ) {
939
- // This test doesn't work for BigInts.
940
- continue ;
941
- }
942
905
const buffer_byte_length = no_elements * ctor . BYTES_PER_ELEMENT ;
943
906
const byte_offset = offset * ctor . BYTES_PER_ELEMENT ;
944
907
0 commit comments