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

Side by Side Diff: samples/sample_extension/test_sample_asynchronous_extension.dart

Issue 13956006: Remove insertRange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebuild DOM (unrelated CL) and update status files. Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test_sample_extension; 5 library test_sample_extension;
6 6
7 import 'sample_asynchronous_extension.dart'; 7 import 'sample_asynchronous_extension.dart';
8 8
9 // TODO(3008): Run this test automatically on buildbot (dart:3008). 9 // TODO(3008): Run this test automatically on buildbot (dart:3008).
10 void main() { 10 void main() {
11 RandomArray r = new RandomArray(); 11 RandomArray r = new RandomArray();
12 r.randomArray(100, 17, (list_100) { 12 r.randomArray(100, 17, (list_100) {
13 r.randomArray(200, 17, (list_200) { 13 r.randomArray(200, 17, (list_200) {
14 for (var i = 0; i < 100; ++i) { 14 for (var i = 0; i < 100; ++i) {
15 Expect.equals(list_100[i], list_200[i]); 15 Expect.equals(list_100[i], list_200[i]);
16 } 16 }
17 }); 17 });
18 }); 18 });
19 19
20 // Gets a list of 256000 random uint8 values, using seed 19, and 20 // Gets a list of 256000 random uint8 values, using seed 19, and
21 // runs checkNormal on that list. 21 // runs checkNormal on that list.
22 r.randomArray(256000, 19, checkNormal); 22 r.randomArray(256000, 19, checkNormal);
23 } 23 }
24 24
25 void checkNormal(List l) { 25 void checkNormal(List l) {
26 // Count how many times each byte value occurs. Assert that the counts 26 // Count how many times each byte value occurs. Assert that the counts
27 // are all withing a reasonable (six-sigma) range. 27 // are all withing a reasonable (six-sigma) range.
28 List counts = new List<int>(); 28 List counts = new List<int>.filled(256, 0);
29 counts.insertRange(0, 256, 0);
30 for (var e in l) { counts[e]++; } 29 for (var e in l) { counts[e]++; }
31 new RandomArray().randomArray(256000, 18, checkCorrelation(counts)); 30 new RandomArray().randomArray(256000, 18, checkCorrelation(counts));
32 } 31 }
33 32
34 void checkCorrelation(List counts) { 33 void checkCorrelation(List counts) {
35 return (List l) { 34 return (List l) {
36 List counts_2 = new List<int>(); 35 List counts_2 = new List<int>.filled(256, 0);
37 counts_2.insertRange(0, 256, 0);
38 for (var e in l) { counts_2[e]++; } 36 for (var e in l) { counts_2[e]++; }
39 var product = 0; 37 var product = 0;
40 for (var i = 0; i < 256; ++i) { 38 for (var i = 0; i < 256; ++i) {
41 Expect.isTrue(counts[i] < 1200); 39 Expect.isTrue(counts[i] < 1200);
42 Expect.isTrue(counts_2[i] < 1200); 40 Expect.isTrue(counts_2[i] < 1200);
43 Expect.isTrue(counts[i] > 800); 41 Expect.isTrue(counts[i] > 800);
44 Expect.isTrue(counts[i] > 800); 42 Expect.isTrue(counts[i] > 800);
45 43
46 product += counts[i] * counts_2[i]; 44 product += counts[i] * counts_2[i];
47 } 45 }
48 Expect.isTrue(product < 256000000 * 1.001); 46 Expect.isTrue(product < 256000000 * 1.001);
49 Expect.isTrue(product > 256000000 * 0.999); 47 Expect.isTrue(product > 256000000 * 0.999);
50 }; 48 };
51 } 49 }
OLDNEW
« no previous file with comments | « runtime/tests/vm/dart/byte_array_test.dart ('k') | samples/swarm/swarm_ui_lib/observable/observable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698