Skip to content

Commit

Permalink
Don't quote object keys unless it's strictly necessary.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 18, 2014
1 parent af02b9b commit cd85d24
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions test/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,13 @@ var runArrayTests = function () {
});

it('should work with an array-like object', function () {
var obj = { '0': 1, '1': 2, '2': 3, length: 3 };
var obj = { 0: 1, 1: 2, 2: 3, length: 3 };
var found = Array.prototype.find.call(obj, function (item) { return item === 2; });
expect(found).to.equal(2);
});

it('should work with an array-like object with negative length', function () {
var obj = { '0': 1, '1': 2, '2': 3, length: -3 };
var obj = { 0: 1, 1: 2, 2: 3, length: -3 };
var found = Array.prototype.find.call(obj, function (item) {
throw new Error('should not reach here');
});
Expand All @@ -314,7 +314,7 @@ var runArrayTests = function () {
});

it('should work with a sparse array-like object', function () {
var obj = { '0': 1, '2': undefined, length: 3.2 };
var obj = { 0: 1, 2: undefined, length: 3.2 };
var seen = [];
var found = Array.prototype.find.call(obj, function (item, idx) {
seen.push([idx, item]);
Expand Down Expand Up @@ -359,13 +359,13 @@ var runArrayTests = function () {
});

it('should work with an array-like object', function () {
var obj = { '0': 1, '1': 2, '2': 3, length: 3 };
var obj = { 0: 1, 1: 2, 2: 3, length: 3 };
var foundIndex = Array.prototype.findIndex.call(obj, function (item) { return item === 2; });
expect(foundIndex).to.equal(1);
});

it('should work with an array-like object with negative length', function () {
var obj = { '0': 1, '1': 2, '2': 3, length: -3 };
var obj = { 0: 1, 1: 2, 2: 3, length: -3 };
var foundIndex = Array.prototype.findIndex.call(obj, function (item) {
throw new Error('should not reach here');
});
Expand All @@ -385,7 +385,7 @@ var runArrayTests = function () {
});

it('should work with a sparse array-like object', function () {
var obj = { '0': 1, '2': undefined, length: 3.2 };
var obj = { 0: 1, 2: undefined, length: 3.2 };
var seen = [];
var foundIndex = Array.prototype.findIndex.call(obj, function (item, idx) {
seen.push([idx, item]);
Expand Down
6 changes: 3 additions & 3 deletions test/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,17 @@ var runStringTests = function () {
var callSite = {};

var str = 'The total is 10 ($11 with tax)';
callSite.raw = {'0': 'The total is ', '1': ' ($', '2': ' with tax)'};
callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)' };
expect(String.raw(callSite,10,11)).to.eql(str);

str = 'The total is {total} (${total * 1.01} with tax)';
callSite.raw = {'0': 'The total is ', '1': ' ($', '2': ' with tax)'};
callSite.raw = { 0: 'The total is ', 1: ' ($', 2: ' with tax)' };
expect(String.raw(callSite,'{total}','{total * 1.01}')).to.eql(str);
});

it('String.raw ReturnIfAbrupt - Less Substitutions', function () {
var callSite = {
raw: {'0': 'The total is ', '1': ' ($', '2': ' with tax)'}
raw: { 0: 'The total is ', 1: ' ($', 2: ' with tax)' }
};
var str = 'The total is 10 ($';
expect(String.raw(callSite, 10)).to.equal(str);
Expand Down

0 comments on commit cd85d24

Please sign in to comment.