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

Unified Diff: test/codegen/expect/lib/math/random_secure_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/codegen/expect/lib/math/random_big_test.js ('k') | test/codegen/expect/lib/math/random_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/expect/lib/math/random_secure_test.js
diff --git a/test/codegen/expect/lib/math/random_secure_test.js b/test/codegen/expect/lib/math/random_secure_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..7a0b8f29f1c98a2811983b6a6c13d7781b9d9cf4
--- /dev/null
+++ b/test/codegen/expect/lib/math/random_secure_test.js
@@ -0,0 +1,64 @@
+dart_library.library('lib/math/random_secure_test', null, /* Imports */[
+ 'dart_sdk',
+ 'expect'
+], function load__random_secure_test(exports, dart_sdk, expect) {
+ 'use strict';
+ const core = dart_sdk.core;
+ const math = dart_sdk.math;
+ const dart = dart_sdk.dart;
+ const dartx = dart_sdk.dartx;
+ const expect$ = expect.expect;
+ const random_secure_test = Object.create(null);
+ let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic])))();
+ let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionType(dart.dynamic, [])))();
+ random_secure_test.main = function() {
+ let results = null;
+ let rng0 = null;
+ let rng1 = null;
+ let checkInt = dart.fn(max => {
+ let intVal0 = dart.dsend(rng0, 'nextInt', max);
+ let intVal1 = dart.dsend(rng1, 'nextInt', max);
+ if (dart.test(dart.dsend(max, '>', 1 << 28))) {
+ expect$.Expect.isFalse(dart.dsend(results, 'contains', intVal0));
+ dart.dsend(results, 'add', intVal0);
+ expect$.Expect.isFalse(dart.dsend(results, 'contains', intVal1));
+ dart.dsend(results, 'add', intVal1);
+ }
+ }, dynamicTodynamic());
+ results = [];
+ rng0 = math.Random.secure();
+ for (let i = 0; i <= 32; i++) {
+ rng1 = math.Random.secure();
+ dart.dcall(checkInt, math.pow(2, 32));
+ dart.dcall(checkInt, math.pow(2, 32 - i));
+ dart.dcall(checkInt, 1000000000);
+ }
+ let checkDouble = dart.fn(() => {
+ let doubleVal0 = dart.dsend(rng0, 'nextDouble');
+ let doubleVal1 = dart.dsend(rng1, 'nextDouble');
+ expect$.Expect.isFalse(dart.dsend(results, 'contains', doubleVal0));
+ dart.dsend(results, 'add', doubleVal0);
+ expect$.Expect.isFalse(dart.dsend(results, 'contains', doubleVal1));
+ dart.dsend(results, 'add', doubleVal1);
+ }, VoidTodynamic());
+ results = [];
+ rng0 = math.Random.secure();
+ for (let i = 0; i < 32; i++) {
+ rng1 = math.Random.secure();
+ checkDouble();
+ }
+ let cnt0 = 0;
+ let cnt1 = 0;
+ rng0 = math.Random.secure();
+ for (let i = 0; i < 32; i++) {
+ rng1 = math.Random.secure();
+ cnt0 = cnt0 + (dart.test(dart.dsend(rng0, 'nextBool')) ? 1 : 0);
+ cnt1 = cnt1 + (dart.test(dart.dsend(rng1, 'nextBool')) ? 1 : 0);
+ }
+ expect$.Expect.isTrue(cnt0 > 0 && cnt0 < 32);
+ expect$.Expect.isTrue(cnt1 > 0 && cnt1 < 32);
+ };
+ dart.fn(random_secure_test.main, VoidTodynamic());
+ // Exports:
+ exports.random_secure_test = random_secure_test;
+});
« no previous file with comments | « test/codegen/expect/lib/math/random_big_test.js ('k') | test/codegen/expect/lib/math/random_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698