Backed out 2 changesets (bug 1908320) for causing wr failures on align-items-baseline...
[gecko.git] / js / src / tests / test262 / built-ins / Number / prototype / valueOf / S15.7.4.4_A2_T01.js
blob15d7fa57b7c16e1e01f0d66b924c2ee968f712c4
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_T01
10 description: transferring to the String objects
11 ---*/
13 try {
14   var s1 = new String();
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 String();
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);