Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: tests/html/typed_arrays_arraybuffer_test.dart

Issue 10780029: ArrayBuffer constructor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tests/html/typed_arrays_5_test.dart ('K') | « tests/html/typed_arrays_5_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/typed_arrays_arraybuffer_test.dart
diff --git a/tests/html/typed_arrays_arraybuffer_test.dart b/tests/html/typed_arrays_arraybuffer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8fd704b5eb94764358139f440bcba79797ae1cc5
--- /dev/null
+++ b/tests/html/typed_arrays_arraybuffer_test.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2012, 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.
+
+#library('typed_arrays_arraybuffer_test');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+main() {
+ useHtmlConfiguration();
+
+ test('constructor', () {
+ var a = new ArrayBuffer(100);
+ expect(a.byteLength, 100);
+ });
+
+ test('slice1', () {
+ var a = new ArrayBuffer(100);
+ var s = a.slice(10, 40);
+ expect(s.byteLength, 30);
+ });
+
+ test('slice2', () {
+ var a = new ArrayBuffer(100);
+ var s = a.slice(10, 400);
+ expect(s.byteLength, 90); // indexes clamped to valid range.
+ });
+
+ test('slice3', () {
+ var a = new ArrayBuffer(100);
+ var s = a.slice(50, 10);
+ expect(s.byteLength, 0); // end before start becomes empty range.
+ });
+
+ test('slice4', () {
+ var a = new ArrayBuffer(100);
+ var s = a.slice(-90, -30);
+ expect(s.byteLength, 60); // negative indexes measure from end.
+ });
+}
« tests/html/typed_arrays_5_test.dart ('K') | « tests/html/typed_arrays_5_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698