blob: 9d615c46dd25e79c2679454c14dc6d983e86485f [file] [log] [blame] [edit]
// Copyright (c) 2025, 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 JSFloat64Array([JSArrayBuffer buffer, int byteOffset, int length])
/// Creates a JavaScript `Float64Array` with `buffer` as its backing storage,
/// offset by `byteOffset` bytes, of size `length`.
///
/// If no `buffer` is provided, creates an empty `Float64Array`.
///
/// @description Checks that this constructor creates a JavaScript
/// `Float64Array` with `buffer` as its backing storage, offset by `byteOffset`
/// bytes, of size `length`. Test that `length == 0` creates an empty array.
/// @author sgrekhov22@gmail.com
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import '../../../Utils/expect.dart';
import '../js_utils.dart';
main() {
JSArrayBuffer buffer = JSArrayBuffer(8);
JSFloat64Array ar = JSFloat64Array(buffer, 0, 0);
globalContext["ar"] = ar;
globalContext["buffer"] = buffer;
eval(r'''
globalThis.length = ar.length;
''');
Expect.equals(0, (globalContext["length"] as JSNumber).toDartInt);
}