Files
sdk/tests/web/internal/array_flags_errors_test.dart
T
Robert Nystrom ba40d9bece Format tests/web/ using the 3.8 formatting style.
Change-Id: I73edeeaf4934899b71d6335dcb4b4b54dce46bae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426340
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-05-02 20:17:11 -07:00

48 lines
1.3 KiB
Dart

// Copyright (c) 2024, 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.
import 'dart:_foreign_helper' show ArrayFlags, HArrayFlagsCheck;
import 'dart:typed_data';
import 'package:expect/expect.dart';
void rub(Object object, String message) {
try {
// Always fail, using non-standard operation name and verb.
HArrayFlagsCheck(
object,
ArrayFlags.unmodifiable,
ArrayFlags.fixedLengthCheck,
'rub',
'burnish',
);
Expect.fail('HArrayFlagsCheck should always throw');
} catch (e) {
Expect.equals(message, e.toString());
}
}
main() {
rub(const [], "Unsupported operation: 'rub': Cannot burnish a constant list");
rub(
List.unmodifiable([]),
"Unsupported operation: 'rub': Cannot burnish an unmodifiable list",
);
rub(
List.filled(0, 0),
"Unsupported operation: 'rub': Cannot burnish a fixed-length list",
);
rub([], "Unsupported operation: 'rub': Cannot burnish a list");
rub(
Uint8List(10).asUnmodifiableView(),
"Unsupported operation: 'rub': Cannot burnish an unmodifiable list",
);
rub(
ByteData(10).asUnmodifiableView(),
"Unsupported operation: 'rub': Cannot burnish an unmodifiable ByteData",
);
}