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

Unified Diff: test/codegen/expect/lib/math/low_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/double_pow_test.js ('k') | test/codegen/expect/lib/math/math2_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/low_test.js
diff --git a/test/codegen/expect/lib/math/low_test.js b/test/codegen/expect/lib/math/low_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..da86b55d7cd4e73ad6f2dc1e35388d23e6efc90d
--- /dev/null
+++ b/test/codegen/expect/lib/math/low_test.js
@@ -0,0 +1,33 @@
+dart_library.library('lib/math/low_test', null, /* Imports */[
+ 'dart_sdk',
+ 'expect'
+], function load__low_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 low_test = Object.create(null);
+ let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [])))();
+ low_test.main = function() {
+ let n = (2 * (1)[dartx['<<']](32) / 3)[dartx.truncate]();
+ let n2 = (n / 2)[dartx.truncate]();
+ let iterations = 200000;
+ let seed = math.Random.new().nextInt(1 << 16);
+ core.print(dart.str`low_test seed: ${seed}`);
+ let prng = math.Random.new(seed);
+ let low = 0;
+ for (let i = 0; i < iterations; i++) {
+ if (dart.notNull(prng.nextInt(n)) < n2) {
+ low++;
+ }
+ }
+ let diff = (low - (iterations / 2)[dartx.truncate]())[dartx.abs]();
+ core.print(dart.str`${low}, ${diff}`);
+ expect$.Expect.isTrue(dart.notNull(diff) < (iterations / 20)[dartx.truncate]());
+ };
+ dart.fn(low_test.main, VoidTovoid());
+ // Exports:
+ exports.low_test = low_test;
+});
« no previous file with comments | « test/codegen/expect/lib/math/double_pow_test.js ('k') | test/codegen/expect/lib/math/math2_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698