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

Side by Side Diff: test/codegen/expect/lib/math/random_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 dart_library.library('lib/math/random_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__random_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const math = dart_sdk.math;
8 const _interceptors = dart_sdk._interceptors;
9 const dart = dart_sdk.dart;
10 const dartx = dart_sdk.dartx;
11 const expect$ = expect.expect;
12 const random_test = Object.create(null);
13 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c ore.int)))();
14 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
15 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core .int, [])))();
16 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT ype(core.bool, [dart.dynamic])))();
17 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
18 random_test.main = function() {
19 random_test.checkSequence();
20 random_test.checkSeed();
21 };
22 dart.fn(random_test.main, VoidTodynamic());
23 random_test.checkSequence = function() {
24 let rnd = math.Random.new(20130307);
25 let i = 1;
26 expect$.Expect.equals(0, rnd.nextInt((i = i * 2)));
27 expect$.Expect.equals(3, rnd.nextInt((i = i * 2)));
28 expect$.Expect.equals(7, rnd.nextInt((i = i * 2)));
29 expect$.Expect.equals(5, rnd.nextInt((i = i * 2)));
30 expect$.Expect.equals(29, rnd.nextInt((i = i * 2)));
31 expect$.Expect.equals(17, rnd.nextInt((i = i * 2)));
32 expect$.Expect.equals(104, rnd.nextInt((i = i * 2)));
33 expect$.Expect.equals(199, rnd.nextInt((i = i * 2)));
34 expect$.Expect.equals(408, rnd.nextInt((i = i * 2)));
35 expect$.Expect.equals(362, rnd.nextInt((i = i * 2)));
36 expect$.Expect.equals(995, rnd.nextInt((i = i * 2)));
37 expect$.Expect.equals(2561, rnd.nextInt((i = i * 2)));
38 expect$.Expect.equals(2548, rnd.nextInt((i = i * 2)));
39 expect$.Expect.equals(9553, rnd.nextInt((i = i * 2)));
40 expect$.Expect.equals(2628, rnd.nextInt((i = i * 2)));
41 expect$.Expect.equals(42376, rnd.nextInt((i = i * 2)));
42 expect$.Expect.equals(101848, rnd.nextInt((i = i * 2)));
43 expect$.Expect.equals(85153, rnd.nextInt((i = i * 2)));
44 expect$.Expect.equals(495595, rnd.nextInt((i = i * 2)));
45 expect$.Expect.equals(647122, rnd.nextInt((i = i * 2)));
46 expect$.Expect.equals(793546, rnd.nextInt((i = i * 2)));
47 expect$.Expect.equals(1073343, rnd.nextInt((i = i * 2)));
48 expect$.Expect.equals(4479969, rnd.nextInt((i = i * 2)));
49 expect$.Expect.equals(9680425, rnd.nextInt((i = i * 2)));
50 expect$.Expect.equals(28460171, rnd.nextInt((i = i * 2)));
51 expect$.Expect.equals(49481738, rnd.nextInt((i = i * 2)));
52 expect$.Expect.equals(9878974, rnd.nextInt((i = i * 2)));
53 expect$.Expect.equals(132552472, rnd.nextInt((i = i * 2)));
54 expect$.Expect.equals(210267283, rnd.nextInt((i = i * 2)));
55 expect$.Expect.equals(125422442, rnd.nextInt((i = i * 2)));
56 expect$.Expect.equals(226275094, rnd.nextInt((i = i * 2)));
57 expect$.Expect.equals(1639629168, rnd.nextInt((i = i * 2)));
58 expect$.Expect.equals(4294967296, i);
59 expect$.Expect.throws(dart.fn(() => rnd.nextInt(i + 1), VoidToint()), dart.f n(e => core.ArgumentError.is(e), dynamicTobool()));
60 rnd = math.Random.new(6790);
61 expect$.Expect.approxEquals(0.1202733131, rnd.nextDouble());
62 expect$.Expect.approxEquals(0.5554054805, rnd.nextDouble());
63 expect$.Expect.approxEquals(0.0385160727, rnd.nextDouble());
64 expect$.Expect.approxEquals(0.2836345217, rnd.nextDouble());
65 };
66 dart.fn(random_test.checkSequence, VoidTovoid());
67 random_test.checkSeed = function() {
68 let rawSeed = 7216285470301553;
69 let expectations = JSArrayOfint().of([26007, 43006, 46458, 18610, 16413, 504 55, 2164, 47399, 8859, 9732, 20367, 33935, 54549, 54913, 4819, 24198, 49353, 222 77, 51852, 35959, 45347, 12100, 10136, 22372, 15293, 20066, 1351, 49030, 64845, 12793, 50916, 55784, 43170, 27653, 34696, 1492, 50255, 9597, 45929, 2874, 27629, 53084, 36064, 42140, 32016, 41751, 13967, 20516, 578, 16773, 53064, 14814, 2273 7, 48846, 45147, 10205, 56584, 63711, 44128, 21099, 47966, 35471, 39576, 1141, 4 5716, 54940, 57406, 15437, 31721, 35044, 28136, 39797, 50801, 22184, 58686]);
70 let negative_seed_expectations = JSArrayOfint().of([12170, 42844, 39228, 640 32, 29046, 57572, 8453, 52224, 27060, 28454, 20510, 28804, 59221, 53422, 11047, 50864, 33997, 19611, 1250, 65088, 19690, 11396, 20, 48867, 44862, 47129, 58724, 13325, 50005, 33320, 16523, 4740, 63721, 63272, 30545, 51403, 35845, 3943, 31850 , 23148, 26307, 1724, 29281, 39988, 43653, 48012, 43810, 16755, 13105, 25325, 32 648, 19958, 38838, 8322, 3421, 28624, 17269, 45385, 50680, 1696, 26088, 2787, 48 566, 34357, 27731, 51764, 8455, 16498, 59721, 59568, 46333, 7935, 51459, 36766, 50711]);
71 for (let i = 0, m = 1; i < 75; i++) {
72 expect$.Expect.equals(expectations[dartx.get](i), math.Random.new(rawSeed * m).nextInt(65536));
73 expect$.Expect.equals(negative_seed_expectations[dartx.get](i), math.Rando m.new(rawSeed * -m).nextInt(65536));
74 m = m * 2;
75 }
76 expect$.Expect.equals(21391, math.Random.new(0).nextInt(65536));
77 };
78 dart.fn(random_test.checkSeed, VoidTovoid());
79 // Exports:
80 exports.random_test = random_test;
81 });
OLDNEW
« no previous file with comments | « test/codegen/expect/lib/math/random_secure_test.js ('k') | test/codegen/expect/lib/math/rectangle_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698