From 35a31d157b9f0d177b2a0f42b35fd070f921ac22 Mon Sep 17 00:00:00 2001 From: Alexey Shvayka Date: Fri, 8 May 2020 18:33:31 +0300 Subject: [PATCH] Add String.prototype.split test --- .../custom-splitter-emulates-undefined.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js diff --git a/test/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js b/test/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js new file mode 100644 index 0000000000..d4dbc210c8 --- /dev/null +++ b/test/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Alexey Shvayka. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-string.prototype.split +description: > + [[IsHTMLDDA]] object as @@split method gets called. +info: | + String.prototype.split ( separator, limit ) + + [...] + 2. If separator is neither undefined nor null, then + a. Let splitter be ? GetMethod(separator, @@split). + b. If splitter is not undefined, then + i. Return ? Call(splitter, separator, « O, limit »). +features: [Symbol.split, IsHTMLDDA] +---*/ + +var separator = $262.IsHTMLDDA; +var splitterGets = 0; +Object.defineProperty(separator, Symbol.split, { + get: function() { + splitterGets += 1; + return separator; + }, + configurable: true, +}); + +assert.sameValue("".split(separator), null); +assert.sameValue(splitterGets, 1);