2015-11-17 14:24:55 +00:00
|
|
|
// Copyright 2015 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
// Flags: --allow-natives-syntax --harmony-do-expressions
|
|
|
|
|
2015-11-17 14:51:04 +00:00
|
|
|
"use strict";
|
|
|
|
|
2015-11-17 14:24:55 +00:00
|
|
|
var p = {};
|
|
|
|
var testCases = [
|
2015-11-17 15:24:54 +00:00
|
|
|
{ s:"[1, do { _OSR_ 2 }, 3]", r:[1, 2, 3] },
|
|
|
|
{ s:"[1, ...[2], do { _OSR_ 3 }, 4]", r:[1, 2, 3, 4] },
|
|
|
|
{ s:"[1, ...do { _OSR_ [2,3] }, 4]", r:[1, 2, 3, 4] },
|
|
|
|
{ s:"{ a:do { _OSR_ 1 } }", r:{ a:1 } },
|
|
|
|
{ s:"{ a:do { _OSR_ 2 }, __proto__:p }", r:{ a:2, __proto__:p } },
|
|
|
|
{ s:"{ a:do { _OSR_ 3 }, get b() { return 4; } }", r:{ a:3, b:4 } },
|
|
|
|
{ s:"{ [do { _OSR_ 'b' }]: 3 }", r:{ b:3 } },
|
|
|
|
{ s:"{ [do { _OSR_ 'b' }]: 3, c: 4 }", r:{ b:3, c:4 } },
|
|
|
|
{ s:"{ [do { _OSR_ 'b' }]: 3, __proto__:p }", r:{ b:3, __proto__:p } },
|
2015-11-18 11:45:08 +00:00
|
|
|
{ s:"{ get [do { _OSR_ 'c' }]() { return 4; } }", r:{ c:4 } },
|
2015-11-17 14:51:04 +00:00
|
|
|
{ s:"class { [do { _OSR_ 'f' }]() {} }" },
|
|
|
|
{ s:"class { [do { _OSR_ 'f' }]() {}; g() {} }" },
|
2015-11-17 14:24:55 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
for (var i = 0; i < testCases.length; ++i) {
|
|
|
|
var source = "(function f" + i + "(x) { return " + testCases[i].s + "})";
|
|
|
|
var osr = "for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); }";
|
2015-11-17 14:51:04 +00:00
|
|
|
var result = eval(source.replace("_OSR_", osr))();
|
|
|
|
if (testCases[i].r) assertEquals(testCases[i].r, result);
|
2015-11-17 14:24:55 +00:00
|
|
|
}
|