summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Number/S9.1_A1_T1.js
blob: 0b1ba8b0b454633485550e3aee47d35cf4778c78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
    Result of primitive conversion from object is a default value for the
    Object
es5id: 9.1_A1_T1
description: >
    Using operator Number. The operator calls ToPrimitive with hint
    Number
---*/

// CHECK#1
var object = {
  valueOf: function() {
    return "1"
  },
  toString: function() {
    return 0
  }
};

assert.sameValue(
  Number(object),
  1,
  'Number({valueOf: function() {return "1"}, toString: function() {return 0}}) must return 1'
);

// CHECK#2
var object = {
  valueOf: function() {
    return {}
  },
  toString: function() {
    return "0"
  }
};

assert.sameValue(
  Number(object),
  0,
  'Number({valueOf: function() {return {}}, toString: function() {return "0"}}) must return 0'
);

reportCompare(0, 0);