-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This PR adds many new tests. The idea is to test each `setRange()` of an `int` type against a `float` type of the same size (to ensure that we have an error, not a memcpy). Next, we test it against a type of a smaller size, and against a type of a bigger size. We do the same for each `float` against `int`. We have float types with sizes 32, 64, and 128 (32x4 and 64x2) only. Therefore we test `Int16` against `Uint8` and `Uint16` in case of small and equal size, which is not an error. When we are checking 32-bit type against 16, 32 and 64 bit, the latter case is moved to separate tests because it has to be switched off on web configurations. Issue dart-lang/sdk#53945 exists for `x` types as well, so we test them, too.
- Loading branch information
Showing
39 changed files
with
1,048 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test data of the same size | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
List<num> ints = Uint32List.fromList([1, 2, 3, 4]); | ||
Float32List floats = Float32List(4); | ||
Expect.throws(() { | ||
// Check that it's no memcopy of the same-sized data | ||
(floats as List<num>).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test less-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
List<num> ints = Uint16List.fromList([1, 2, 3, 4]); | ||
Float32List floats = Float32List(4); | ||
Expect.throws(() { | ||
(floats as List<num>).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test larger-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
List<num> ints = Uint64List.fromList([1, 2, 3, 4]); | ||
Float32List floats = Float32List(4); | ||
Expect.throws(() { | ||
(floats as List<num>).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test list elements of the same size | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var ints = Int32x4List.fromList([Int32x4(1, 1, 1, 1), Int32x4(2, 2, 2, 2)]); | ||
Float32x4List floats = Float32x4List(2); | ||
Expect.throws(() { | ||
// Check that it's no memcopy of the same-sized data | ||
(floats as dynamic).setRange(0, 2, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test less-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var ints = Int16List.fromList([1, 2, 3, 4]); | ||
Float32x4List floats = Float32x4List(4); | ||
Expect.throws(() { | ||
(floats as dynamic).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test less-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var ints = Int64List.fromList([1, 2, 3, 4]); | ||
Float32x4List floats = Float32x4List(4); | ||
Expect.throws(() { | ||
(floats as dynamic).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test list elements of the same size | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
List<num> ints = Uint64List.fromList([1, 2, 3, 4]); | ||
Float64List floats = Float64List(4); | ||
Expect.throws(() { | ||
// Check that it's no memcopy of the same-sized data | ||
(floats as List<num>).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test less-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
List<num> ints = Uint32List.fromList([1, 2, 3, 4]); | ||
Float64List floats = Float64List(4); | ||
Expect.throws(() { | ||
(floats as List<num>).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test less-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var ints = Int32x4List.fromList([Int32x4(1, 1, 1, 1), Int32x4(2, 2, 2, 2)]); | ||
Float64List floats = Float64List(2); | ||
Expect.throws(() { | ||
(floats as dynamic).setRange(0, 2, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test list elements of the same size | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var ints = Int32x4List.fromList([Int32x4(1, 1, 1, 1), Int32x4(2, 2, 2, 2)]); | ||
Float64x2List floats = Float64x2List(2); | ||
Expect.throws(() { | ||
// Check that it's no memcopy of the same-sized data | ||
(floats as dynamic).setRange(0, 2, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` is not subtype of this list. Test less-sized list elements | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var ints = Int64List.fromList([1, 2, 3, 4]); | ||
Float64x2List floats = Float64x2List(4); | ||
Expect.throws(() { | ||
(floats as dynamic).setRange(0, 4, ints); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is not an error if run-time type of the | ||
/// `iterable` elements is an integer | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
Uint8List uint8List = Uint8List.fromList([255, 255]); | ||
Uint16List uint16List = Uint16List.fromList([0xFFFF, 1]); | ||
Uint32List uint32List = Uint32List.fromList([0xFFFFFFFF, 2]); | ||
Int16List int16List = Int16List(2); | ||
int16List.setRange(0, 2, uint8List); | ||
Expect.listEquals([255, 255], int16List); | ||
int16List.setRange(0, 2, uint16List); | ||
Expect.listEquals([-1, 1], int16List); | ||
int16List.setRange(0, 2, uint32List); | ||
Expect.listEquals([-1, 2], int16List); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is a run time error if run-time type of the | ||
/// `iterable` elements is not a subtype of `Int16` | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
var floats = Float32List.fromList([1, 2, 3, 4]); | ||
Int16List int16List = Int16List(4); | ||
Expect.throws(() { | ||
(int16List as dynamic).setRange(0, 4, floats); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// @assertion | ||
/// void setRange( | ||
/// int start, | ||
/// int end, | ||
/// Iterable<E> iterable, [ | ||
/// int skipCount = 0 | ||
/// ]) | ||
/// | ||
/// @description Checks that it is not an error if run-time type of the | ||
/// `iterable` elements is an integer | ||
/// @author [email protected] | ||
import "dart:typed_data"; | ||
import "../../../Utils/expect.dart"; | ||
|
||
void main() { | ||
Uint16List uint16List = Uint16List.fromList([0xFFFF, 1]); | ||
Uint32List uint32List = Uint32List.fromList([0xFFFFFFFF, 2]); | ||
Int32List int32List = Int32List(2); | ||
int32List.setRange(0, 2, uint16List); | ||
Expect.listEquals([65535, 1], int32List); | ||
int32List.setRange(0, 2, uint32List); | ||
Expect.listEquals([-1, 2], int32List); | ||
} |
Oops, something went wrong.