11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst stdoutWrite = process.stdout.write;
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cilet buf = '';
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciprocess.stdout.write = (string) => buf = string;
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconsole.count();
131cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'default: 1\n');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci// 'default' and undefined are equivalent
161cb0ef41Sopenharmony_ciconsole.count('default');
171cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'default: 2\n');
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconsole.count('a');
201cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'a: 1\n');
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciconsole.count('b');
231cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'b: 1\n');
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciconsole.count('a');
261cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'a: 2\n');
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciconsole.count();
291cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'default: 3\n');
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ciconsole.count({});
321cb0ef41Sopenharmony_ciassert.strictEqual(buf, '[object Object]: 1\n');
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ciconsole.count(1);
351cb0ef41Sopenharmony_ciassert.strictEqual(buf, '1: 1\n');
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciconsole.count(null);
381cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'null: 1\n');
391cb0ef41Sopenharmony_ci
401cb0ef41Sopenharmony_ciconsole.count('null');
411cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'null: 2\n');
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_ciconsole.countReset();
441cb0ef41Sopenharmony_ciconsole.count();
451cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'default: 1\n');
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ciconsole.countReset('a');
481cb0ef41Sopenharmony_ciconsole.count('a');
491cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'a: 1\n');
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_ci// countReset('a') only reset the a counter
521cb0ef41Sopenharmony_ciconsole.count();
531cb0ef41Sopenharmony_ciassert.strictEqual(buf, 'default: 2\n');
541cb0ef41Sopenharmony_ci
551cb0ef41Sopenharmony_ciprocess.stdout.write = stdoutWrite;
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci// Symbol labels do not work. Only check that the `Error` is a `TypeError`. Do
581cb0ef41Sopenharmony_ci// not check the message because it is different depending on the JavaScript
591cb0ef41Sopenharmony_ci// engine.
601cb0ef41Sopenharmony_ciassert.throws(
611cb0ef41Sopenharmony_ci  () => console.count(Symbol('test')),
621cb0ef41Sopenharmony_ci  TypeError);
631cb0ef41Sopenharmony_ciassert.throws(
641cb0ef41Sopenharmony_ci  () => console.countReset(Symbol('test')),
651cb0ef41Sopenharmony_ci  TypeError);
66