MCPcopy Create free account
hub / github.com/dop251/goja / TestArraySortNonStdArray

Function TestArraySortNonStdArray

builtin_arrray_test.go:237–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

235}
236
237func TestArraySortNonStdArray(t *testing.T) {
238 const SCRIPT = `
239 const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd'];
240
241 Object.defineProperty(array, '2', {
242 get() {
243 array.pop();
244 array.pop();
245 return this.foo;
246 },
247 set(v) {
248 this.foo = v;
249 }
250 });
251
252 array.sort();
253
254 assert.sameValue(array[0], 'b');
255 assert.sameValue(array[1], 'c');
256 assert.sameValue(array[3], undefined);
257 assert.sameValue(array[4], undefined);
258 assert.sameValue('5' in array, false);
259 assert.sameValue(array.hasOwnProperty('5'), false);
260 assert.sameValue(array.length, 6);
261 assert.sameValue(array.foo, undefined);
262
263 assert.sameValue(array[2], undefined);
264 assert.sameValue(array.length, 4);
265 `
266 testScriptWithTestLib(SCRIPT, _undefined, t)
267}
268
269func TestArrayConcat(t *testing.T) {
270 const SCRIPT = `

Callers

nothing calls this directly

Calls 1

testScriptWithTestLibFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…