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

Side by Side Diff: test/codegen/expect/language/range_analysis_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('language/range_analysis_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__range_analysis_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const dart = dart_sdk.dart;
8 const dartx = dart_sdk.dartx;
9 const expect$ = expect.expect;
10 const range_analysis_test = Object.create(null);
11 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
12 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))();
13 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
14 range_analysis_test.bar = function() {
15 let sum = 0;
16 for (let i = 0; i < 10; i++) {
17 for (let j = i - 1; j >= 0; j--) {
18 for (let k = j; k < i; k++) {
19 sum = sum + (i + j + k);
20 }
21 }
22 }
23 return sum;
24 };
25 dart.fn(range_analysis_test.bar, VoidTodynamic());
26 range_analysis_test.test1 = function() {
27 for (let i = 0; i < 20; i++)
28 range_analysis_test.bar();
29 };
30 dart.fn(range_analysis_test.test1, VoidTodynamic());
31 range_analysis_test.test2 = function() {
32 let width = 1073741823;
33 expect$.Expect.equals(width - 1, range_analysis_test.foo(width - 5000, width - 1));
34 expect$.Expect.equals(width, range_analysis_test.foo(width - 5000, width));
35 };
36 dart.fn(range_analysis_test.test2, VoidTodynamic());
37 range_analysis_test.foo = function(n, w) {
38 let x = 0;
39 for (let i = n; dart.test(dart.dsend(i, '<=', w)); i = dart.dsend(i, '+', 1) ) {
40 expect$.Expect.isTrue(dart.dsend(i, '>', 0));
41 x = core.int._check(i);
42 }
43 return x;
44 };
45 dart.fn(range_analysis_test.foo, dynamicAnddynamicTodynamic());
46 range_analysis_test.f = function(a, b) {
47 if (dart.test(dart.dsend(a, '<', b))) {
48 if (dart.test(dart.dsend(a, '>', b))) {
49 dart.throw("unreachable");
50 }
51 return 2;
52 }
53 return 3;
54 };
55 dart.fn(range_analysis_test.f, dynamicAnddynamicTodynamic());
56 range_analysis_test.f1 = function(a, b) {
57 if (dart.test(dart.dsend(a, '<', b))) {
58 if (dart.test(dart.dsend(a, '>', dart.dsend(b, '-', 1)))) {
59 dart.throw("unreachable");
60 }
61 return 2;
62 }
63 return 3;
64 };
65 dart.fn(range_analysis_test.f1, dynamicAnddynamicTodynamic());
66 range_analysis_test.f2 = function(a, b) {
67 if (dart.test(dart.dsend(a, '<', b))) {
68 if (dart.test(dart.dsend(a, '>', dart.dsend(b, '-', 2)))) {
69 return 2;
70 }
71 dart.throw("unreachable");
72 }
73 return 3;
74 };
75 dart.fn(range_analysis_test.f2, dynamicAnddynamicTodynamic());
76 range_analysis_test.g = function() {
77 let i = null;
78 for (i = 0; dart.test(dart.dsend(i, '<', 10)); i = dart.dsend(i, '+', 1)) {
79 if (dart.test(dart.dsend(i, '<', 0))) dart.throw("unreachable");
80 }
81 return i;
82 };
83 dart.fn(range_analysis_test.g, VoidTodynamic());
84 range_analysis_test.h = function(n) {
85 let i = null;
86 for (i = 0; dart.test(dart.dsend(i, '<', n)); i = dart.dsend(i, '+', 1)) {
87 if (dart.test(dart.dsend(i, '<', 0))) dart.throw("unreachable");
88 let j = dart.dsend(i, '-', 1);
89 if (dart.test(dart.dsend(j, '>=', dart.dsend(n, '-', 1)))) dart.throw("unr eachable");
90 }
91 return i;
92 };
93 dart.fn(range_analysis_test.h, dynamicTodynamic());
94 range_analysis_test.test3 = function() {
95 function test_fun(fun) {
96 expect$.Expect.equals(2, dart.dcall(fun, 0, 1));
97 expect$.Expect.equals(3, dart.dcall(fun, 0, 0));
98 for (let i = 0; i < 20; i++)
99 dart.dcall(fun, 0, 1);
100 expect$.Expect.equals(2, dart.dcall(fun, 0, 1));
101 expect$.Expect.equals(3, dart.dcall(fun, 0, 0));
102 }
103 dart.fn(test_fun, dynamicTodynamic());
104 test_fun(range_analysis_test.f);
105 test_fun(range_analysis_test.f1);
106 test_fun(range_analysis_test.f2);
107 expect$.Expect.equals(10, range_analysis_test.g());
108 for (let i = 0; i < 20; i++)
109 range_analysis_test.g();
110 expect$.Expect.equals(10, range_analysis_test.g());
111 expect$.Expect.equals(10, range_analysis_test.h(10));
112 for (let i = 0; i < 20; i++)
113 range_analysis_test.h(10);
114 expect$.Expect.equals(10, range_analysis_test.h(10));
115 };
116 dart.fn(range_analysis_test.test3, VoidTodynamic());
117 range_analysis_test.main = function() {
118 range_analysis_test.test1();
119 range_analysis_test.test2();
120 range_analysis_test.test3();
121 };
122 dart.fn(range_analysis_test.main, VoidTodynamic());
123 // Exports:
124 exports.range_analysis_test = range_analysis_test;
125 });
OLDNEW
« no previous file with comments | « test/codegen/expect/language/range_analysis3_test.js ('k') | test/codegen/expect/language/raw_string_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698