keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 1 | // Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 | // This code is governed by the BSD license found in the LICENSE file. |
| 3 | |
| 4 | /*--- |
| 5 | info: > |
| 6 | Number([value]) returns a number value (not a Number object) computed by |
| 7 | ToNumber(value) if value was supplied |
| 8 | es5id: 15.7.1.1_A1 |
| 9 | description: Used values "10", 10, new String("10"), new Object(10) and "abc" |
| 10 | ---*/ |
| 11 | |
| 12 | //CHECK#1 |
| 13 | if( typeof Number("10") !== "number" ) { |
| 14 | $ERROR('#1: typeof Number("10") should be "number", actual is "'+typeof Number("10")+'"'); |
| 15 | } |
| 16 | |
| 17 | //CHECK#2 |
| 18 | if( typeof Number(10) !== "number" ) { |
| 19 | $ERROR('#2: typeof Number(10) should be "number", actual is "'+typeof Number(10)+'"'); |
| 20 | } |
| 21 | |
| 22 | //CHECK#3 |
| 23 | if( typeof Number(new String("10")) !== "number" ) { |
| 24 | $ERROR('#3: typeof Number(new String("10")) should be "number", actual is "'+typeof Number(new String("10"))+'"'); |
| 25 | } |
| 26 | |
| 27 | //CHECK#4 |
| 28 | if( typeof Number(new Object(10)) !== "number" ) { |
| 29 | $ERROR('#4: typeof Number(new Object(10)) should be "number", actual is "'+typeof Number(new Object(10))+'"'); |
| 30 | } |
| 31 | |
| 32 | //CHECK #5 |
| 33 | assert.sameValue(Number("abc"), NaN, "Number('abc')"); |