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

Side by Side Diff: test/codegen/expect/lib/math/double_pow_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
« no previous file with comments | « test/codegen/expect/lib/math/coin_test.js ('k') | test/codegen/expect/lib/math/low_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 dart_library.library('lib/math/double_pow_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__double_pow_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const _interceptors = dart_sdk._interceptors;
8 const math = dart_sdk.math;
9 const dart = dart_sdk.dart;
10 const dartx = dart_sdk.dartx;
11 const expect$ = expect.expect;
12 const double_pow_test = Object.create(null);
13 let JSArrayOfdouble = () => (JSArrayOfdouble = dart.constFn(_interceptors.JSAr ray$(core.double)))();
14 let doubleAnddoubleTovoid = () => (doubleAnddoubleTovoid = dart.constFn(dart.d efiniteFunctionType(dart.void, [core.double, core.double])))();
15 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
16 double_pow_test.checkVeryClose = function(a, b) {
17 if (a == 0.0) {
18 let minimalDouble = 5e-324;
19 expect$.Expect.equals(true, dart.notNull(b[dartx.abs]()) <= minimalDouble) ;
20 return;
21 }
22 if (b == 0.0) {
23 expect$.Expect.equals(a, b);
24 }
25 let shiftRightBy52 = 2.220446049250313e-16;
26 let shiftedA = (dart.notNull(a) * shiftRightBy52)[dartx.abs]();
27 let limitLow = dart.notNull(a) - dart.notNull(shiftedA);
28 let limitHigh = dart.notNull(a) + dart.notNull(shiftedA);
29 expect$.Expect.equals(false, a == limitLow);
30 expect$.Expect.equals(false, a == limitHigh);
31 expect$.Expect.equals(true, limitLow <= dart.notNull(b));
32 expect$.Expect.equals(true, dart.notNull(b) <= limitHigh);
33 };
34 dart.fn(double_pow_test.checkVeryClose, doubleAnddoubleTovoid());
35 double_pow_test.NaN = core.double.NAN;
36 double_pow_test.Infinity = core.double.INFINITY;
37 dart.defineLazy(double_pow_test, {
38 get samples() {
39 return JSArrayOfdouble().of([double_pow_test.NaN, -double_pow_test.Infinit y, -3.0, -2.0, -1.5, -1.0, -0.5, -0.0, 0.5, 1.0, 1.5, 2.0, 3.0, double_pow_test. Infinity]);
40 },
41 set samples(_) {}
42 });
43 double_pow_test.test = function() {
44 for (let d of double_pow_test.samples) {
45 expect$.Expect.identical(1.0, math.pow(d, 0.0), dart.str`${d}`);
46 expect$.Expect.identical(1.0, math.pow(d, -0.0), dart.str`${d}`);
47 }
48 for (let d of double_pow_test.samples) {
49 expect$.Expect.identical(1.0, math.pow(1.0, d), dart.str`${d}`);
50 }
51 for (let d of double_pow_test.samples) {
52 if (d != 0.0) expect$.Expect.isTrue(math.pow(double_pow_test.NaN, d)[dartx .isNaN], dart.str`${d}`);
53 if (d != 1.0) expect$.Expect.isTrue(math.pow(d, double_pow_test.NaN)[dartx .isNaN], dart.str`${d}`);
54 }
55 for (let d of double_pow_test.samples) {
56 if (dart.notNull(d) < 0 && !dart.test(d[dartx.isInfinite])) {
57 expect$.Expect.isTrue(math.pow(d, 0.5)[dartx.isNaN], dart.str`${d}`);
58 expect$.Expect.isTrue(math.pow(d, -0.5)[dartx.isNaN], dart.str`${d}`);
59 expect$.Expect.isTrue(math.pow(d, 1.5)[dartx.isNaN], dart.str`${d}`);
60 expect$.Expect.isTrue(math.pow(d, -1.5)[dartx.isNaN], dart.str`${d}`);
61 }
62 }
63 for (let d of double_pow_test.samples) {
64 if (dart.notNull(d) < 0) {
65 expect$.Expect.identical(0.0, math.pow(double_pow_test.Infinity, d), dar t.str`${d}`);
66 }
67 if (dart.notNull(d) > 0) {
68 expect$.Expect.identical(double_pow_test.Infinity, math.pow(double_pow_t est.Infinity, d), dart.str`${d}`);
69 }
70 }
71 for (let d of double_pow_test.samples) {
72 if (dart.notNull(d) < 0) {
73 expect$.Expect.identical(double_pow_test.Infinity, math.pow(0.0, d), dar t.str`${d}`);
74 }
75 if (dart.notNull(d) > 0) {
76 expect$.Expect.identical(0.0, math.pow(0.0, d), dart.str`${d}`);
77 }
78 }
79 for (let d of double_pow_test.samples) {
80 if (!dart.test(d[dartx.isInfinite]) && !dart.test(d[dartx.isNaN])) {
81 let dint = d[dartx.toInt]();
82 if (d == dint && dart.test(dint[dartx.isOdd])) {
83 expect$.Expect.identical(-dart.notNull(math.pow(double_pow_test.Infini ty, d)), math.pow(-double_pow_test.Infinity, d));
84 expect$.Expect.identical(-dart.notNull(math.pow(0.0, d)), math.pow(-0. 0, d));
85 continue;
86 }
87 }
88 expect$.Expect.identical(math.pow(double_pow_test.Infinity, d), math.pow(- double_pow_test.Infinity, d));
89 expect$.Expect.identical(math.pow(0.0, d), math.pow(-0.0, d));
90 }
91 for (let d of double_pow_test.samples) {
92 if (dart.notNull(d[dartx.abs]()) < 1) {
93 expect$.Expect.identical(0.0, math.pow(d, double_pow_test.Infinity));
94 } else if (dart.notNull(d[dartx.abs]()) > 1) {
95 expect$.Expect.identical(double_pow_test.Infinity, math.pow(d, double_po w_test.Infinity));
96 } else if (d == -1) {
97 expect$.Expect.identical(1.0, math.pow(d, double_pow_test.Infinity));
98 }
99 expect$.Expect.identical(1 / dart.notNull(math.pow(d, double_pow_test.Infi nity)), math.pow(d, -double_pow_test.Infinity));
100 }
101 double_pow_test.checkVeryClose(16.0, math.pow(4.0, 2.0));
102 double_pow_test.checkVeryClose(math.SQRT2, math.pow(2.0, 0.5));
103 double_pow_test.checkVeryClose(math.SQRT1_2, math.pow(0.5, 0.5));
104 expect$.Expect.identical(5e-324, math.pow(2.0, -1074.0));
105 expect$.Expect.identical(double_pow_test.Infinity, math.pow(10.0, 309.0));
106 expect$.Expect.identical(0.0, math.pow(10.0, -325.0));
107 expect$.Expect.identical(double_pow_test.Infinity, math.pow(-0.0, -922337203 6854775809));
108 };
109 dart.fn(double_pow_test.test, VoidTodynamic());
110 double_pow_test.main = function() {
111 for (let i = 0; i < 10; i++)
112 double_pow_test.test();
113 };
114 dart.fn(double_pow_test.main, VoidTodynamic());
115 // Exports:
116 exports.double_pow_test = double_pow_test;
117 });
OLDNEW
« no previous file with comments | « test/codegen/expect/lib/math/coin_test.js ('k') | test/codegen/expect/lib/math/low_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698