test262/test/suite/intl402/ch11/11.3/11.3.2_1_a_ii.js
Norbert Lindenberg 96321f30c9 New tests and test fixes for ECMAScript Internationalization API.
Updated copyright notice for 2013.
2013-03-24 23:48:59 -07:00

28 lines
842 B
JavaScript

// Copyright 2012 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/**
* @description Tests that Intl.NumberFormat.prototype.format
* converts other types to numbers.
* @author: Roozbeh Pournader
*/
var formatter = new Intl.NumberFormat();
var testData = [undefined, null, true, '0.6666666', {valueOf: function () { return '0.1234567';}}];
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+'"');
}
}