Skip to content

Commit

Permalink
Support more node types in generateUidBasedOnNode (#11260)
Browse files Browse the repository at this point in the history
* Support more node types in generateUidBasedOnNode

* More nodes
  • Loading branch information
jridgewell committed Mar 14, 2020
1 parent b85d9f5 commit 661ffbd
Show file tree
Hide file tree
Showing 13 changed files with 192 additions and 101 deletions.
Expand Up @@ -64,7 +64,7 @@ function _foo() {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_bar2 = function _ref2() {
_bar2 = function _bar4() {
_bar2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var baz;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
Expand All @@ -83,7 +83,7 @@ function _foo() {
return _bar2.apply(this, arguments);
};

bar = function _ref() {
bar = function _bar3() {
return _bar2.apply(this, arguments);
};

Expand Down
@@ -1,8 +1,8 @@
async function g() {
let A = babelHelpers.decorate([dec], function (_initialize, _super) {
let A = babelHelpers.decorate([dec], function (_initialize, _await$B) {
"use strict";

class A extends _super {
class A extends _await$B {
constructor(...args) {
super(...args);

Expand Down
@@ -1,8 +1,8 @@
function* g() {
let A = babelHelpers.decorate([dec], function (_initialize, _super) {
let A = babelHelpers.decorate([dec], function (_initialize, _yield$B) {
"use strict";

class A extends _super {
class A extends _yield$B {
constructor(...args) {
super(...args);

Expand Down
@@ -1,4 +1,4 @@
var _deep$obj, _deep$obj2, _deep$obj3, _deep$obj4, _ref, _ref2, _ref3, _ref4, _deep$obj5, _ref5, _deep$obj6, _ref6, _deep$obj7, _ref7, _deep$obj8, _ref8;
var _deep$obj, _deep$obj2, _deep$obj3, _deep$obj4, _key, _key2, _key3, _key4, _deep$obj5, _key5, _deep$obj6, _key6, _deep$obj7, _key7, _deep$obj8, _key8;

var x = 0;
var sets = 0;
Expand Down Expand Up @@ -38,30 +38,30 @@ expect(gets).toBe(3);
expect((_deep$obj4 = deep.obj).x && (_deep$obj4.x = 3)).toBe(0);
expect(gets).toBe(4);
var key = 0;
expect(obj[_ref = ++key] || (obj[_ref] = 1)).toBe(1);
expect(obj[_key = ++key] || (obj[_key] = 1)).toBe(1);
expect(key).toBe(1);
key = 0;
expect(obj[_ref2 = ++key] || (obj[_ref2] = 2)).toBe(1);
expect(obj[_key2 = ++key] || (obj[_key2] = 2)).toBe(1);
expect(key).toBe(1);
key = 0;
expect(obj[_ref3 = ++key] && (obj[_ref3] = 0)).toBe(0);
expect(obj[_key3 = ++key] && (obj[_key3] = 0)).toBe(0);
expect(key).toBe(1);
key = 0;
expect(obj[_ref4 = ++key] && (obj[_ref4] = 3)).toBe(0);
expect(obj[_key4 = ++key] && (obj[_key4] = 3)).toBe(0);
expect(key).toBe(1);
key = 0;
expect((_deep$obj5 = deep.obj)[_ref5 = ++key] || (_deep$obj5[_ref5] = 1)).toBe(1);
expect((_deep$obj5 = deep.obj)[_key5 = ++key] || (_deep$obj5[_key5] = 1)).toBe(1);
expect(gets).toBe(5);
expect(key).toBe(1);
key = 0;
expect((_deep$obj6 = deep.obj)[_ref6 = ++key] || (_deep$obj6[_ref6] = 2)).toBe(1);
expect((_deep$obj6 = deep.obj)[_key6 = ++key] || (_deep$obj6[_key6] = 2)).toBe(1);
expect(gets).toBe(6);
expect(key).toBe(1);
key = 0;
expect((_deep$obj7 = deep.obj)[_ref7 = ++key] && (_deep$obj7[_ref7] = 0)).toBe(0);
expect((_deep$obj7 = deep.obj)[_key7 = ++key] && (_deep$obj7[_key7] = 0)).toBe(0);
expect(gets).toBe(7);
expect(key).toBe(1);
key = 0;
expect((_deep$obj8 = deep.obj)[_ref8 = ++key] && (_deep$obj8[_ref8] = 3)).toBe(0);
expect((_deep$obj8 = deep.obj)[_key8 = ++key] && (_deep$obj8[_key8] = 3)).toBe(0);
expect(gets).toBe(8);
expect(key).toBe(1);
@@ -1,4 +1,4 @@
var _obj$x, _obj$x2, _deep$obj, _x, _deep$obj2, _x2, _ref, _obj, _ref2, _obj2, _deep$obj3, _ref3, _ref4, _deep$obj4, _ref5, _ref6;
var _obj$x, _obj$x2, _deep$obj, _deep$obj$x, _deep$obj2, _deep$obj2$x, _key, _obj$_key, _key2, _obj$_key2, _deep$obj3, _key3, _deep$obj3$_key, _deep$obj4, _key4, _deep$obj4$_key;

var x = undefined;
var sets = 0;
Expand Down Expand Up @@ -26,23 +26,23 @@ var deep = {

};
obj.x = undefined;
expect((_x = (_deep$obj = deep.obj).x) !== null && _x !== void 0 ? _x : _deep$obj.x = 1).toBe(1);
expect((_deep$obj$x = (_deep$obj = deep.obj).x) !== null && _deep$obj$x !== void 0 ? _deep$obj$x : _deep$obj.x = 1).toBe(1);
expect(gets, 1);
expect((_x2 = (_deep$obj2 = deep.obj).x) !== null && _x2 !== void 0 ? _x2 : _deep$obj2.x = 2).toBe(1);
expect((_deep$obj2$x = (_deep$obj2 = deep.obj).x) !== null && _deep$obj2$x !== void 0 ? _deep$obj2$x : _deep$obj2.x = 2).toBe(1);
expect(gets, 2);
var key = 0;
obj.x = undefined;
expect((_obj = obj[_ref = ++key]) !== null && _obj !== void 0 ? _obj : obj[_ref] = 1).toBe(1);
expect((_obj$_key = obj[_key = ++key]) !== null && _obj$_key !== void 0 ? _obj$_key : obj[_key] = 1).toBe(1);
expect(key, 1);
key = 0;
expect((_obj2 = obj[_ref2 = ++key]) !== null && _obj2 !== void 0 ? _obj2 : obj[_ref2] = 2).toBe(1);
expect((_obj$_key2 = obj[_key2 = ++key]) !== null && _obj$_key2 !== void 0 ? _obj$_key2 : obj[_key2] = 2).toBe(1);
expect(key, 1);
obj.x = undefined;
key = 0;
expect((_ref4 = (_deep$obj3 = deep.obj)[_ref3 = ++key]) !== null && _ref4 !== void 0 ? _ref4 : _deep$obj3[_ref3] = 1).toBe(1);
expect((_deep$obj3$_key = (_deep$obj3 = deep.obj)[_key3 = ++key]) !== null && _deep$obj3$_key !== void 0 ? _deep$obj3$_key : _deep$obj3[_key3] = 1).toBe(1);
expect(gets, 3);
expect(key, 1);
key = 0;
expect((_ref6 = (_deep$obj4 = deep.obj)[_ref5 = ++key]) !== null && _ref6 !== void 0 ? _ref6 : _deep$obj4[_ref5] = 2).toBe(1);
expect((_deep$obj4$_key = (_deep$obj4 = deep.obj)[_key4 = ++key]) !== null && _deep$obj4$_key !== void 0 ? _deep$obj4$_key : _deep$obj4[_key4] = 2).toBe(1);
expect(gets, 4);
expect(key, 1);
Expand Up @@ -6,11 +6,11 @@ var _$a = {
1: 1,
a: 1
},
_ref = key++,
_key = key++,
{
[_ref]: y
[_key]: y
} = _$a,
x = babelHelpers.objectWithoutProperties(_$a, [_ref].map(babelHelpers.toPropertyKey));
x = babelHelpers.objectWithoutProperties(_$a, [_key].map(babelHelpers.toPropertyKey));

expect(x).toEqual({
a: 1
Expand All @@ -24,13 +24,13 @@ var _$ = {
2: 2,
3: 3
},
_ref2 = ++key,
_ref3 = ++key,
_key2 = ++key,
_key3 = ++key,
{
[_ref2]: y,
[_ref3]: z
[_key2]: y,
[_key3]: z
} = _$,
rest = babelHelpers.objectWithoutProperties(_$, [_ref2, _ref3].map(babelHelpers.toPropertyKey));
rest = babelHelpers.objectWithoutProperties(_$, [_key2, _key3].map(babelHelpers.toPropertyKey));

expect(y).toBe(2);
expect(z).toBe(3); // pure, computed property should remain as-is
Expand Down
Expand Up @@ -2,9 +2,9 @@ var key, x, y, z; // impure

key = 1;

var _ref = key++,
var _key = key++,
{
[_ref]: {
[_key]: {
y
}
} = {
Expand All @@ -18,7 +18,7 @@ var _ref = key++,
a: 1,
y: 1
}
}[_ref], ["y"]);
}[_key], ["y"]);

expect(x).toEqual({
a: 1
Expand All @@ -38,18 +38,18 @@ var _$ = {
z: 3
}
},
_ref2 = ++key,
_ref3 = ++key,
_key2 = ++key,
_key3 = ++key,
{
[_ref3]: {
[_key3]: {
y
},
[_ref2]: {
[_key2]: {
z
}
} = _$,
rest_y = babelHelpers.objectWithoutProperties(_$[_ref3], ["y"]),
rest_z = babelHelpers.objectWithoutProperties(_$[_ref2], ["z"]);
rest_y = babelHelpers.objectWithoutProperties(_$[_key3], ["y"]),
rest_z = babelHelpers.objectWithoutProperties(_$[_key2], ["z"]);

expect(y).toBe(2);
expect(rest_y).toEqual({
Expand Down
@@ -1,13 +1,13 @@
"use strict";

var _a, _param, _foo, _x, _param2, _bar, _param3, _obj$baz, _obj;
var _a, _b, _foo, _x, _y, _bar, _d, _obj$baz, _obj;

const q = (_foo = foo, _a = a, _param = [...b], function foo(_argPlaceholder) {
return _foo(_a, ..._param, _argPlaceholder);
const q = (_foo = foo, _a = a, _b = [...b], function foo(_argPlaceholder) {
return _foo(_a, ..._b, _argPlaceholder);
});
const w = (_bar = bar, _x = x, _param2 = [...y], function bar(_argPlaceholder2, _argPlaceholder3) {
return _bar(1, _x, _argPlaceholder2, ..._param2, _argPlaceholder3, 2);
const w = (_bar = bar, _x = x, _y = [...y], function bar(_argPlaceholder2, _argPlaceholder3) {
return _bar(1, _x, _argPlaceholder2, ..._y, _argPlaceholder3, 2);
});
const z = (_obj = obj, _obj$baz = _obj.baz, _param3 = [...d], function baz(_argPlaceholder4) {
return _obj$baz.call(_obj, _argPlaceholder4, ..._param3);
const z = (_obj = obj, _obj$baz = _obj.baz, _d = [...d], function baz(_argPlaceholder4) {
return _obj$baz.call(_obj, _argPlaceholder4, ..._d);
});
@@ -1,4 +1,4 @@
var _ref, _ref2;
var _ref, _;

const abs = Math.abs;
const value = (_ref = (_ref2 = -5.9, abs(_ref2)), Math.floor(_ref));
const value = (_ref = (_ = -5.9, abs(_)), Math.floor(_ref));
@@ -1,10 +1,10 @@
var _ref, _ref2, _ref3;
var _ref, _ref2, _;

function area(rect) {
return rect.width * rect.height;
}

const result = (_ref = (_ref2 = (_ref3 = -5, Math.abs(_ref3)), {
const result = (_ref = (_ref2 = (_ = -5, Math.abs(_)), {
width: _ref2,
height: _ref2 + 3
}), area(_ref));
@@ -1,7 +1,7 @@
var _ref, _ref2, _ref3, _ref4;
var _ref, _ref2, _ref3, _;

const result = (_ref = (_ref2 = (_ref3 = (_ref4 = -2.2 // -2.2
, Math.floor(_ref4) // -3
const result = (_ref = (_ref2 = (_ref3 = (_ = -2.2 // -2.2
, Math.floor(_) // -3
), () => Math.pow(_ref3, 5) // () => -243
), _ref2() // -243
), Math.sign(_ref)); // -1
@@ -1,6 +1,6 @@
function first() {
var _ref;
var _index;

var index = 0;
return _ref = index++, _ref < 0 || arguments.length <= _ref ? undefined : arguments[_ref];
return _index = index++, _index < 0 || arguments.length <= _index ? undefined : arguments[_index];
}

0 comments on commit 661ffbd

Please sign in to comment.