PR-URL: https://github.com/nodejs/node/pull/49639 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
// Copyright 2023 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Correctness issue:
|
|
// When changing the Number prototype and providing a smi as the locale for
|
|
// String.p.toLocaleLowerCase, the prototype would not be considered.
|
|
// See ecma402 #sec-canonicalizelocalelist.
|
|
|
|
let smi = 123;
|
|
let heapNumber = 1.23;
|
|
|
|
// Test case 1: The number prototype has a length property and a valid locale
|
|
// for Get(O, '0').
|
|
Number.prototype.__proto__ = ['tr'];
|
|
assertEquals('I'.toLocaleLowerCase('tr'),
|
|
'I'.toLocaleLowerCase(smi));
|
|
assertEquals('I'.toLocaleLowerCase('tr'),
|
|
'I'.toLocaleLowerCase(heapNumber));
|
|
|
|
// Test case 2: The number prototype has a length property and an invalid locale
|
|
// for Get(O, '0').
|
|
Number.prototype.__proto__ = [42]; // 42 is not a valid locale.
|
|
assertThrows(() => 'I'.toLocaleLowerCase(smi), TypeError);
|
|
assertThrows(() => 'I'.toLocaleLowerCase(heapNumber), TypeError);
|
|
|
|
// Test case 3: The number prototype has a length property of 0.
|
|
Number.prototype.__proto__ = [];
|
|
assertEquals('I'.toLocaleLowerCase([]),
|
|
'I'.toLocaleLowerCase(smi));
|
|
assertEquals('I'.toLocaleLowerCase([]),
|
|
'I'.toLocaleLowerCase(heapNumber));
|