Files
sdk/tests/web/dart2js/array_flags_errors_test.dart
T
Nate Biggs 124b98b461 [dart2js] Move tests from tests/web that are failing on DDC configurations into dart2js specific folder.
Also update dart2jsOptions on some tests that are failing on production/O0 configurations.

Change-Id: Ie0a8fa56dc391c98186f1573a76cff7ef6afde8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433563
Reviewed-by: Mayank Patke <fishythefish@google.com>
2025-06-20 20:11:25 -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",
);
}