11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst buffer = Buffer.from([1, 2, 3, 4, 5]);
61cb0ef41Sopenharmony_cilet arr;
71cb0ef41Sopenharmony_cilet b;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// Buffers should be iterable
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciarr = [];
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_cifor (b of buffer)
141cb0ef41Sopenharmony_ci  arr.push(b);
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciassert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci// Buffer iterators should be iterable
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciarr = [];
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_cifor (b of buffer[Symbol.iterator]())
241cb0ef41Sopenharmony_ci  arr.push(b);
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ciassert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci// buffer#values() should return iterator for values
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciarr = [];
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_cifor (b of buffer.values())
341cb0ef41Sopenharmony_ci  arr.push(b);
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ciassert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ci// buffer#keys() should return iterator for keys
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ciarr = [];
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_cifor (b of buffer.keys())
441cb0ef41Sopenharmony_ci  arr.push(b);
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ciassert.deepStrictEqual(arr, [0, 1, 2, 3, 4]);
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci// buffer#entries() should return iterator for entries
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ciarr = [];
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_cifor (b of buffer.entries())
541cb0ef41Sopenharmony_ci  arr.push(b);
551cb0ef41Sopenharmony_ci
561cb0ef41Sopenharmony_ciassert.deepStrictEqual(arr, [
571cb0ef41Sopenharmony_ci  [0, 1],
581cb0ef41Sopenharmony_ci  [1, 2],
591cb0ef41Sopenharmony_ci  [2, 3],
601cb0ef41Sopenharmony_ci  [3, 4],
611cb0ef41Sopenharmony_ci  [4, 5],
621cb0ef41Sopenharmony_ci]);
63