From c7b7c6490a6a9f90a9be894ec8e5316ab650c56b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 21 Mar 2016 12:43:25 -0700 Subject: [PATCH] Bring in the latest pub. This updates a number of other dependencies as well. R=rnystrom@google.com Review URL: https://codereview.chromium.org/1811183002 . --- CHANGELOG.md | 9 + DEPS | 34 +- pkg/typed_data/LICENSE | 26 -- pkg/typed_data/README.md | 15 - pkg/typed_data/lib/typed_buffers.dart | 235 ----------- pkg/typed_data/lib/typed_data.dart | 10 - pkg/typed_data/pubspec.yaml | 9 - pkg/typed_data/test/typed_buffers_test.dart | 421 -------------------- 8 files changed, 35 insertions(+), 724 deletions(-) delete mode 100644 pkg/typed_data/LICENSE delete mode 100644 pkg/typed_data/README.md delete mode 100644 pkg/typed_data/lib/typed_buffers.dart delete mode 100644 pkg/typed_data/lib/typed_data.dart delete mode 100644 pkg/typed_data/pubspec.yaml delete mode 100644 pkg/typed_data/test/typed_buffers_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 863e8d6ffd5..10c8136d351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,15 @@ for (int n in ["a", "b"]) { ... } ``` +### Tool Changes + +* Pub + * `pub serve` now provides caching headers that should improve the performance + of requesting large files multiple times. + + * Both `pub get` and `pub upgrade` now have a `--no-precompile` flag that + disables precompilation of executables and transformed dependencies. + ## 1.15.0 - 2016-03-09 ### Core library changes diff --git a/DEPS b/DEPS index e0a16f3e689..8e35a96b477 100644 --- a/DEPS +++ b/DEPS @@ -21,14 +21,18 @@ vars = { "github_mirror": "https://chromium.googlesource.com/external/github.com/dart-lang/%s.git", + # Only use this temporarily while waiting for a mirror for a new package. + "github_dartlang": "https://github.com/dart-lang/%s.git", + "gyp_rev": "@6ee91ad8659871916f9aa840d42e1513befdf638", "co19_rev": "@3ed795ea02e022ef19c77cf1b6095b7c8f5584d0", "chromium_git": "https://chromium.googlesource.com", # Revisions of /third_party/* dependencies. - "args_tag": "@0.13.0", - "async_tag": "@1.4.0", + "args_tag": "@0.13.4", + "async_tag": "@1.9.0", "barback_tag" : "@0.15.2+7", + "boolean_selector_tag" : "@1.0.0", "boringssl_rev" : "@daeafc22c66ad48f6b32fc8d3362eb9ba31b774e", "charcode_tag": "@1.1.0", "chrome_rev" : "@19997", @@ -51,7 +55,7 @@ vars = { "idl_parser_rev": "@7fbe68cab90c38147dee4f48c30ad0d496c17915", "intl_rev": "@a8b480b9c436f6c0ec16730804c914bdb4e30d53", "jinja2_rev": "@2222b31554f03e62600cd7e383376a7c187967a1", - "json_rpc_2_tag": "@1.1.1", + "json_rpc_2_tag": "@2.0.0", "linter_rev": "@a60289545b34ab1f047a0a3f0673a4c5abde0eaf", "logging_rev": "@85d83e002670545e9039ad3985f0018ab640e597", "markdown_rev": "@4aaadf3d940bb172e1f6285af4d2b1710d309982", @@ -67,31 +71,34 @@ vars = { "ply_rev": "@604b32590ffad5cbb82e4afef1d305512d06ae93", "plugin_tag": "@0.1.0", "pool_tag": "@1.2.1", - "pub_rev": "@bd5c77abcb609d95340632b96344b59035e70376", + "pub_rev": "@c1405b945c6d818c8cfe78334e8d4b11fd913103", "pub_cache_tag": "@v0.1.0", "pub_semver_tag": "@1.2.1", "quiver_tag": "@0.21.4", "resource_rev":"@a49101ba2deb29c728acba6fb86000a8f730f4b1", "root_certificates_rev": "@c3a41df63afacec62fcb8135196177e35fe72f71", - "scheduled_test_tag": "@0.12.4+2", - "shelf_tag": "@0.6.4+3", + "scheduled_test_tag": "@0.12.5+2", + "shelf_tag": "@0.6.5", "smoke_rev" : "@f3361191cc2a85ebc1e4d4c33aec672d7915aba9", "source_maps_tag": "@0.10.1", "shelf_static_tag": "@0.2.3+1", - "shelf_web_socket_tag": "@0.0.1+4", + "shelf_web_socket_tag": "@0.2.0", "source_map_stack_trace_tag": "@1.0.4", "source_span_tag": "@1.2.0", "stack_trace_tag": "@1.4.2", + "stream_channel_tag": "@1.3.1", "string_scanner_tag": "@0.1.4", "sunflower_rev": "@879b704933413414679396b129f5dfa96f7a0b1e", - "test_tag": "@0.12.6+1", + "test_tag": "@0.12.12", "test_reflective_loader_tag": "@0.0.3", + "typed_data_tag": "@1.1.2", "utf_rev": "@1f55027068759e2d52f2c12de6a57cce5f3c5ee6", "usage_rev": "@b5080dac0d26a5609b266f8fdb0d053bc4c1c638", "watcher_tag": "@0.9.7", "when_tag": "@0.2.0+2", "which_tag": "@0.1.3+1", "web_components_rev": "@0e636b534d9b12c9e96f841e6679398e91a986ec", + "web_socket_channel_tag": "@1.0.0", "WebCore_rev": "@a86fe28efadcfc781f836037a80f27e22a5dad17", "yaml_tag": "@2.1.5", "zlib_rev": "@c3d0a6190f2f8c924a05ab6cc97b8f975bddd33f", @@ -142,6 +149,9 @@ deps = { (Var("github_mirror") % "async") + Var("async_tag"), Var("dart_root") + "/third_party/pkg/barback": (Var("github_mirror") % "barback") + Var("barback_tag"), + Var("dart_root") + "/third_party/pkg/boolean_selector": + (Var("github_dartlang") % "boolean_selector") + + Var("boolean_selector_tag"), Var("dart_root") + "/third_party/pkg/charcode": (Var("github_mirror") % "charcode") + Var("charcode_tag"), Var("dart_root") + "/third_party/pkg/cli_util": @@ -247,6 +257,9 @@ deps = { Var("source_map_stack_trace_tag"), Var("dart_root") + "/third_party/pkg/stack_trace": (Var("github_mirror") % "stack_trace") + Var("stack_trace_tag"), + Var("dart_root") + "/third_party/pkg/stream_channel": + (Var("github_dartlang") % "stream_channel") + + Var("stream_channel_tag"), Var("dart_root") + "/third_party/pkg/string_scanner": (Var("github_mirror") % "string_scanner") + Var("string_scanner_tag"), @@ -258,6 +271,8 @@ deps = { Var("dart_root") + "/third_party/pkg/test_reflective_loader": (Var("github_mirror") % "test_reflective_loader") + Var("test_reflective_loader_tag"), + Var("dart_root") + "/third_party/pkg/typed_data": + (Var("github_dartlang") % "typed_data") + Var("typed_data_tag"), Var("dart_root") + "/third_party/pkg/usage": (Var("github_mirror") % "usage") + Var("usage_rev"), Var("dart_root") + "/third_party/pkg/utf": @@ -267,6 +282,9 @@ deps = { Var("dart_root") + "/third_party/pkg/web_components": (Var("github_mirror") % "web-components") + Var("web_components_rev"), + Var("dart_root") + "/third_party/pkg/web_socket_channel": + (Var("github_dartlang") % "web_socket_channel") + + Var("web_socket_channel_tag"), Var("dart_root") + "/third_party/pkg/when": (Var("github_mirror") % "when") + Var("when_tag"), Var("dart_root") + "/third_party/pkg/which": diff --git a/pkg/typed_data/LICENSE b/pkg/typed_data/LICENSE deleted file mode 100644 index ee999303130..00000000000 --- a/pkg/typed_data/LICENSE +++ /dev/null @@ -1,26 +0,0 @@ -Copyright 2013, the Dart project authors. All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkg/typed_data/README.md b/pkg/typed_data/README.md deleted file mode 100644 index e1e7db53bed..00000000000 --- a/pkg/typed_data/README.md +++ /dev/null @@ -1,15 +0,0 @@ -Helper libraries for working with typed data lists. - -The `typed_data` package contains utility functions and classes that makes working with typed data lists easier. - -## Using - -The `typed_data` package can be imported as - - import 'package:typed_data/typed_data.dart'; - -## Typed buffers: Growable typed data lists - -Typed buffers are contains growable lists backed by typed arrays. -These are similar to the growable lists returned by `new List()`, -but stores typed data like a typed data list. \ No newline at end of file diff --git a/pkg/typed_data/lib/typed_buffers.dart b/pkg/typed_data/lib/typed_buffers.dart deleted file mode 100644 index 50ed2414c4c..00000000000 --- a/pkg/typed_data/lib/typed_buffers.dart +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) 2013, 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. - -/** - * Growable typed-data lists. - * - * These lists works just as a typed-data list, except that they are growable. - * They use an underlying buffer, and when that buffer becomes too small, it - * is replaced by a new buffer. - * - * That means that using the [TypedDataView.buffer] getter is not guaranteed - * to return the same result each time it is used, and that the buffer may - * be larger than what the list is using. - */ -library dart.pkg.typed_data.typed_buffers; - -import "dart:collection" show ListBase; -import "dart:typed_data"; - -abstract class _TypedDataBuffer extends ListBase { - static const int INITIAL_LENGTH = 8; - - /// This is a Uint8List for Uint8Buffer. It's both a List and a TypedData, - /// which we don't have a type for here. - var _buffer; - /// The length of the list being built. - int _length; - - _TypedDataBuffer(List buffer) - : this._buffer = buffer, this._length = buffer.length; - - int get length => _length; - E operator[](int index) { - if (index >= length) throw new RangeError.index(index, this); - return _buffer[index]; - } - - void operator[]=(int index, E value) { - if (index >= length) throw new RangeError.index(index, this); - _buffer[index] = value; - } - - void set length(int newLength) { - if (newLength < _length) { - E defaultValue = _defaultValue; - for (int i = newLength; i < _length; i++) { - _buffer[i] = defaultValue; - } - } else if (newLength > _buffer.length) { - List newBuffer; - if (_buffer.length == 0) { - newBuffer = _createBuffer(newLength); - } else { - newBuffer = _createBiggerBuffer(newLength); - } - newBuffer.setRange(0, _length, _buffer); - _buffer = newBuffer; - } - _length = newLength; - } - - void _add(E value) { - if (_length == _buffer.length) _grow(); - _buffer[_length++] = value; - } - - // We override the default implementation of `add` and `addAll` because - // they grow by setting the length in increments of one. We want to grow - // by doubling capacity in most cases. - void add(E value) { _add(value); } - - void addAll(Iterable values) { - for (E value in values) _add(value); - } - - void insert(int index, E element) { - if (index < 0 || index > _length) { - throw new RangeError.range(index, 0, _length); - } - if (_length < _buffer.length) { - _buffer.setRange(index + 1, _length + 1, _buffer, index); - _buffer[index] = element; - _length++; - return; - } - List newBuffer = _createBiggerBuffer(null); - newBuffer.setRange(0, index, _buffer); - newBuffer.setRange(index + 1, _length + 1, _buffer, index); - newBuffer[index] = element; - _length++; - _buffer = newBuffer; - } - - /** - * Create a bigger buffer. - * - * This method determines how much bigger a bigger buffer should - * be. If [requiredLength] is not null, it will be at least that - * size. It will always have at least have double the capacity of - * the current buffer. - */ - List _createBiggerBuffer(int requiredLength) { - int newLength = _buffer.length * 2; - if (requiredLength != null && newLength < requiredLength) { - newLength = requiredLength; - } else if (newLength < INITIAL_LENGTH) { - newLength = INITIAL_LENGTH; - } - return _createBuffer(newLength); - } - - void _grow() { - _buffer = _createBiggerBuffer(null)..setRange(0, _length, _buffer); - } - - void setRange(int start, int end, Iterable source, [int skipCount = 0]) { - if (end > _length) throw new RangeError.range(end, 0, _length); - if (source is _TypedDataBuffer) { - _buffer.setRange(start, end, source._buffer, skipCount); - } else { - _buffer.setRange(start, end, source, skipCount); - } - } - - // TypedData. - - int get elementSizeInBytes => _buffer.elementSizeInBytes; - - int get lengthInBytes => _length * _buffer.elementSizeInBytes; - - int get offsetInBytes => _buffer.offsetInBytes; - - /** - * Returns the underlying [ByteBuffer]. - * - * The returned buffer may be replaced by operations that change the [length] - * of this list. - * - * The buffer may be larger than [lengthInBytes] bytes, but never smaller. - */ - ByteBuffer get buffer => _buffer.buffer; - - // Specialization for the specific type. - - // Return zero for integers, 0.0 for floats, etc. - // Used to fill buffer when changing length. - E get _defaultValue; - - // Create a new typed list to use as buffer. - List _createBuffer(int size); -} - -abstract class _IntBuffer extends _TypedDataBuffer { - _IntBuffer(buffer): super(buffer); - int get _defaultValue => 0; -} - -abstract class _FloatBuffer extends _TypedDataBuffer { - _FloatBuffer(buffer): super(buffer); - double get _defaultValue => 0.0; -} - -class Uint8Buffer extends _IntBuffer { - Uint8Buffer([int initialLength = 0]) : super(new Uint8List(initialLength)); - Uint8List _createBuffer(int size) => new Uint8List(size); -} - -class Int8Buffer extends _IntBuffer { - Int8Buffer([int initialLength = 0]) : super(new Int8List(initialLength)); - Int8List _createBuffer(int size) => new Int8List(size); -} - -class Uint8ClampedBuffer extends _IntBuffer { - Uint8ClampedBuffer([int initialLength = 0]) - : super(new Uint8ClampedList(initialLength)); - Uint8ClampedList _createBuffer(int size) => new Uint8ClampedList(size); -} - -class Uint16Buffer extends _IntBuffer { - Uint16Buffer([int initialLength = 0]) : super(new Uint16List(initialLength)); - Uint16List _createBuffer(int size) => new Uint16List(size); -} - -class Int16Buffer extends _IntBuffer { - Int16Buffer([int initialLength = 0]) : super(new Int16List(initialLength)); - Int16List _createBuffer(int size) => new Int16List(size); -} - -class Uint32Buffer extends _IntBuffer { - Uint32Buffer([int initialLength = 0]) : super(new Uint32List(initialLength)); - Uint32List _createBuffer(int size) => new Uint32List(size); -} - -class Int32Buffer extends _IntBuffer { - Int32Buffer([int initialLength = 0]) : super(new Int32List(initialLength)); - Int32List _createBuffer(int size) => new Int32List(size); -} - -class Uint64Buffer extends _IntBuffer { - Uint64Buffer([int initialLength = 0]) : super(new Uint64List(initialLength)); - Uint64List _createBuffer(int size) => new Uint64List(size); -} - -class Int64Buffer extends _IntBuffer { - Int64Buffer([int initialLength = 0]) : super(new Int64List(initialLength)); - Int64List _createBuffer(int size) => new Int64List(size); -} - -class Float32Buffer extends _FloatBuffer { - Float32Buffer([int initialLength = 0]) - : super(new Float32List(initialLength)); - Float32List _createBuffer(int size) => new Float32List(size); -} - -class Float64Buffer extends _FloatBuffer { - Float64Buffer([int initialLength = 0]) - : super(new Float64List(initialLength)); - Float64List _createBuffer(int size) => new Float64List(size); -} - -class Int32x4Buffer extends _TypedDataBuffer { - static Int32x4 _zero = new Int32x4(0, 0, 0, 0); - Int32x4Buffer([int initialLength = 0]) - : super(new Int32x4List(initialLength)); - Int32x4 get _defaultValue => _zero; - Int32x4List _createBuffer(int size) => new Int32x4List(size); -} - -class Float32x4Buffer extends _TypedDataBuffer { - Float32x4Buffer([int initialLength = 0]) - : super(new Float32x4List(initialLength)); - Float32x4 get _defaultValue => new Float32x4.zero(); - Float32x4List _createBuffer(int size) => new Float32x4List(size); -} diff --git a/pkg/typed_data/lib/typed_data.dart b/pkg/typed_data/lib/typed_data.dart deleted file mode 100644 index b6619abda07..00000000000 --- a/pkg/typed_data/lib/typed_data.dart +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2013, 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. - -/** - * Utilities and functionality related to the "dart:typed_data" library. - */ -library dart.pkg.typed_data; - -export "package:typed_data/typed_buffers.dart"; diff --git a/pkg/typed_data/pubspec.yaml b/pkg/typed_data/pubspec.yaml deleted file mode 100644 index b4c394563be..00000000000 --- a/pkg/typed_data/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: typed_data -version: 1.0.1-dev -author: Dart Team -description: Utility functions and classes related to the 'dart:typed_data' library. -homepage: http://www.dartlang.org -dev_dependencies: - unittest: ">=0.9.0 <0.10.0" -environment: - sdk: ">=1.5.0 <2.0.0" diff --git a/pkg/typed_data/test/typed_buffers_test.dart b/pkg/typed_data/test/typed_buffers_test.dart deleted file mode 100644 index 1cb37b00ea5..00000000000 --- a/pkg/typed_data/test/typed_buffers_test.dart +++ /dev/null @@ -1,421 +0,0 @@ -// Copyright (c) 2013, 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. - -// Tests typed-data buffer classes. - -import "package:typed_data/typed_buffers.dart"; -import "package:unittest/unittest.dart"; -import "dart:typed_data"; - -main() { - testUint(8, (l) => new Uint8Buffer(l)); - testInt(8, (l) => new Int8Buffer(l)); - test("Uint8ClampedBuffer", () { - testIntBuffer(8, 0, 255, (l) => new Uint8ClampedBuffer(l), clampUint8); - }); - testUint(16, (l) => new Uint16Buffer(l)); - testInt(16, (l) => new Int16Buffer(l)); - testUint(32, (l) => new Uint32Buffer(l)); /// 01: ok - testInt(32, (l) => new Int32Buffer(l)); - testUint(64, (l) => new Uint64Buffer(l)); /// 01: continued - testInt(64, (l) => new Int64Buffer(l)); /// 01: continued - - testInt32x4Buffer(intSamples); - - List roundedFloatSamples = floatSamples.map(roundToFloat).toList(); - testFloatBuffer(32, roundedFloatSamples, - () => new Float32Buffer(), - roundToFloat); - testFloatBuffer(64, doubleSamples, () => new Float64Buffer(), (x) => x); - - testFloat32x4Buffer(roundedFloatSamples); -} - -double roundToFloat(double value) { - return (new Float32List(1)..[0] = value)[0]; -} - -typedef int Rounder(int value); - -Rounder roundUint(bits) { - int halfbits = (1 << (bits ~/ 2)) - 1; - int mask = halfbits | (halfbits << (bits ~/ 2)); - return (int x) => x & mask; -} - -Rounder roundInt(bits) { - int highBit = 1 << (bits - 1); - int mask = highBit - 1; - return (int x) => (x & mask) - (x & highBit); -} - -int clampUint8(x) => x < 0 ? 0 : x > 255 ? 255 : x; - -void testUint(int bits, var buffer) { - int min = 0; - Function round = roundUint(bits); - int max = round(-1); - test("Uint${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, round); - }); -} - -void testInt(int bits, var buffer) { - int min = -(1 << (bits - 1)); - int max = -(min + 1); - test("Int${bits}Buffer", () { - testIntBuffer(bits, min, max, buffer, roundInt(bits)); - }); -} - -const List intSamples = const [ - 0x10000000000000001, - 0x10000000000000000, // 2^64 - 0x0ffffffffffffffff, - 0xaaaaaaaaaaaaaaaa, - 0x8000000000000001, - 0x8000000000000000, // 2^63 - 0x7fffffffffffffff, - 0x5555555555555555, - 0x100000001, - 0x100000000, // 2^32 - 0x0ffffffff, - 0xaaaaaaaa, - 0x80000001, - 0x80000000, // 2^31 - 0x7fffffff, - 0x55555555, - 0x10001, - 0x10000, // 2^16 - 0x0ffff, - 0xaaaa, - 0x8001, - 0x8000, // 2^15 - 0x7fff, - 0x5555, - 0x101, - 0x100, // 2^8 - 0x0ff, - 0xaa, - 0x81, - 0x80, // 2^7 - 0x7f, - 0x55, - 0x02, - 0x01, - 0x00 -]; - -// Takes bit-size, min value, max value, function to create a buffer, and -// the rounding that is applied when storing values outside the valid range -// into the buffer. -void testIntBuffer(int bits, int min, int max, - create(int length), - int round(int)) { - assert(round(min) == min); - assert(round(max) == max); - // All int buffers default to the value 0. - var buffer = create(0); - List list = buffer; // Check the type. - expect(buffer.length, equals(0)); - var bytes = bits ~/ 8; - - expect(buffer.elementSizeInBytes, equals(bytes)); - expect(buffer.lengthInBytes, equals(0)); - expect(buffer.offsetInBytes, equals(0)); - - buffer.add(min); - expect(buffer.length, equals(1)); - expect(buffer[0], equals(min)); - - expect(buffer.elementSizeInBytes, equals(bytes)); - expect(buffer.lengthInBytes, equals(bytes)); - expect(buffer.offsetInBytes, equals(0)); - - buffer.length = 0; - expect(buffer.length, equals(0)); - - List samples = intSamples.toList()..addAll(intSamples.map((x) => -x)); - for (int value in samples) { - int length = buffer.length; - buffer.add(value); - expect(buffer.length, equals(length + 1)); - expect(buffer[length], equals(round(value))); - } - buffer.addAll(samples); // Add all the values at once. - for (int i = 0; i < samples.length; i++) { - expect(buffer[samples.length + i], equals(buffer[i])); - } - - // Remove range works and changes length. - buffer.removeRange(samples.length, buffer.length); - expect(buffer.length, equals(samples.length)); - - // Both values are in `samples`, but equality is performed without rounding. - expect(buffer.contains(min - 1), isFalse); - expect(buffer.contains(max + 1), isFalse); - expect(buffer.contains(round(min - 1)), isTrue); - expect(buffer.contains(round(max + 1)), isTrue); - - // Accessing the underlying buffer works. - buffer.length = 2; - buffer[0] = min; - buffer[1] = max; - var byteBuffer = new Uint8List.view(buffer.buffer); - int byteSize = buffer.elementSizeInBytes; - for (int i = 0; i < byteSize; i++) { - int tmp = byteBuffer[i]; - byteBuffer[i] = byteBuffer[byteSize + i]; - byteBuffer[byteSize + i] = tmp; - } - expect(buffer[0], equals(max)); - expect(buffer[1], equals(min)); -} - -const List doubleSamples = const [ - 0.0, - 5e-324, // Minimal denormal value. - 2.225073858507201e-308, // Maximal denormal value. - 2.2250738585072014e-308, // Minimal normal value. - 0.9999999999999999, // Maximum value < 1. - 1.0, - 1.0000000000000002, // Minimum value > 1. - 4294967295.0, // 2^32 -1. - 4294967296.0, // 2^32. - 4503599627370495.5, // Maximal fractional value. - 9007199254740992.0, // Maximal exact value (adding one gets lost). - 1.7976931348623157e+308, // Maximal value. - 1.0/0.0, // Infinity. - 0.0/0.0, // NaN. - 0.49999999999999994, // Round-traps 1-3 (adding 0.5 and rounding towards - 4503599627370497.0, // minus infinity will not be the same as rounding - 9007199254740991.0 // to nearest with 0.5 rounding up). -]; - -const List floatSamples = const [ - 0.0, - 1.4e-45, // Minimal denormal value. - 1.1754942E-38, // Maximal denormal value. - 1.17549435E-38, // Minimal normal value. - 0.99999994, // Maximal value < 1. - 1.0, - 1.0000001, // Minimal value > 1. - 8388607.5, // Maximal fractional value. - 16777216.0, // Maximal exact value. - 3.4028235e+38, // Maximal value. - 1.0/0.0, // Infinity. - 0.0/0.0, // NaN. - 0.99999994, // Round traps 1-3. - 8388609.0, - 16777215.0 -]; - -void doubleEqual(x, y) { - if (y.isNaN) { - expect(x.isNaN, isTrue); - } else { - if (x != y) { - } - expect(x, equals(y)); - } -} - -testFloatBuffer(int bitSize, List samples, create(), double round(double v)) { - test("Float${bitSize}Buffer", () { - var buffer = create(); - List list = buffer; // Test type. - int byteSize = bitSize ~/ 8; - - expect(buffer.length, equals(0)); - buffer.add(0.0); - expect(buffer.length, equals(1)); - expect(buffer.removeLast(), equals(0.0)); - expect(buffer.length, equals(0)); - - for (double value in samples) { - buffer.add(value); - doubleEqual(buffer[buffer.length - 1], round(value)); - } - expect(buffer.length, equals(samples.length)); - - buffer.addAll(samples); - expect(buffer.length, equals(samples.length * 2)); - for (int i = 0; i < samples.length; i++) { - doubleEqual(buffer[i], buffer[samples.length + i]); - } - - buffer.removeRange(samples.length, buffer.length); - expect(buffer.length, equals(samples.length)); - - buffer.insertAll(0, samples); - expect(buffer.length, equals(samples.length * 2)); - for (int i = 0; i < samples.length; i++) { - doubleEqual(buffer[i], buffer[samples.length + i]); - } - - buffer.length = samples.length; - expect(buffer.length, equals(samples.length)); - - // TypedData. - expect(buffer.elementSizeInBytes, equals(byteSize)); - expect(buffer.lengthInBytes, equals(byteSize * buffer.length)); - expect(buffer.offsetInBytes, equals(0)); - - // Accessing the buffer works. - // Accessing the underlying buffer works. - buffer.length = 2; - buffer[0] = samples[0]; - buffer[1] = samples[1]; - var bytes = new Uint8List.view(buffer.buffer); - for (int i = 0; i < byteSize; i++) { - int tmp = bytes[i]; - bytes[i] = bytes[byteSize + i]; - bytes[byteSize + i] = tmp; - } - doubleEqual(buffer[0], round(samples[1])); - doubleEqual(buffer[1], round(samples[0])); - }); -} - -testFloat32x4Buffer(List floatSamples) { - List float4Samples = []; - for (int i = 0; i < floatSamples.length - 3; i++) { - float4Samples.add(new Float32x4(floatSamples[i], - floatSamples[i + 1], - floatSamples[i + 2], - floatSamples[i + 3])); - } - - void floatEquals(x, y) { - if (y.isNaN) { - expect(x.isNaN, isTrue); - } else { - expect(x, equals(y)); - } - } - - void x4Equals(Float32x4 x, Float32x4 y) { - floatEquals(x.x, y.x); - floatEquals(x.y, y.y); - floatEquals(x.z, y.z); - floatEquals(x.w, y.w); - } - - test("Float32x4Buffer", () { - var buffer = new Float32x4Buffer(5); - List list = buffer; - - expect(buffer.length, equals(5)); - expect(buffer.elementSizeInBytes, equals(128 ~/ 8)); - expect(buffer.lengthInBytes, equals(5 * 128 ~/ 8)); - expect(buffer.offsetInBytes, equals(0)); - - x4Equals(buffer[0], new Float32x4.zero()); - buffer.length = 0; - expect(buffer.length, equals(0)); - - for (var sample in float4Samples) { - buffer.add(sample); - x4Equals(buffer[buffer.length - 1], sample); - } - expect(buffer.length, equals(float4Samples.length)); - - buffer.addAll(float4Samples); - expect(buffer.length, equals(float4Samples.length * 2)); - for (int i = 0; i < float4Samples.length; i++) { - x4Equals(buffer[i], buffer[float4Samples.length + i]); - } - - buffer.removeRange(4, 4 + float4Samples.length); - for (int i = 0; i < float4Samples.length; i++) { - x4Equals(buffer[i], float4Samples[i]); - } - - // Test underlying buffer. - buffer.length = 1; - buffer[0] = float4Samples[0]; // Does not contain NaN. - - Float32List floats = new Float32List.view(buffer.buffer); - expect(floats[0], equals(buffer[0].x)); - expect(floats[1], equals(buffer[0].y)); - expect(floats[2], equals(buffer[0].z)); - expect(floats[3], equals(buffer[0].w)); - }); -} - -void testInt32x4Buffer(intSamples) { - test("Int32x4Buffer", () { - Function round = roundInt(32); - int bits = 128; - int bytes = 128 ~/ 8; - Matcher equals32x4(Int32x4 expected) => new MatchesInt32x4(expected); - - var buffer = new Int32x4Buffer(0); - List list = buffer; // It's a List. - expect(buffer.length, equals(0)); - - expect(buffer.elementSizeInBytes, equals(bytes)); - expect(buffer.lengthInBytes, equals(0)); - expect(buffer.offsetInBytes, equals(0)); - - Int32x4 sample = new Int32x4(-0x80000000, -1, 0, 0x7fffffff); - buffer.add(sample); - expect(buffer.length, equals(1)); - expect(buffer[0], equals32x4(sample)); - - expect(buffer.elementSizeInBytes, equals(bytes)); - expect(buffer.lengthInBytes, equals(bytes)); - expect(buffer.offsetInBytes, equals(0)); - - buffer.length = 0; - expect(buffer.length, equals(0)); - - var samples = intSamples - .where((value) => value == round(value)) // Issue 15130 - .map((value) => new Int32x4(value, -value, ~value, ~-value)) - .toList(); - for (Int32x4 value in samples) { - int length = buffer.length; - buffer.add(value); - expect(buffer.length, equals(length + 1)); - expect(buffer[length], equals32x4(value)); - } - - buffer.addAll(samples); // Add all the values at once. - for (int i = 0; i < samples.length; i++) { - expect(buffer[samples.length + i], equals32x4(buffer[i])); - } - - // Remove range works and changes length. - buffer.removeRange(samples.length, buffer.length); - expect(buffer.length, equals(samples.length)); - - // Accessing the underlying buffer works. - buffer.length = 2; - buffer[0] = new Int32x4(-80000000, 0x7fffffff, 0, -1); - var byteBuffer = new Uint8List.view(buffer.buffer); - int halfBytes = bytes ~/ 2; - for (int i = 0; i < halfBytes; i++) { - int tmp = byteBuffer[i]; - byteBuffer[i] = byteBuffer[halfBytes + i]; - byteBuffer[halfBytes + i] = tmp; - } - var result = new Int32x4(0, -1, -80000000, 0x7fffffff); - expect(buffer[0], equals32x4(result)); - }); -} - -class MatchesInt32x4 extends Matcher { - Int32x4 result; - MatchesInt32x4(this.result); - bool matches(item, Map matchState) { - if (item is! Int32x4) return false; - Int32x4 value = item; - return result.x == value.x && result.y == value.y && - result.z == value.z && result.w == value.w; - } - - Description describe(Description description) => - description.add('Int32x4.=='); -}