blob: 4e342441675abde7ec239b5e742228fe73a6a9d5 [file] [log] [blame]
// Copyright (c) 2017, 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 Int8List.fromList(List<int> elements)
/// ...
/// Values are truncated to fit in the list when they are copied, the same way
/// storing values truncates them.
/// @description Checks that values are truncated to fit in the list when they
/// are copied.
/// @author ngl@unipro.ru
import "dart:typed_data";
import "../../../Utils/expect.dart";
void check(List<int> list) {
Int8List l = new Int8List.fromList(list);
Expect.equals(l.length, list.length);
Expect.listEquals(list.map((x) => x.toUnsigned(8)).toList(),
l.map((x) => x.toUnsigned(8)).toList());
}
main() {
check([128, -129]);
check([1000, 1001, 1002]);
check([-1000, -1001, -1002]);
check([1024, 2048, 4096]);
check([-1024, -2048, -4096]);
}