forked from lightscript/babel-plugin-lightscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/fixtures/enhanced-comprehensions/object-assign/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{...for elem e in arr: | ||
{ [e]: e, [e+1]: e+1 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
obj = {...for let i=0; i<2; i++: | ||
{ [`${i}.0`]: i, [`${i}.1`]: i+1 } | ||
} | ||
|
||
assert.deepEqual(obj, { "0.0": 0, "0.1": 1, "1.0": 1, "1.1": 2 }) |
6 changes: 6 additions & 0 deletions
6
test/fixtures/enhanced-comprehensions/object-assign/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(() => { | ||
const _obj = {};for (let _i = 0, _len = arr.length; _i < _len; _i++) { | ||
const e = arr[_i]; | ||
Object.assign(_obj, { [e]: e, [e + 1]: e + 1 }); | ||
}return _obj; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
{ ...for elem x in arr: ({a: x}) } | ||
|
||
{ ...for elem x in arr: ({[x]: f(x)}) } | ||
|
||
{ | ||
a: b | ||
...if c: ({d: e}) | ||
} |
15 changes: 14 additions & 1 deletion
15
test/fixtures/enhanced-comprehensions/object-basic/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
(() => { | ||
const _obj = {};for (let _i = 0, _len = arr.length; _i < _len; _i++) { | ||
const x = arr[_i];_obj[x] = f(x); | ||
const x = arr[_i];_obj.a = x; | ||
}return _obj; | ||
})(); | ||
|
||
(() => { | ||
const _obj2 = {};for (let _i2 = 0, _len2 = arr.length; _i2 < _len2; _i2++) { | ||
const x = arr[_i2];_obj2[x] = f(x); | ||
}return _obj2; | ||
})(); | ||
|
||
(() => { | ||
const _obj3 = { | ||
a: b | ||
};if (c) _obj3.d = e; | ||
return _obj3; | ||
})(); |
1 change: 1 addition & 0 deletions
1
test/fixtures/enhanced-comprehensions/object-malformed-labeled-stmt/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ ...if true: { k: v } } |
3 changes: 3 additions & 0 deletions
3
test/fixtures/enhanced-comprehensions/object-malformed-labeled-stmt/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Object comprehensions must end with an object expression." | ||
} |