Index: test/mjsunit/compiler/boolean-protototype.js |
diff --git a/test/mjsunit/compiler/boolean-protototype.js b/test/mjsunit/compiler/boolean-protototype.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5e940d75aed53a3ec9eec678c4e1dfafb29d2d36 |
--- /dev/null |
+++ b/test/mjsunit/compiler/boolean-protototype.js |
@@ -0,0 +1,43 @@ |
+// 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 |
+ |
+function test1(s) { |
+ return s.toString; |
+} |
+assertSame(test1(false), Boolean.prototype.toString); |
+assertSame(test1(true), Boolean.prototype.toString); |
+%OptimizeFunctionOnNextCall(test1); |
+assertSame(test1(false), Boolean.prototype.toString); |
+assertSame(test1(true), Boolean.prototype.toString); |
+ |
+function test2(s) { |
+ return s.valueOf; |
+} |
+assertSame(test2(false), Boolean.prototype.valueOf); |
+assertSame(test2(true), Boolean.prototype.valueOf); |
+%OptimizeFunctionOnNextCall(test2); |
+assertSame(test2(false), Boolean.prototype.valueOf); |
+assertSame(test2(true), Boolean.prototype.valueOf); |
+ |
+Boolean.prototype.foo = 42; |
+function test3(s) { |
+ return s["foo"]; |
+} |
+assertEquals(test3(false), 42); |
+assertEquals(test3(true), 42); |
+%OptimizeFunctionOnNextCall(test3); |
+assertEquals(test3(false), 42); |
+assertEquals(test3(true), 42); |
+ |
+Boolean.prototype.bar = function bar() { "use strict"; return this; } |
+function test4(s) { |
+ return s.bar(); |
+} |
+assertEquals(test4(false), false); |
+assertEquals(test4(true), true); |
+%OptimizeFunctionOnNextCall(test4); |
+assertEquals(test4(false), false); |
+assertEquals(test4(true), true); |