update
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
var test = require('tape');
|
||||
var v = require('es-value-fixtures');
|
||||
var forEach = require('for-each');
|
||||
|
||||
var inspect = require('../');
|
||||
|
||||
test('negative zero', function (t) {
|
||||
t.equal(inspect(0), '0', 'inspect(0) === "0"');
|
||||
t.equal(inspect(Object(0)), 'Object(0)', 'inspect(Object(0)) === "Object(0)"');
|
||||
|
||||
t.equal(inspect(-0), '-0', 'inspect(-0) === "-0"');
|
||||
t.equal(inspect(Object(-0)), 'Object(-0)', 'inspect(Object(-0)) === "Object(-0)"');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('numericSeparator', function (t) {
|
||||
forEach(v.nonBooleans, function (nonBoolean) {
|
||||
t['throws'](
|
||||
function () { inspect(true, { numericSeparator: nonBoolean }); },
|
||||
TypeError,
|
||||
inspect(nonBoolean) + ' is not a boolean'
|
||||
);
|
||||
});
|
||||
|
||||
t.test('3 digit numbers', function (st) {
|
||||
var failed = false;
|
||||
for (var i = -999; i < 1000; i += 1) {
|
||||
var actual = inspect(i);
|
||||
var actualSepNo = inspect(i, { numericSeparator: false });
|
||||
var actualSepYes = inspect(i, { numericSeparator: true });
|
||||
var expected = String(i);
|
||||
if (actual !== expected || actualSepNo !== expected || actualSepYes !== expected) {
|
||||
failed = true;
|
||||
t.equal(actual, expected);
|
||||
t.equal(actualSepNo, expected);
|
||||
t.equal(actualSepYes, expected);
|
||||
}
|
||||
}
|
||||
|
||||
st.notOk(failed, 'all 3 digit numbers passed');
|
||||
|
||||
st.end();
|
||||
});
|
||||
|
||||
t.equal(inspect(1e3), '1000', '1000');
|
||||
t.equal(inspect(1e3, { numericSeparator: false }), '1000', '1000, numericSeparator false');
|
||||
t.equal(inspect(1e3, { numericSeparator: true }), '1_000', '1000, numericSeparator true');
|
||||
t.equal(inspect(-1e3), '-1000', '-1000');
|
||||
t.equal(inspect(-1e3, { numericSeparator: false }), '-1000', '-1000, numericSeparator false');
|
||||
t.equal(inspect(-1e3, { numericSeparator: true }), '-1_000', '-1000, numericSeparator true');
|
||||
|
||||
t.equal(inspect(1234.5678, { numericSeparator: true }), '1_234.567_8', 'fractional numbers get separators');
|
||||
t.equal(inspect(1234.56789, { numericSeparator: true }), '1_234.567_89', 'fractional numbers get separators');
|
||||
t.equal(inspect(1234.567891, { numericSeparator: true }), '1_234.567_891', 'fractional numbers get separators');
|
||||
|
||||
t.end();
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (C) 2011-2017 whitequark <whitequark@whitequark.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Reference in New Issue
Block a user