Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / Number / prototype / valueOf / S15.7.4.4_A2_T02.js
blob94c443f74d13e2b5d40c6f0379034f61648a6517
1 // Copyright 2009 the Sputnik authors.  All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 info: |
6     The valueOf function is not generic, it cannot be transferred
7     to other kinds of objects for use as a method and there is should be
8     a TypeError exception if its this value is not a Number object
9 es5id: 15.7.4.4_A2_T02
10 description: transferring to the Boolean objects
11 ---*/
13 try {
14   var s1 = new Boolean();
15   s1.valueOf = Number.prototype.valueOf;
16   var v1 = s1.valueOf();
17   throw new Test262Error('#1: Number.prototype.valueOf on not a Number object should throw TypeError');
19 catch (e) {
20   assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true');
23 try {
24   var s2 = new Boolean();
25   s2.myValueOf = Number.prototype.valueOf;
26   var v2 = s2.myValueOf();
27   throw new Test262Error('#2: Number.prototype.valueOf on not a Number object should throw TypeError');
29 catch (e) {
30   assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true');
33 reportCompare(0, 0);