Chromium Code Reviews| Index: src/harmony-math.js |
| diff --git a/test/mjsunit/regress/readonly2.js b/src/harmony-math.js |
| similarity index 71% |
| copy from test/mjsunit/regress/readonly2.js |
| copy to src/harmony-math.js |
| index 4e539250d55cd7656c70d2fa0bd8ef7a97527db0..917166d1093eec26e5c96448f8cbc9addbfb874e 100644 |
| --- a/test/mjsunit/regress/readonly2.js |
| +++ b/src/harmony-math.js |
| @@ -25,38 +25,36 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -Object.defineProperty(this, "x", { writable:true }); |
| - |
| -function s(v) { |
| - v.x = 1; |
| +'use strict'; |
| + |
| +// ES6 draft 09-27-13, section 20.2.2.28. |
| +function MathSign(x) { |
| + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
| + if (x > 0) return 1; |
| + if (x < 0) return -1; |
| + if (x === 0) return x; |
| + return NAN; |
| } |
| -function s_strict(v) { |
| - "use strict"; |
| - v.x = 1; |
| -} |
| -function c(p) { |
| - return {__proto__: p}; |
| +// ES6 draft 09-27-13, section 20.2.2.34. |
| +function MathTrunc(x) { |
| + if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
|
Dmitry Lomov (no reviews)
2013/10/21 07:01:28
Replace with TO_NUMBER_INLINE
|
| + if (x > 0) return MathFloor(x); |
| + if (x < 0) return MathCeil(x); |
| + if (x === 0) return x; |
| + return NAN; |
| } |
| -var o1 = c(this); |
| -var o2 = c(this); |
| -// Initialize the store IC. |
| -s(c(this)); |
| -s(c(this)); |
| -s_strict(c(this)); |
| -s_strict(c(this)); |
| +function ExtendMath() { |
| + %CheckIsBootstrapping(); |
| -// Make x non-writable. |
| -Object.defineProperty(this, "x", { writable:false, value:5 }); |
| - |
| -// Verify that direct setting fails. |
| -o1.x = 20; |
| -assertEquals(5, o1.x); |
| + // Set up the non-enumerable functions on the Math object. |
| + InstallFunctions($Math, DONT_ENUM, $Array( |
| + "sign", MathSign, |
| + "trunc", MathTrunc |
| + )); |
| +} |
| -// Verify that setting through the IC fails. |
| -s(o2); |
| -assertEquals(5, o2.x); |
| -assertThrows("s_strict(o2);", TypeError); |
| +ExtendMath(); |