~ubuntu-branches/ubuntu/saucy/libv8/saucy

« back to all changes in this revision

Viewing changes to test/mjsunit/harmony/block-let-crankshaft.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2012-04-07 16:26:13 UTC
  • mfrom: (15.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120407162613-dqo1m6w9r3fh8tst
Tags: 3.8.9.16-3
* mipsel build fixes :
  + v8_use_mips_abi_hardfloat=false, this lowers EABI requirements.
  + v8_can_use_fpu_instructions=false, detect if FPU is present.
  + set -Wno-unused-but-set-variable only on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
// TODO(ES6): properly activate extended mode
31
31
"use strict";
32
32
 
 
33
// Check that the following functions are optimizable.
 
34
var functions = [ f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14,
 
35
                  f15, f16, f17, f18, f19, f20, f21, f22, f23 ];
 
36
 
 
37
for (var i = 0; i < functions.length; ++i) {
 
38
  var func = functions[i];
 
39
  print("Testing:");
 
40
  print(func);
 
41
  for (var j = 0; j < 10; ++j) {
 
42
    func(12);
 
43
  }
 
44
  %OptimizeFunctionOnNextCall(func);
 
45
  func(12);
 
46
  assertTrue(%GetOptimizationStatus(func) != 2);
 
47
}
 
48
 
 
49
function f1() { }
 
50
 
 
51
function f2(x) { }
 
52
 
 
53
function f3() {
 
54
  let x;
 
55
}
 
56
 
 
57
function f4() {
 
58
  function foo() {
 
59
  }
 
60
}
 
61
 
 
62
function f5() {
 
63
  let x = 1;
 
64
}
 
65
 
 
66
function f6() {
 
67
  const x = 1;
 
68
}
 
69
 
 
70
function f7(x) {
 
71
  return x;
 
72
}
 
73
 
 
74
function f8() {
 
75
  let x;
 
76
  return x;
 
77
}
 
78
 
 
79
function f9() {
 
80
  function x() {
 
81
  }
 
82
  return x;
 
83
}
 
84
 
 
85
function f10(x) {
 
86
  x = 1;
 
87
}
 
88
 
 
89
function f11() {
 
90
  let x;
 
91
  x = 1;
 
92
}
 
93
 
 
94
function f12() {
 
95
  function x() {};
 
96
  x = 1;
 
97
}
 
98
 
 
99
function f13(x) {
 
100
  (function() { x; });
 
101
}
 
102
 
 
103
function f14() {
 
104
  let x;
 
105
  (function() { x; });
 
106
}
 
107
 
 
108
function f15() {
 
109
  function x() {
 
110
  }
 
111
  (function() { x; });
 
112
}
 
113
 
 
114
function f16() {
 
115
  let x = 1;
 
116
  (function() { x; });
 
117
}
 
118
 
 
119
function f17() {
 
120
  const x = 1;
 
121
  (function() { x; });
 
122
}
 
123
 
 
124
function f18(x) {
 
125
  return x;
 
126
  (function() { x; });
 
127
}
 
128
 
 
129
function f19() {
 
130
  let x;
 
131
  return x;
 
132
  (function() { x; });
 
133
}
 
134
 
 
135
function f20() {
 
136
  function x() {
 
137
  }
 
138
  return x;
 
139
  (function() { x; });
 
140
}
 
141
 
 
142
function f21(x) {
 
143
  x = 1;
 
144
  (function() { x; });
 
145
}
 
146
 
 
147
function f22() {
 
148
  let x;
 
149
  x = 1;
 
150
  (function() { x; });
 
151
}
 
152
 
 
153
function f23() {
 
154
  function x() { }
 
155
  x = 1;
 
156
  (function() { x; });
 
157
}
 
158
 
 
159
 
33
160
// Test that temporal dead zone semantics for function and block scoped
34
 
// ket bindings are handled by the optimizing compiler.
 
161
// let bindings are handled by the optimizing compiler.
 
162
 
 
163
function TestFunctionLocal(s) {
 
164
  'use strict';
 
165
  var func = eval("(function baz(){" + s + "; })");
 
166
  print("Testing:");
 
167
  print(func);
 
168
  for (var i = 0; i < 5; ++i) {
 
169
    try {
 
170
      func();
 
171
      assertUnreachable();
 
172
    } catch (e) {
 
173
      assertInstanceof(e, ReferenceError);
 
174
    }
 
175
  }
 
176
  %OptimizeFunctionOnNextCall(func);
 
177
  try {
 
178
    func();
 
179
    assertUnreachable();
 
180
  } catch (e) {
 
181
    assertInstanceof(e, ReferenceError);
 
182
  }
 
183
}
 
184
 
 
185
function TestFunctionContext(s) {
 
186
  'use strict';
 
187
  var func = eval("(function baz(){ " + s + "; (function() { x; }); })");
 
188
  print("Testing:");
 
189
  print(func);
 
190
  for (var i = 0; i < 5; ++i) {
 
191
    print(i);
 
192
    try {
 
193
      func();
 
194
      assertUnreachable();
 
195
    } catch (e) {
 
196
      assertInstanceof(e, ReferenceError);
 
197
    }
 
198
  }
 
199
  print("optimize");
 
200
  %OptimizeFunctionOnNextCall(func);
 
201
  try {
 
202
    print("call");
 
203
    func();
 
204
    assertUnreachable();
 
205
  } catch (e) {
 
206
    print("catch");
 
207
    assertInstanceof(e, ReferenceError);
 
208
  }
 
209
}
 
210
 
 
211
function TestAll(s) {
 
212
  TestFunctionLocal(s);
 
213
  TestFunctionContext(s);
 
214
}
 
215
 
 
216
// Use before initialization in declaration statement.
 
217
TestAll('let x = x + 1');
 
218
TestAll('let x = x += 1');
 
219
TestAll('let x = x++');
 
220
TestAll('let x = ++x');
 
221
TestAll('const x = x + 1');
 
222
 
 
223
// Use before initialization in prior statement.
 
224
TestAll('x + 1; let x;');
 
225
TestAll('x = 1; let x;');
 
226
TestAll('x += 1; let x;');
 
227
TestAll('++x; let x;');
 
228
TestAll('x++; let x;');
 
229
TestAll('let y = x; const x = 1;');
 
230
 
35
231
 
36
232
function f(x, b) {
37
233
  let y = (b ? y : x) + 42;