Skip to content

Commit eba6ec7

Browse files
committed
Remove Runnable#inspect() and utils.ngettext() (#4230)
1 parent a4a4d50 commit eba6ec7

File tree

5 files changed

+6
-93
lines changed

5 files changed

+6
-93
lines changed

lib/runnable.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -222,31 +222,6 @@ Runnable.prototype.clearTimeout = function() {
222222
clearTimeout(this.timer);
223223
};
224224

225-
/**
226-
* Inspect the runnable void of private properties.
227-
*
228-
* @private
229-
* @return {string}
230-
*/
231-
Runnable.prototype.inspect = function() {
232-
return JSON.stringify(
233-
this,
234-
function(key, val) {
235-
if (key[0] === '_') {
236-
return;
237-
}
238-
if (key === 'parent') {
239-
return '#<Suite>';
240-
}
241-
if (key === 'ctx') {
242-
return '#<Context>';
243-
}
244-
return val;
245-
},
246-
2
247-
);
248-
};
249-
250225
/**
251226
* Reset the timeout.
252227
*

lib/runner.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var EVENT_ROOT_SUITE_RUN = Suite.constants.EVENT_ROOT_SUITE_RUN;
1919
var STATE_FAILED = Runnable.constants.STATE_FAILED;
2020
var STATE_PASSED = Runnable.constants.STATE_PASSED;
2121
var dQuote = utils.dQuote;
22-
var ngettext = utils.ngettext;
2322
var sQuote = utils.sQuote;
2423
var stackFilter = utils.stackTraceFilter();
2524
var stringify = utils.stringify;
@@ -271,12 +270,8 @@ Runner.prototype.checkGlobals = function(test) {
271270
this._globals = this._globals.concat(leaks);
272271

273272
if (leaks.length) {
274-
var format = ngettext(
275-
leaks.length,
276-
'global leak detected: %s',
277-
'global leaks detected: %s'
278-
);
279-
var error = new Error(util.format(format, leaks.map(sQuote).join(', ')));
273+
var msg = 'global leak(s) detected: %s';
274+
var error = new Error(util.format(msg, leaks.map(sQuote).join(', ')));
280275
this.fail(test, error);
281276
}
282277
};

lib/utils.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -753,38 +753,6 @@ exports.dQuote = function(str) {
753753
return '"' + str + '"';
754754
};
755755

756-
/**
757-
* Provides simplistic message translation for dealing with plurality.
758-
*
759-
* @description
760-
* Use this to create messages which need to be singular or plural.
761-
* Some languages have several plural forms, so _complete_ message clauses
762-
* are preferable to generating the message on the fly.
763-
*
764-
* @private
765-
* @param {number} n - Non-negative integer
766-
* @param {string} msg1 - Message to be used in English for `n = 1`
767-
* @param {string} msg2 - Message to be used in English for `n = 0, 2, 3, ...`
768-
* @returns {string} message corresponding to value of `n`
769-
* @example
770-
* var sprintf = require('util').format;
771-
* var pkgs = ['one', 'two'];
772-
* var msg = sprintf(
773-
* ngettext(
774-
* pkgs.length,
775-
* 'cannot load package: %s',
776-
* 'cannot load packages: %s'
777-
* ),
778-
* pkgs.map(sQuote).join(', ')
779-
* );
780-
* console.log(msg); // => cannot load packages: 'one', 'two'
781-
*/
782-
exports.ngettext = function(n, msg1, msg2) {
783-
if (typeof n === 'number' && n >= 0) {
784-
return n === 1 ? msg1 : msg2;
785-
}
786-
};
787-
788756
/**
789757
* It's a noop.
790758
* @public

test/unit/runner.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('Runner', function() {
121121
global.foo = 'bar';
122122
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
123123
expect(_test, 'to be', test);
124-
expect(_err, 'to have message', "global leak detected: 'foo'");
124+
expect(_err, 'to have message', "global leak(s) detected: 'foo'");
125125
delete global.foo;
126126
done();
127127
});
@@ -183,7 +183,7 @@ describe('Runner', function() {
183183
global.bar = 'baz';
184184
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
185185
expect(_test, 'to be', test);
186-
expect(_err, 'to have message', "global leaks detected: 'foo', 'bar'");
186+
expect(_err.message, 'to be', "global leak(s) detected: 'foo', 'bar'");
187187
delete global.foo;
188188
delete global.bar;
189189
done();
@@ -217,7 +217,7 @@ describe('Runner', function() {
217217
global.bar = 'detect-me';
218218
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
219219
expect(_test.title, 'to be', 'im a test about lions');
220-
expect(_err, 'to have message', "global leak detected: 'bar'");
220+
expect(_err, 'to have message', "global leak(s) detected: 'bar'");
221221
delete global.foo;
222222
delete global.bar;
223223
done();
@@ -229,7 +229,7 @@ describe('Runner', function() {
229229
global.derp = 'bar';
230230
runner.on(EVENT_TEST_FAIL, function(_test, _err) {
231231
expect(_test.title, 'to be', 'herp');
232-
expect(_err, 'to have message', "global leak detected: 'derp'");
232+
expect(_err, 'to have message', "global leak(s) detected: 'derp'");
233233
delete global.derp;
234234
done();
235235
});

test/unit/utils.spec.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -720,31 +720,6 @@ describe('lib/utils', function() {
720720
});
721721
});
722722

723-
describe('ngettext', function() {
724-
var singular = 'singular';
725-
var plural = 'plural';
726-
727-
it("should return plural string if 'n' is 0", function() {
728-
expect(utils.ngettext(0, singular, plural), 'to be', plural);
729-
});
730-
731-
it("should return singular string if 'n' is 1", function() {
732-
expect(utils.ngettext(1, singular, plural), 'to be', singular);
733-
});
734-
735-
it("should return plural string if 'n' is greater than 1", function() {
736-
var arr = ['aaa', 'bbb'];
737-
expect(utils.ngettext(arr.length, singular, plural), 'to be', plural);
738-
});
739-
740-
it("should return undefined if 'n' is not a non-negative integer", function() {
741-
expect(utils.ngettext('', singular, plural), 'to be undefined');
742-
expect(utils.ngettext(-1, singular, plural), 'to be undefined');
743-
expect(utils.ngettext(true, singular, plural), 'to be undefined');
744-
expect(utils.ngettext({}, singular, plural), 'to be undefined');
745-
});
746-
});
747-
748723
describe('createMap', function() {
749724
it('should return an object with a null prototype', function() {
750725
expect(Object.getPrototypeOf(utils.createMap()), 'to be', null);

0 commit comments

Comments
 (0)