mirror of
https://github.com/tc39/test262.git
synced 2025-05-29 11:10:32 +02:00
intl: increase coverage for the Intl.NumberFormat constructor
Increase coverge for the Intl.NumberFormat constructor by testing that Get(O, P) and ToString(arg) are properly called.
This commit is contained in:
parent
48cf391412
commit
ff8b10c448
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2018 Ujjwal Sharma. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-initializenumberformat
|
||||||
|
description: >
|
||||||
|
Tests that Get(O, P) and ToString(arg) are properly called within the
|
||||||
|
constructor for Intl.NumberFormat
|
||||||
|
info: |
|
||||||
|
9.2.1 CanonicalizeLocaleList ( locales )
|
||||||
|
|
||||||
|
5. Let len be ? ToLength(? Get(O, "length")).
|
||||||
|
|
||||||
|
7.a. Let Pk be ToString(k).
|
||||||
|
|
||||||
|
7.c.i. Let kValue be ? Get(O, Pk).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
const locales = {
|
||||||
|
length: 8,
|
||||||
|
1: 'en-US',
|
||||||
|
3: 'de-DE',
|
||||||
|
5: 'en-IN',
|
||||||
|
7: 'en-GB'
|
||||||
|
};
|
||||||
|
|
||||||
|
const actualLookups = [];
|
||||||
|
const expectedLookups = Object.keys(locales);
|
||||||
|
|
||||||
|
const handlers = {
|
||||||
|
get(obj, prop) {
|
||||||
|
actualLookups.push(prop);
|
||||||
|
return Reflect.get(...arguments);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const proxyLocales = new Proxy(locales, handlers);
|
||||||
|
|
||||||
|
const nf = new Intl.NumberFormat(proxyLocales);
|
||||||
|
|
||||||
|
actualLookups.forEach(lookup => assert(expectedLookups.indexOf(lookup) != -1));
|
Loading…
x
Reference in New Issue
Block a user