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

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

Issue 131103025: Fixes ABI bug in MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test_sample_extension_no_autoscope;
6
7 import 'sample_asynchronous_extension_no_autoscope.dart';
8
9 void check(bool condition, String message) {
10 if (!condition) {
11 throw new StateError(message);
12 }
13 }
14
15 void main() {
16 RandomArray r = new RandomArray();
17 r.randomArray(17, 100).then((list_100) {
18 r.randomArray(17, 200).then((list_200) {
19 for (var i = 0; i < 100; ++i) {
20 check(list_100[i] == list_200[i], "list_100[i] == list_200[i]");
21 }
22 });
23 });
24
25 // Gets a list of 256000 random uint8 values, using seed 19, and
26 // runs checkNormal on that list.
27 r.randomArray(19, 256000).then(checkNormal);
28 }
29
30 void checkNormal(List l) {
31 // Count how many times each byte value occurs. Assert that the counts
32 // are all within a reasonable (six-sigma) range.
33 List counts = new List<int>.filled(256, 0);
34 for (var e in l) { counts[e]++; }
35 new RandomArray().randomArray(18, 256000).then(checkCorrelation(counts));
36 }
37
38 Function checkCorrelation(List counts) {
39 return (List l) {
40 List counts_2 = new List<int>.filled(256, 0);
41 for (var e in l) { counts_2[e]++; }
42 var product = 0;
43 for (var i = 0; i < 256; ++i) {
44 check(counts[i] < 1200, "counts[i] < 1200");
45 check(counts_2[i] < 1200, "counts_2[i] < 1200");
46 check(counts[i] > 800, "counts[i] > 800");
47 check(counts[i] > 800, "counts[i] > 800");
48
49 product += counts[i] * counts_2[i];
50 }
51 check(product < 256000000 * 1.001, "product < 256000000 * 1.001");
52 check(product > 256000000 * 0.999, "product > 256000000 * 0.999");
53 };
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698