summaryrefslogtreecommitdiff
path: root/test/suite/intl402/ch12/12.3/12.3.2_2.js
blob: 09fafe15d66cad37859f7d06ab8b9cacc770db36 (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
// Copyright 2012 Google Inc.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
 * @path intl402/ch12/12.3/12.3.2_2.js
 * @description Tests that Intl.NumberFormat.prototype.format
 * converts other types to numbers.
 * @author: Roozbeh Pournader
 */

var testcase = function() {
  "use strict";

  var formatter = new Intl.NumberFormat();
  var testData = [undefined, null, true, '0.6666666'];
  var number;
  var i, input, correctResult, result;

  for (i in testData) {
    input = testData[i];
    number = +input;
    correctResult = formatter.format(number);
    
    result = formatter.format(input);
    if (result !== correctResult) {
      $ERROR('Intl.NumberFormat does not convert other ' +
        'types to numbers. Input: "'+input+'" Output: "'+result+'" '+
        'Expected output: "'+correctResult+'"');
    }
  }

  return true;
}
runTestCase(testcase);