From 940d8698d1faaaa6bdb3307713095e112d4f122c Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 1 Feb 2016 16:57:31 -0800 Subject: [PATCH] Add test with duplicate keys. Per https://github.com/tc39/test262/pull/484#issuecomment-178145781 --- .../duplicate-keys.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/built-ins/Object/getOwnPropertyDescriptors/duplicate-keys.js diff --git a/test/built-ins/Object/getOwnPropertyDescriptors/duplicate-keys.js b/test/built-ins/Object/getOwnPropertyDescriptors/duplicate-keys.js new file mode 100644 index 0000000000..7960a2759f --- /dev/null +++ b/test/built-ins/Object/getOwnPropertyDescriptors/duplicate-keys.js @@ -0,0 +1,31 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Object.getOwnPropertyDescriptors on a proxy with duplicate ownKeys should work +esid: pending +author: Jordan Harband +features: [Proxy] +---*/ + +var i = 0; +var descriptors = [ + { enumerable: false, value: "A1", writable: true, configurable: true }, + { enumerable: true, value: "A2", writable: true, configurable: true } +]; +var log = ''; +var proxy = new Proxy({}, { + ownKeys() { + log += 'ownKeys|'; + return ['DUPLICATE', 'DUPLICATE', 'DUPLICATE']; + }, + getOwnPropertyDescriptor(t, name) { + log += 'getOwnPropertyDescriptor:' + name + '|'; + return descriptors[i++]; + } +}); + +var result = Object.getOwnPropertyDescriptors(proxy); +assert.sameValue(result.hasOwnProperty('DUPLICATE'), true); +assert.sameValue(result.DUPLICATE, undefined); +assert.sameValue(log, 'ownKeys|getOwnPropertyDescriptor:DUPLICATE|getOwnPropertyDescriptor:DUPLICATE|getOwnPropertyDescriptor:DUPLICATE');