Index: test/mjsunit/harmony/block-let-crankshaft.js |
diff --git a/test/mjsunit/harmony/block-let-crankshaft.js b/test/mjsunit/harmony/block-let-crankshaft.js |
index ba5bc0d4a573cf0ce14de953678c222c54fd3cd1..d744a0063be8446ab62865357d93c76cc5ab73b7 100644 |
--- a/test/mjsunit/harmony/block-let-crankshaft.js |
+++ b/test/mjsunit/harmony/block-let-crankshaft.js |
@@ -25,13 +25,121 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Flags: --harmony-scoping --allow-natives-syntax |
+// Flags: --harmony-scoping --allow-natives-syntax --trace-bailout |
Jakob Kummerow
2011/12/05 16:40:36
I think you should remove --trace-bailout before l
|
// TODO(ES6): properly activate extended mode |
"use strict"; |
+// Check that the following functions are optimizable. |
+var functions = [f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12]; |
+ |
+for (var i = 0; i < functions.length; ++i) { |
+ var func = functions[i]; |
+ print("Testing:"); |
+ print(func); |
+ for (var j = 0; j < 10; ++j) { |
+ func(12); |
+ } |
+ %OptimizeFunctionOnNextCall(func); |
+ func(12); |
+ assertTrue(%GetOptimizationStatus(func) != 2); |
+} |
+ |
+function f1() { } |
+ |
+function f2(x) { } |
+ |
+function f3() { |
+ let x; |
+} |
+ |
+function f4() { |
+ function foo() { |
+ } |
+} |
+ |
+function f5() { |
+ let x = 1; |
+} |
+ |
+function f6() { |
+ const x = 1; |
+} |
+ |
+function f7(x) { |
+ return x; |
+} |
+ |
+function f8() { |
+ let x; |
+ return x; |
+} |
+ |
+function f9() { |
+ function x() { |
+ } |
+ return x; |
+} |
+ |
+function f10(x) { |
+ x = 1; |
+} |
+ |
+function f11() { |
+ let x; |
+ x = 1; |
+} |
+ |
+function f12() { |
+ function x() {}; |
+ x = 1; |
+} |
+ |
+ |
// Test that temporal dead zone semantics for function and block scoped |
-// ket bindings are handled by the optimizing compiler. |
+// let bindings are handled by the optimizing compiler. |
+ |
+function TestFunctionLocal(s) { |
+ 'use strict'; |
+ var func = eval("(function baz(){" + s + "; })"); |
+ print("Testing:"); |
+ print(func); |
+ for (var i = 0; i < 5; ++i) { |
+ try { |
+ func(); |
+ assertUnreachable(); |
+ } catch (e) { |
+ assertInstanceof(e, ReferenceError); |
+ } |
+ } |
+ %OptimizeFunctionOnNextCall(func); |
+ try { |
+ func(); |
+ assertUnreachable(); |
+ } catch (e) { |
+ assertInstanceof(e, ReferenceError); |
+ } |
+} |
+ |
+function TestAll(s) { |
+ TestFunctionLocal(s); |
+} |
+ |
+// Use before initialization in declaration statement. |
+TestAll('let x = x + 1'); |
+TestAll('let x = x += 1'); |
+TestAll('let x = x++'); |
+TestAll('let x = ++x'); |
+TestAll('const x = x + 1'); |
+ |
+// Use before initialization in prior statement. |
+TestAll('x + 1; let x;'); |
+TestAll('x = 1; let x;'); |
+TestAll('x += 1; let x;'); |
+TestAll('++x; let x;'); |
+TestAll('x++; let x;'); |
+TestAll('let y = x; const x = 1;'); |
+ |
function f(x, b) { |
let y = (b ? y : x) + 42; |