• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013 the V8 project authors. All rights reserved.
2# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions
6# are met:
7# 1.  Redistributions of source code must retain the above copyright
8#     notice, this list of conditions and the following disclaimer.
9# 2.  Redistributions in binary form must reproduce the above copyright
10#     notice, this list of conditions and the following disclaimer in the
11#     documentation and/or other materials provided with the distribution.
12#
13# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24This test checks a few Number.toFixed cases, including 5307: Number.toFixed does not round 0.5 up and 5308: Number.toFixed does not include leading zero.
25
26On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
27
28
29PASS (0).toFixed(0) is '0'
30PASS (0.49).toFixed(0) is '0'
31PASS (0.5).toFixed(0) is '1'
32PASS (0.51).toFixed(0) is '1'
33PASS (-0.49).toFixed(0) is '-0'
34PASS (-0.5).toFixed(0) is '-1'
35PASS (-0.51).toFixed(0) is '-1'
36PASS (0).toFixed(1) is '0.0'
37PASS (0.449).toFixed(1) is '0.4'
38PASS (0.45).toFixed(1) is '0.5'
39PASS (0.451).toFixed(1) is '0.5'
40PASS (0.5).toFixed(1) is '0.5'
41PASS (0.549).toFixed(1) is '0.5'
42PASS (0.55).toFixed(1) is '0.6'
43PASS (0.551).toFixed(1) is '0.6'
44PASS (-0.449).toFixed(1) is '-0.4'
45PASS (-0.45).toFixed(1) is '-0.5'
46PASS (-0.451).toFixed(1) is '-0.5'
47PASS (-0.5).toFixed(1) is '-0.5'
48PASS (-0.549).toFixed(1) is '-0.5'
49PASS (-0.55).toFixed(1) is '-0.6'
50PASS (-0.551).toFixed(1) is '-0.6'
51PASS (0.0).toFixed(4) is "0.0000"
52PASS (-0.0).toFixed(4) is "0.0000"
53PASS (0.0).toFixed() is "0"
54PASS (-0.0).toFixed() is "0"
55PASS (1234.567).toFixed() is "1235"
56PASS (1234.567).toFixed(0) is "1235"
57PASS (1234.567).toFixed(null) is "1235"
58PASS (1234.567).toFixed(false) is "1235"
59PASS (1234.567).toFixed('foo') is "1235"
60PASS (1234.567).toFixed(nan) is "1235"
61PASS (1234.567).toFixed(1) is "1234.6"
62PASS (1234.567).toFixed(true) is "1234.6"
63PASS (1234.567).toFixed('1') is "1234.6"
64PASS (1234.567).toFixed(2) is "1234.57"
65PASS (1234.567).toFixed(2.9) is "1234.57"
66PASS (1234.567).toFixed(5) is "1234.56700"
67PASS (1234.567).toFixed(20) is "1234.56700000000000727596"
68PASS (1234.567).toFixed(21) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
69PASS (1234.567).toFixed(100) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
70PASS (1234.567).toFixed(101) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
71PASS (1234.567).toFixed(-1) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
72PASS (1234.567).toFixed(-4) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
73PASS (1234.567).toFixed(-5) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
74PASS (1234.567).toFixed(-20) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
75PASS (1234.567).toFixed(-21) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
76PASS (1234.567).toFixed(posInf) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
77PASS (1234.567).toFixed(negInf) threw exception RangeError: toFixed() digits argument must be between 0 and 20.
78PASS posInf.toFixed() is "Infinity"
79PASS negInf.toFixed() is "-Infinity"
80PASS nan.toFixed() is "NaN"
81PASS successfullyParsed is true
82
83TEST COMPLETE
84
85