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

Unified Diff: test/mjsunit/harmony/toMethod.js

Issue 418143007: FYI Implementing 'super' keyword (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: one more test Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/toMethod.js
diff --git a/test/mjsunit/never-optimize.js b/test/mjsunit/harmony/toMethod.js
similarity index 75%
copy from test/mjsunit/never-optimize.js
copy to test/mjsunit/harmony/toMethod.js
index 643588ebf41e84c5d42bef8829d9ceb1e756841c..ec8703d960477dfc8885de65bd6cfec1b8d4c4ee 100644
--- a/test/mjsunit/never-optimize.js
+++ b/test/mjsunit/harmony/toMethod.js
@@ -24,40 +24,39 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (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: --allow-natives-syntax
-function o1() {
-}
-if (%GetOptimizationStatus(o1) != 4) {
- // 4 == optimization disabled.
- o1(); o1();
- %OptimizeFunctionOnNextCall(o1);
- o1();
+(function () {
+ function f(x) {
+ var a = [0, 1, 2]
+ return a[x];
+ }
+
+ function ClassD() { }
- // Check that the given function was optimized.
- assertOptimized(o1);
+ assertEquals(1, f(1));
+ var g = %ToMethod(f, ClassD);
+ assertEquals(1, g(1));
+}());
- // Test the %NeverOptimizeFunction runtime call.
- %NeverOptimizeFunction(u1);
- function u1() {
- }
- function u2() {
- u1();
+(function () {
+ function f(x) {
+ return function g(y) { x++; return x + y; };
}
- u1(); u1();
- u2(); u2();
-
- %OptimizeFunctionOnNextCall(u1);
- %OptimizeFunctionOnNextCall(u2);
+ function Base() {}
+ function Derived() { }
+ Derived.prototype = Object.create(Base.prototype);
- u1(); u1();
- u2(); u2();
- // 2 => not optimized.
- assertUnoptimized(u1);
- assertOptimized(u2);
-}
+ var q = f(0);
+ assertEquals(2, q(1));
+ assertEquals(3, q(1));
+ var g = %ToMethod(q, Derived);
+ assertFalse(g === q);
+ assertEquals(4, g(1));
+ assertEquals(5, q(1));
+}());

Powered by Google App Engine
This is Rietveld 408576698