From ec35b59e88a8d98e5c83795c6acf5dd7f5cc3330 Mon Sep 17 00:00:00 2001
From: Ujjwal Sharma <usharma1998@gmail.com>
Date: Fri, 5 Oct 2018 03:06:44 +0530
Subject: [PATCH] intl: increase coverage for the NumberFormat constructor

Increase the coverage for the constructor for Intl.NumberFormat by
ensuring that HasProperty(O, Pk) is properly called.
---
 .../constructor-locales-hasproperty.js        | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 test/intl402/NumberFormat/constructor-locales-hasproperty.js

diff --git a/test/intl402/NumberFormat/constructor-locales-hasproperty.js b/test/intl402/NumberFormat/constructor-locales-hasproperty.js
new file mode 100644
index 0000000000..40e17127b1
--- /dev/null
+++ b/test/intl402/NumberFormat/constructor-locales-hasproperty.js
@@ -0,0 +1,39 @@
+// 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 HasProperty(O, Pk) is properly called within the constructor for
+  Intl.NumberFormat
+info: |
+  9.2.1 CanonicalizeLocaleList ( locales )
+
+  7.b. Let kPresent be ? HasProperty(O, Pk).
+---*/
+
+const locales = {
+  length: 8,
+  1: 'en-US',
+  3: 'de-DE',
+  5: 'en-IN',
+  7: 'en-GB'
+};
+
+const actualLookups = [];
+
+const handlers = {
+  has(obj, prop) {
+    actualLookups.push(prop);
+    return Reflect.has(...arguments);
+  }
+};
+
+const proxyLocales = new Proxy(locales, handlers);
+
+const nf = new Intl.NumberFormat(proxyLocales);
+
+assert.sameValue(actualLookups.length, locales.length);
+for (index in actualLookups) {
+  assert.sameValue(actualLookups[index], String(index));
+}
-- 
GitLab